Commit Graph

2288 Commits

Author SHA1 Message Date
Stefan Monnier 1a5e3f931c
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables.  For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.

Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?

I found some suspicious code, for which I added FIXMEs.

There are also a few changes to the main files.

* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined.  [ Needed to get
the tests to pass. ]

* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it).  Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.

* lisp/org.el (org-log-beginning): Add FIXME.

* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.

* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.

* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded.  Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.

* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler.  Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.

* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.

* testing/lisp/test-org-timer.el: Require `org-timer`.

* testing/lisp/test-org-table.el: Require `ox`.

* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded.  Also require `capture`, and
add missing `provide` statement.

* testing/lisp/test-org-pcomplete.el: Require `org`.

* testing/lisp/test-org-list.el: Require `org-list` and `org`.

* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.

* testing/lisp/test-org-footnote.el: Require `org-footnote`.

* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded.  Also require `org` and
`org-inlinetask`.

* testing/lisp/test-org-duration.el: Require `org-duration`.

* testing/lisp/test-org-datetree.el: Require `org-datetree`.

* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.

* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.

* testing/lisp/test-org-archive.el: Require `org-archive`.

* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.

* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.

* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.

* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.

* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.

* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.

* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.

* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded.  Use `with-current-buffer`.

* testing/lisp/test-ob-julia.el: Require `ob-core`.

* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.

* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.

* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.

* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-15 19:17:19 +08:00
Ihor Radchenko 86c4635dba
test-org-link/store-link: Update tests for 4fc2c8dd8
* testing/lisp/test-ol.el (test-org-link/store-link): Do not expect
duplicating raw link in the file link description.
2022-09-13 22:11:05 +08:00
Ihor Radchenko c9db3c51ab
test-org-clock/clocktable/step: Add test for the new ":step quarter"
* testing/lisp/test-org-clock.el (test-org-clock/clocktable/step): Add
new test case.
2022-09-09 21:16:46 +08:00
Bruno BARBIER 8151d52574
ob-shell: Use `process-file' when stdin or cmdline
lisp/ob-shell.el (org-babel-sh-evaluate): Use `process-file' (instead
of `call-process-shell-command') so that `org-babel-sh-evaluate' will
invoke file name handlers based on `default-directory', if needed,
like when using a remote directory.

lisp/org-compat.el (with-connection-local-variables): New
compatibility macro.

testing/lisp/test-ob-shell.el (ob-shell/remote-with-stdin-or-cmdline):
New test.

testing/org-test.el (org-test-with-tramp-remote-dir): New macro.

Fixes https://list.orgmode.org/CKMOBWBK709F.1RUN69SRWB64U@laptop/.
2022-09-05 18:31:39 +08:00
Max Nikulin ac2d0a249e
org.el: Fix percent substitutions in `org-open-file'
* lisp/org.el (org--open-file-format-command): New function with better
coverage of mailcap RFC 1524 syntax.  Do not replace percent character
in file name or link component, fix substitution of multiple regular
expression groups matched in the link target.
(org-open-file): Use `org--open-file-format-command' instead of inline
code.
* testing/lisp/test-org.el (org-test/org--open-file-format-command):
Tests for `org--open-file-format-command'.

The primary goal of moving code outside of `org-open-file' function is to
make it testable.

It should fix the following issues:
- Maxim Nikulin. greedy substitution in org-open-file.
  Wed, 20 Jan 2021 23:08:35 +0700.
  https://list.orgmode.org/ru9ki4$t5e$1@ciao.gmane.io
- Rodrigo Morales. Org mode links: Open a PDF file at a given page
  and highlight a given string. Tue, 02 Mar 2021 15:07:32 -0500.
  https://list.orgmode.org/87lfb5pbej.fsf@gmail.com
2022-09-05 13:27:14 +08:00
Sébastien Miquel 72f66ca0b9
New babel syntax to pass src block contents as argument
* lisp/ob-ref.el (org-babel-ref-resolve): Add support for
`named-block[]' syntax, resolving to the contents of a named-block.
* lisp/ob-core.el (org-babel-read-element): Read a code block into its
contents, like other blocks.
* testing/listp/test-ob.el (test-ob/block-content-resolution): Test
block content resolution.
* doc/org-manual.org: Document syntax.
* etc/ORG-NEWS: Document syntax.
2022-08-31 11:31:16 +08:00
Max Nikulin 372788a189
ol-info: Define :insert-description function
* lisp/ol-info.el (org-info--link-file-node): New helper to parse info
link info file (manual) name and node.
(org-info-follow-link, org-info-export): Use `org-info--link-file-node'.
(org-info-description-as-command): New function to create description
for info links that may executed to view the manual.
(org-link-parameters): Specify `org-info-description-as-command' as
`:insert-description' for info links.
(org-info-other-documents): Add URL of directory index.
* testing/lisp/test-org-info.el (test-org-info/export): Add cases for
texinfo export with link description.
(test-org-info/link-file-node, test-org-info/description-as-command):
New tests for new functions `org-info--link-file-node' and
`org-info-description-as-command'.

Use recently added :insert-description feature of `org-link'.
Alternative separators between file name and node ":", "::", "#:"
are preserved.  Added interpretation of empty path or omitted
file name as info dir index.
2022-08-26 21:09:39 +08:00
Ihor Radchenko b8a0ddf52f
Use the full org-fold-core API when `org-fold-core-style' is `overlays'
The old fallback folding mechanism was re-using old function versions
to work with overlay folds directly.  Switch to using org-fold-core
API instead.  This avoids code duplication.

* lisp/ol.el (org-toggle-link-display--overlays): Merge overlay and
text-property versions.
(org-toggle-link-display--text-properties):
(org-toggle-link-display):
* lisp/org-cycle.el (org-cycle-overview--overlays):
(org-cycle-overview--text-properties):
(org-cycle-overview):
(org-cycle-content--text-properties):
(org-cycle-content):
(org-cycle-content--overlays):
* lisp/org-element.el (org-element-swap-A-B--overlays):
(org-element-swap-A-B):
(org-element-swap-A-B--text-properties):
* lisp/org-fold.el (org-fold-save-outline-visibility--overlays):
(org-fold-save-outline-visibility--text-properties):
(org-fold-save-outline-visibility):
(org-fold-region--overlays):
(org-fold-region):
(org-fold-show-all--text-properties):
(org-fold-show-all--overlays):
(org-fold-show-all):
(org-fold-show-branches-buffer--text-properties):
(org-fold-show-branches-buffer):
(org-fold-show-branches-buffer--overlays):
(org-fold--hide-drawers--overlays):
(org-fold--hide-drawers--text-properties):
(org-fold--hide-drawers):
(org-fold-show-set-visibility--overlays):
(org-fold-show-set-visibility--text-properties):
(org-fold-show-set-visibility):
(org-fold-check-before-invisible-edit--overlays):
(org-fold-check-before-invisible-edit--text-properties):
(org-fold-check-before-invisible-edit):
(org-fold--hide-wrapper-toggle):
* lisp/org-inlinetask.el (org-inlinetask-toggle-visibility--text-properties):
(org-inlinetask-toggle-visibility):
(org-inlinetask-toggle-visibility--overlays):
* lisp/org-list.el (org-list-swap-items--text-properties):
(org-list-swap-items):
(org-list-swap-items--overlays):
* lisp/org-macs.el (org-invisible-p--text-properties):
(org-invisible-p):
(org-invisible-p--overlays):
(org-find-visible--overlays):
(org-find-visible--text-properties):
(org-find-visible):
(org-find-invisible--overlays):
(org-find-invisible--text-properties):
(org-find-invisible):
* lisp/org.el (org-next-visible-heading--overlays):
(org-next-visible-heading--text-properties):
(org-next-visible-heading):
(org--forward-paragraph-once--overlays):
(org--forward-paragraph-once--text-properties):
(org--forward-paragraph-once):
(org--backward-paragraph-once--overlays):
(org--backward-paragraph-once--text-properties):
(org--backward-paragraph-once):

* testing/lisp/test-org.el (test-org/drag-element-backward):
(test-org/drag-element-forward): Update tests.
2022-08-13 15:03:28 +08:00
Hraban Luyat 8a781d35dc
ob-tangle.el: fix ‘:comments noweb’ double linking
* lisp/ob-tangle.el: Refactor the double implementation to a single
helper function.  This avoids the double link wrapping.

* testing/lisp/test-ob-tangle.el: Add unit tests.

Babel tangle allows inserting comments at the tangled site which link
back to the source in the org file.  This linking was implemented
twice, to handle separate cases, but when using ‘:comments noweb’ it
ended up going through both codepaths.  This resulted in doubly
wrapped links.

By refactoring all link generation into a single function, this double
wrapping is avoided.

Example file, /tmp/test.org:

    * Inner
    #+name: inner
    #+begin_src emacs-lisp
    2
    #+end_src

    * Main
    #+header: :tangle test.el :comments noweb :noweb yes
    #+begin_src emacs-lisp
    1
    <<inner>>
    #+end_src

Before:

    ;; [[file:test.org::*Main][Main:1]]
    1
    ;; [[[[file:/tmp/test.org::inner][inner]]][inner]]
    2
    ;; inner ends here
    ;; Main:1 ends here

After:

    ;; [[file:test.org::*Main][Main:1]]
    1
    ;; [[file:test.org::inner][inner]]
    2
    ;; inner ends here
    ;; Main:1 ends here
2022-08-13 14:39:09 +08:00
Ihor Radchenko f71546cc9f
* testing/lisp/test-ol.el: Fix test name
(test-org-link/insert-link-insert-description): Use test name matching
test regexp selector.
2022-08-06 13:52:44 +08:00
Hugo Heagren 2bbb92a72d
test-ol: tests for insert-description param when inserting links
* test-ol (test-ol-with-link-parameters-as): Convenience macro for
testing.
(test-ol-insert-link-get-desc): Convenience macro for testing.
(test-ol/return-foobar): Convenience function for testing.
(test-ol/insert-link-insert-description): Test for various values of
`:insert-description' in `org-link-parameters' (including
`test-ol/return-foobar').
2022-08-06 13:46:36 +08:00
Ihor Radchenko 215de6176b
Partially revert "org-mode: Make local variables effective during Org startup"
This reverts commit e22b4eb7aa.

See
https://list.orgmode.org/87r11wkmew.fsf@ucl.ac.uk/T/#mab6359ed2107d5515c6bb6b266551f0c5049ceca

The problem with the commit is that correctly loading local variables
early requires re-implementing all the built-in tricks done by Emacs,
like not enabling local variables in temp buffers or non-file buffers.

In addition, even if we call `hack-local-variables' manually, Emacs
will repeat the normal call later, possibly asking for non-safe
variables twice.

In conclusion, the whole idea of manual triggering local variables is
fragile and should better be handled by Emacs itself via stable API.

testing/.dir-locals.el is kept.
2022-08-05 19:57:36 +08:00
Ihor Radchenko e22b4eb7aa
org-mode: Make local variables effective during Org startup
* lisp/org.el (org-mode): Call `hack-local-variables' early during Org
mode startup.  This way, Org startup options will regard local
variable settings.

* testing/.dir-locals.el: Create a stub dir-locals file to prevent
tests from being affected by directory-local settings of the root Org
repo folder.

Fixes
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
2022-07-31 18:17:53 +08:00
Max Nikulin 20274454c6
test-ol: Rename cases to match the default selector
* testing/lisp/test-ol.el (test-ol/encode): Rename to
`test-org-link/encode'.
(test-ol/decode): Rename to `test-org-link/decode'.
(test-ol/encode-url-with-escaped-char): Rename to
`test-org-link/encode-url-with-escaped-char'.
(test-ol/org-toggle-link-display): Rename to
`test-org-link/toggle-link-display'.
(test-ol/escape): Rename to `test-org-link/escape'.
(test-ol/unescape): Rename to `test-org-link/unescape'.
(test-ol/make-string): Rename to `test-org-link/make-string'.
(test-ol/store-link): Rename to `test-org-link/store-link'.
(test-ol/update-radio-target-regexp): Rename to
`test-org-link/update-radio-target-regexp'.
(test-ol/next-link): Rename to `test-org-link/next-link'.
(test-ol/previous-link): Rename to `test-org-link/previous-link'.
(test-ol/plain-link-re): Rename to `test-org-link/plain-link-re'.

Only `test-ol/org-toggle-link-display' was executed during
"make test" since it is the only name matched by the "org|ob" default
selector.  Reported in: Ihor Radchenko to emacs-orgmode.
Re [PATCH v7] ol.el: add description format parameter
to org-link-parameters.  Sun, 24 Jul 2022 21:15:31 +0800.
https://list.orgmode.org/87v8rmd53g.fsf@localhost/
2022-07-29 21:02:23 +08:00
Ihor Radchenko d8133e80d8
Merge branch 'bugfix' 2022-07-24 20:29:20 +08:00
Ihor Radchenko afe50b7132
Fix Emacs 26 compatibility
* lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'.
* lisp/ox-ascii.el (org-ascii--describe-links):
* lisp/ox-md.el (org-md--headline-referred-p): Do not use
`ignore-error'.
* testing/org-test.el (org-test-at-time): Fallback to older definition
of `decode-time' when it cannot accept 3 arguments.
2022-07-24 20:11:03 +08:00
TEC db6c229786
testing/lisp: Update to handle new download policy
* testing/lisp/test-ox.el: Bind `org-resource-download-policy' to t when
testing downloading.

* testing/lisp/test-org.el: Bind `org-resource-download-policy' to t
when testing downloading.
2022-07-20 23:37:26 +08:00
Max Nikulin e08ce5b27d
test-org.el: Add some tests for `org-test-with-timezone'
* testing/lisp/test-org.el (test-org/org-time-string-to-time):
Check that no daylight saving time value is forced for
`org-parse-time-string' and `org-encode-time' calls.
2022-07-17 16:40:19 +08:00
Max Nikulin ae1db7df39
Use `org-encode-time' helper macro
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, agenda-bulk-action):
* lisp/org-capture.el (org-capture-fill-template):
* lisp/org-clock.el (org-clock-get-sum-start)
(org-clock-special-range, org-clocktable-shift)
(org-clocktable-steps):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-datetree.el (org-datetree-find-iso-week-create)
(org-datetree-insert-line):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-matcher-time):
* lisp/org.el (org-current-time, org-current-effective-time)
(org-add-planning-info, org-read-date, org-read-date-display)
(org-read-date-analyze, org-eval-in-calendar)
(org-calendar-select, org-display-custom-time)
(org-calendar-select-mouse, org-time-string-to-time)
(org-time-from-absolute, org-at-clock-log-p)
(org-date-from-calendar, org-get-cursor-date)
(org-timestamp-to-time):
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
* lisp/ox-icalendar.el (org-icalendar-convert-timestamp):
Avoid direct calls of `encode-time', use `org-encode-time' instead.

Org supports Emacs-26, but the recommended way to call `encode-time'
changed in Emacs-27.  In Emacs-29 DST and TZ elements of the single list
arguments became optional.  In Org it is still convenient to call the
function with separate arguments without explicit DST and TZ arguments.
The `org-encode-time' should mitigate attempts to modernize Org code
directly in the Emacs repository.
2022-07-17 16:40:18 +08:00
Max Nikulin 8908a1bda1
org-macs.el: Introduce a helper for `encode-time'
* lisp/org-macs.el (org-encode-time): New compatibility and convenience
helper macro to allow a list for time components or separate arguments
independently of Emacs version.
* testing/lisp/test-org.el (org-test-with-timezone): New macro to ensure
that some code is executed with certain TZ environment value and thus
particular daylight saving time or other time shift rules are active.
* testing/lisp/test-org.el (test-org/org-encode-time): Tests for various
ways to call `org-encode-time'.

Ensure recommended way to call `encode-time' for Emacs-27 and newer with
hope to avoid bugs due to attempts to modernize the code similar to
bug#54731.  6-elements list may be allowed as `encode-time' argument
since Emacs-29, see bug#54764.
2022-07-17 16:38:53 +08:00
Max Nikulin f3802b017c
testing/lisp: Use `org-time-string-to-time'
* testing/lisp/test-org.el (test-org/org-read-date, test-org/deadline)
(test-org/schedule, test-org/time-stamp, test-org/timestamp-from-time):
* testing/org-test.el (org-test-at-time): Use `org-time-string-to-time'
instead of composition of `org-parse-time-string' and `encode-time'.

The actual goal is to prepare to replace `encode-time' by
`org-encode-time' compatibility and convenience macro.
2022-07-17 16:38:52 +08:00
Max Nikulin a189697681
Fix tests for `org-parse-time-string' and `org-clock'
* testing/lisp/test-org.el (ert-deftest test-org/org-parse-time-string):
Update test expectations to use DST of -1 (guess) after fix of
`org-parse-time-string'.
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
Do not change timezone from nil to 0.  Prevent test failures in zones
other than UTC.
2022-07-17 16:38:51 +08:00
Ihor Radchenko f29ccf3161
test-org-fold: Cover the issue fixed by previous commit
*
testing/lisp/test-org-fold.el (test-org-fold/org-fold-reveal-broken-structure):
Test `org-delete-char' instead of `delete-char'.  The former is the
function used interactively.
2022-07-12 21:30:58 +08:00
Ihor Radchenko 654005394b
org-list-struct-apply-struct: Do not rely on `match-data' after edits
* lisp/org-list.el (org-list-struct-apply-struct): Refresh
`org-list-full-item-re' match data if we edit the bullet.  Fixes
https://orgmode.org/list/62cbc0f3.1c69fb81.13d5e.e250SMTPIN_ADDED_BROKEN@mx.google.com
* testing/lisp/test-org-list.el (test-org-list/indent-item): Add test
checking for the reported bug.
2022-07-11 19:13:07 +08:00
Sébastien Miquel 4e42500613 org.el: Fix the filling of regions containing lists
* lisp/org.el (org-setup-filling): Set fill-forward-paragraph-function.
(org--single-lines-list-is-paragraph): New internal variable.  Whether
a list with single lines items should be considered a single
paragraph.
(org--paragraph-at-point): use org--single-lines-list-is-paragraph.
(org-fill-paragraph): When an active region contains a list ensure
every item get filled.
* testing/lisp/test-org.el (test-org/fill-paragraph):
(test-org/fill-region): Test behaviour of fill-paragraph and
fill-region with an active region containing a list.

When filling paragraphs in a region, do not treat a list with single
lines items as a single paragraph.
2022-07-04 12:43:09 +02:00
Stefan Kangas 41e19f1d7a
; Fix typos 2022-07-01 17:42:52 +08:00
Allen Li 711ada5acd
test-org: Add test for org-todo prefix behavior
* testing/lisp/test-org.el (test-org/org-todo-prefix): Add test.
2022-06-26 14:29:48 +08:00
Ihor Radchenko 707d3a093b
org-cycle-list-bullet: Preserve relative point position
* lisp/org-list.el (org-cycle-list-bullet): Keep point position
relative to bullet beginning/end when changing the list bullet.

* testing/lisp/test-org-list.el (test-org-list/cycle-bullet): Add
tests.

Fixes https://orgmode.org/list/m2wndjfi32.fsf@gmail.com
2022-06-16 20:08:49 +08:00
Ihor Radchenko 3bbbf77f36
org-babel-exp-process-buffer: Improve performance
* lisp/ob-exp.el (org-babel-exp-src-block): New optional argument
providing ELEMENT at point.
(org-babel-exp-code-template): Use lower-case #+begin/#+end lines to
avoid triggering source code block changes when the blocks are
exported with :exports code and also contain lower-case
 #+begin/#+end.  We prefer lower-case default because other parts of
 Org, like `org-insert-structure-template' default to lower-case as
 well.
(org-babel-exp-process-buffer): Do no disable cache as changes are not
expected to be as frequent anymore.  Pass pre-calculated element at
point to inner function calls to `org-in-commented-heading-p',
`org-in-archived-heading-p', `org-element-context', and
`org-babel-exp-src-block'.  Do not force-replace source block contents
when no change is required.
* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
(ob-export/body-with-coderef):
(ob-exp/src-block-with-affiliated-keyword): Update tests according to
the new `org-babel-exp-code-template'.
2022-06-16 13:21:39 +08:00
Ryan Scott 226119124d
ob-core.el/babel: Special handling for attachment links in src block
* ob-core.el (org-babel-merge-params): Specifying the symbol 'attach`
or string "'attach" as the value of the `:dir' header now functions as
":dir (org-attach-dir nil t) :mkdirp t".
(org-babel-result-to-file): Optional TYPE argument accepts symbol
'attachment to fixup up paths under `(org-attach-dir)' and use the
link type "attachment:" when that is detected.
(org-babel-insert-result): Pass symbol `attachment' as TYPE to
`org-babel-result-to-file'.
* org-attach.el (org-attach-dir): Added autoload header to simplify
dependencies necessary to support this feature (called in
`org-babel-merge-params').
* test-ob.el (test-ob-core/dir-attach): Added unit test for the new
attach feature.
2022-06-14 21:44:25 +08:00
Ihor Radchenko ed6f8dc67f
org-list: Do not move point and change space when promoting/demoting items
* lisp/org-list.el (org-list-struct-apply-struct): Make sure the
origin marker is not moved to bol when promoting/demoting item in
special case:
 - item
 - <point> ::
Do not remove the trailing space after point as well.
(org-insert-item): Do not expect point to remain at bol after writing
list struct.

* testing/lisp/test-org-list.el (test-org-list/indent-item): Add tests.

Fixes https://orgmode.org/list/87o88hlkvv.fsf@gmail.com
2022-06-11 20:17:29 +08:00
Rudolf Adamkovič d9963c58dc
lisp/ol.el: Fix shadowed radio targets
* lisp/ol.el (org-update-radio-target-regexp): Sort radio targets
before building the regexp that matches them.
* testing/lisp/test-org.el: Test shadowed radio targets.  The bug
occurs when two targets share the same prefix and when and the longer
target appears first.
2022-06-09 16:22:44 +08:00
Tyler Grinn e268e47971
lisp/org.el: Add org-property-separators option
* lisp/org.el (org-property-separators, org-property-get-separator):
Created.
(org-entry-get, org-entry-get-with-inheritance): Use new
`org-property-get-separator' function.

* testing/lisp/test-org.el (test-org/entry-get): Added tests for
combining properties with custom separators

`org-property-separators' is a customization option that allows for
properties to be combined using a separator other than the default (a
single space).  It is an alist with the car of each element being a
list of property names or regular expression and the cdr being the
separator string, like '((("EXPORT_FILE_NAME") . "/")).
2022-05-20 15:56:11 +08:00
Ihor Radchenko cdbb1c9633
org--deadline-or-schedule: Allow warning period in TIME argument
* lisp/org.el (org--deadline-or-schedule): Match warning period if
provided in TIME arg.
* testing/lisp/test-org.el (test-org/deadline): Add relevant tests.

Fixes https://orgmode.org/list/87o85bl582.fsf@localhost
2022-05-15 14:49:10 +08:00
Ihor Radchenko e5e7ae36cf
org-element--current-element: Fix #+BEGIN$ parsed as special block
* lisp/org-element.el (org-element--current-element): Use
`org-element-dynamic-block-open-re' to match blocks.

* testing/lisp/test-org-element.el (test-org-element/paragraph-parser):
Fix test relying on previous incorrect behaviour.  Empty #+BEGIN:
should be parsed as a keyword.

Reported in https://list.orgmode.org/Ycay4s3iAdEGSwgt@tuxteam.de/T/#t
2022-05-14 13:51:56 +08:00
TEC b4e4b3c502
ox-latex: Replace `org-latex-listings'
* lisp/ox-latex.el (org-latex-src-block, org-latex-keyword,
org-latex-inline-src-block, org-latex-template,
org-latex--caption/label-string, org-latex-engraved-preamble,
org-latex-listings): Replace `org-latex-listings' with
`org-latex-src-block-backend', which now can be set to listings/verbatim
and no longer advertises t/nil as valid values.

* lisp/ox-beamer.el (org-beamer-template): Update in the same manner as
`org-latex-template'.

* lisp/org-compat.el: Make `org-latex-listings' an obsolete alias for
`org-latex-src-block-backend'.

* testing/lisp/test-ox.el: Replace `org-latex-listings' reference with
`org-latex-src-block-backend'.

* doc/org-manual.org (Footnotes, LaTeX specific properties, Literal
Examples): Replace references to `org-latex-listings' with
`org-latex-src-block-backend'.

* etc/ORG-NEWS: Add a news entry noting this change.

The variable `org-latex-listings' originally indicated whether source
blocks should use the listings LaTeX package, or not.  This usage has
evolved over the years, and now it sets one of four different
fontification backends.  This renaming should make the variable name a
bit less misleading.
2022-05-13 00:43:17 +08:00
Ihor Radchenko 2a6f5cecf7
test-org: Add new test `test-org/org-find-olp'
* testing/lisp/test-org.el (test-org/org-find-olp): New test examining
`org-find-olp'.
2022-05-08 18:22:01 +08:00
Ihor Radchenko 2e4ed52b19
org-fold: Revert old behaviour when handling invisible edits
* lisp/org-fold-core.el (org-fold-core-folded-p): Allow list of fold
types to be passed as argument.
* lisp/org-fold.el (org-fold-check-before-invisible-edit--overlays):
(org-fold-check-before-invisible-edit--text-properties): Make
overlay/text-property behaviour consistent.  Do not handle edits
inside folded links.  Fix inconsistencies.
* testing/lisp/test-org-fold.el:
* testing/lisp/test-org.el: Move folding-related tests to new test
file.
* testing/lisp/test-org-fold.el:
(test-org-fold/org-catch-invisible-edits): New test.

See https://orgmode.org/list/m2o809q170.fsf@gmail.com
2022-05-08 17:26:42 +08:00
Andrew Arensburger 4a30e8cc0c
test-org-macs.el: Add test for template-expansion bug
* testing/lisp/test-org-macs.el (ert-deftest test-org/fill-template):
There is a bug in `org-fill-template': it sorts and processes keys in
order of increasing length, so that "noweb" is seen before
"noweb-ref", and "tangle" before "tangle-mode".  So in a template that
includes "%noweb-ref", it will substitute the value of "noweb".

This change includes a test for this bug.

TINYCHANGE
2022-04-30 17:45:32 +08:00
Nick Dokos 98a771cc3b
test-ob-octave: Add missing `provide' 2022-04-27 16:56:31 +08:00
Ihor Radchenko d2775da08d
test-ol/org-toggle-link-display: Fix compatibility with old Emacs
* testing/lisp/test-ol.el (test-ol/org-toggle-link-display): Use
back-compatible `org-xor' instead of `xor'.
2022-04-25 19:40:12 +08:00
Ihor Radchenko 444d1c50ac
test-org/string-width: Add tests for strings with prefix properties 2022-04-25 19:40:10 +08:00
Ihor Radchenko 6d4e65a124
Add org-fold-related tests 2022-04-25 19:40:01 +08:00
Ihor Radchenko f63ff07441
Fix subtle differences between overlays and invisible text properties
* lisp/org-clock.el (org-clock-in):
(org-clock-find-position):
(org-clock-out):
* lisp/org.el (org-add-planning-info):
(org-scan-tags):
(org-global-tags-completion-table):
(org-make-tags-matcher):
(org-tags-expand):
(org--property-local-values):
(org-read-date-analyze):
(org-revert-all-org-buffers):
(org-beginning-of-line): Make sure that we inherit invisible state
when inserting text.
(org-sort-entries): Preserve invisible state after replace-match.

(org-log-beginning): Do not try to move by visible lines.

* lisp/org-macs.el (org-preserve-local-variables): Do not try to
preserve overlays.
* lisp/ox.el (org-export--generate-copy-script): Preserve folding
properties in export buffer.
* testing/lisp/test-ob.el (test-ob/preserve-results-indentation): Fix
test failure.
* testing/lisp/test-org.el (test-org/meta-return):
(test-org/custom-properties): Use new folding.
2022-04-25 19:39:56 +08:00
Ihor Radchenko fa7530c7b4
Rename old function call to use org-fold 2022-04-25 19:39:53 +08:00
Ihor Radchenko 6304afcaa4
Merge branch 'bugfix' 2022-03-26 15:20:22 +08:00
Ihor Radchenko b1a570b3b4
org-agenda: Fix regression when diary sexp timestamps are ignored
* lisp/org.el (org-at-timestamp-p): Return non-nil on sexp timestamps
when called with 'agenda argument.
* testing/examples/agenda-file.org (test sexp timestamp inside properties):
* testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp):
Add new test checking sexp timestamp inside properties drawer.
2022-03-26 15:17:45 +08:00
Ihor Radchenko 735f666fad
test-org-agenda: Fix failing test and warn about using today's agenda
* testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp):
Fix test that failed because of different behavior of agenda view
depending whether the view is called today (according to system date)
or not.  Today's agenda (even called with custom date argument)
display the past scheduled items, while it is not the case for
non-today agendas.
* testing/lisp/test-org-agenda.el (test-org-agenda/one-line):
(test-org-agenda/scheduled-non-todo):
(test-org-agenda/non-scheduled-re-matces):
(test-org-agenda/property-timestamp):
(test-org-agenda/diary-inclusion):
(test-org-agenda/set-priority):
Add a note to warn future test developers about potential surprising
agenda behaviour.
2022-03-26 15:17:45 +08:00
Ihor Radchenko c9c0b9d004
Merge branch 'bugfix' 2022-03-22 17:40:49 +08:00
Ihor Radchenko d9bf64f064
org-agenda: Match timestamps inside node properties
* lisp/org-agenda.el (org-agenda-get-timestamps): Use
`org-at-timestamp-p' instead of org-element to check if at valid
timestamp.  Agenda should consider timestamps inside node properties
even though they are not parsed by org-element.

* testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp):
Add new test checking active timestamp inside property drawer.

* testing/examples/agenda-file.org (test timestamp inside properties):
Add heading for `test-org-agenda/property-timestamp'.

Reported in https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com
2022-03-22 17:37:47 +08:00
Nicolas Goaziou ef66660cf4 Merge branch 'bugfix' 2022-02-28 15:46:06 +01:00
Nicolas Goaziou bafeaf161c element: Fix parsing of inline footnotes
* lisp/org-element.el (org-element--pair-round-table):
(org-element--pair-square-table):
(org-element--pair-curly-table): De-activate all but one pair of
parenthesis.
* testing/lisp/test-org-element.el (test-org-element/footnote-reference-parser):
Add test.

Reported-by: Greg Minshall <minshall@umich.edu>
<http://lists.gnu.org/r/emacs-orgmode/2022-02/msg00369.html>
2022-02-28 15:45:25 +01:00
Kyle Meyer e822291aca Merge branch 'bugfix' 2022-02-27 23:45:32 -05:00
Kyle Meyer 57362f7414 org-copy-visible: Respect buffer-invisibility-spec
* lisp/org.el (org-copy-visible): Decide whether text is invisible by
calling invisible-p rather than checking whether the invisible
property at point is non-nil.

Text may have a non-nil invisible property but _not_ be hidden from
the user (and thus should be copied by org-copy-visible).  For
example, the link itself is shown when org-link-descriptive is nil,
but it still has an invisible property of `org-link'.
2022-02-27 23:43:59 -05:00
Kyle Meyer f2833ff255 org-copy-visible: Fix handling of adjacent invisible text
* lisp/org.el (org-copy-visible): Don't copy invisible text that
follows invisible text with a different property value.

If org-copy-visible sees that the left bound position has a non-nil
invisible property, it uses next-single-char-property-change to find
the new bound.  However, next-single-char-property-change may just
find a bound that still has a _different_ non-nil invisible property.

Reported-by: "Максим Бабушкин" <maxbabushkin@gmail.com>
Link: https://debbugs.gnu.org/49967
2022-02-27 23:43:59 -05:00
Kyle Meyer e85a872f3b test-org.el: Actually test org-copy-visible
* testing/lisp/test-org.el (test-org/copy-visible): Switch defun to
ert-deftest so that the test is actually executed, and resolve
failures in test.

Make two adjustments so that the now executed test passes:

  - Correct the end value of the hidden part of the string for one
    test case.

  - Disable org-unfontify-region so that the invisible properties show
    up in the temporary buffer.

    I think org-unfontify-region should probably be changed to _not_
    remove the invisible property, but it's a longstanding behavior.
    Changing it would need more thought and isn't something that
    should be done on the bugfix branch.
2022-02-27 23:41:44 -05:00
Nicolas Goaziou 6ac5e0adc8 Merge branch 'bugfix' 2022-02-13 22:14:55 +01:00
Nicolas Goaziou 17e4fe9093 lint: Fix false positive with inline footnote definitions
* lisp/org-lint.el (org-lint-invalid-macro-argument-and-template):
Take into consideration inline definitions.
* testing/lisp/test-org-lint.el (test-org-lint/undefined-footnote-reference):
Add test.

Reported-by: Timothy <tecosaur@gmail.com>
2022-02-13 22:13:41 +01:00
Ihor Radchenko a694cf5224
Merge branch 'bugfix' 2022-02-07 21:08:54 +08:00
Sacha Chua c5ceb6a2c3
org-list-send-item: allow dest to be a buffer position
* lisp/org-list.el (org-list-send-item): Check if dest is a string
before matching it, to allow dest to be a buffer position.
* testing/lisp/test-org-list.el (test-org-list/send-item): Add tests.
2022-02-07 21:07:52 +08:00
Ihor Radchenko 26decec006
test-org-element-at-point: Add tests for point outside contents 2022-01-24 22:54:18 +08:00
Ihor Radchenko 846226a202
test-org-element/cache: Fix typo 2022-01-21 20:53:11 +08:00
Ihor Radchenko 9b58ead467
org-element-context: Use element cache
* lisp/org-element.el (org-element-context): Use
`org-element-at-point', which makes use of cache.
* testing/lisp/test-org-element.el (test-org-element/lineage): Expect
full lineage up to org-data from `org-element-context'.
2022-01-17 20:20:57 +08:00
Ihor Radchenko 8d9ca0eac1
test-org/entry-get: Add test checking reported bug
See https://list.orgmode.org/orgmode/87zgrqqlcs.fsf@toloe.se/
2022-01-15 19:48:24 +08:00
Ihor Radchenko a9b2e262cd
Merge branch 'bugfix' 2022-01-12 21:11:33 +08:00
Ihor Radchenko 65f9524136
test-org-agenda: Test for scheduled-looking lines
* testing/examples/agenda-file.org: Add test headings where SCHEDULED
line is not planning.
*
testing/lisp/test-org-agenda.el (test-org-agenda/non-scheduled-re-matces):
Make sure that SCHEDULED lines that do no belong to planning do not
trigger agenda matches.

See https://list.orgmode.org/20220101200103.GB29829@itccanarias.org/T/#t
2022-01-12 21:08:55 +08:00
Ihor Radchenko dc4b2772e3
org-element-cache-map: Fix an edge case with org-element-cache-continue-from
* lisp/org-element.el (org-element-cache-map): Make sure that START is
never set to -1.  It may cause infinite loops in some scenarios.
* testing/lisp/test-org.el (test-org/map-entries): Add a test catching
the reported situation.

Reported in https://list.orgmode.org/CADywB5JHAyPX99Vr02SvAqiMTD+7ss4VWVipOhKfm=iGirDPhA@mail.gmail.com/T/#t
2022-01-07 22:10:22 +08:00
Ihor Radchenko 515ce56d4e
org-element-cache: Fix transforming keywords to affiliated
* lisp/org-element.el (org-element--cache-for-removal): Consider
preceding keywords to be updated unconditionally.
(org-element-cache-map): Fix infinite loop revealed by the new test.

* testing/lisp/test-org-element.el (test-org-element/cache-affiliated):
New test.
2022-01-07 21:24:43 +08:00
Kyle Meyer aae2ac3a68 Merge branch 'bugfix' 2022-01-01 15:21:37 -05:00
Kyle Meyer 5a229cbc44 Update copyright year to 2022 2022-01-01 15:17:08 -05:00
Ihor Radchenko 06f58e4759
org-element-cache-map: Fix when FUNC deletes current element
* lisp/org-element.el (org-element-cache-map-continue-from): New
variable forcing `org-element-cache-map' to continue from a custom
point in buffer.
(org-element-cache-map): Add support for
`org-element-cache-map-continue-from'.  Update docstring accordingly.
Also, make sure that mapping terminates correctly when FUNC deletes
all elements in buffer.
* testing/lisp/test-org.el (test-org/map-entries): Add test.

Fixes https://orgmode.org/list/CADywB5KOJ1p0NpvA=iX-ybHsO=huGA8qL3xMpUTETmS2qp7_ng@mail.gmail.com
2022-01-01 14:13:26 +08:00
Ihor Radchenko e2a8e95576
org-element-cache: Fix when edit extends previous element
* lisp/org-element.el (org-element--cache-after-change): Always extend
changed region to bol.
* testing/lisp/test-org-element.el (test-org-element/cache): Add test
checking the new fix.  Amend some tests around making sure that cache
is active during testing.
2021-12-17 20:23:50 +08:00
Ihor Radchenko d267486002
org-element-cache: Fix some edits right after indent at :begin
* lisp/org-element.el (org-element--cache-after-change): Extend
changed region to bol when we are editing near beginning of an element
within or right after indentation.  Such edits potentially change
:post-blank value of the previous element.
* testing/lisp/test-org-element.el (test-org-element/cache): Add test
checking one of such cases.
2021-12-16 21:39:25 +08:00
Ihor Radchenko f0c474e659
test-org-element: Add new tests for org-element-cache
* testing/lisp/test-org-element.el (test-org-element/cache): Add tests
for edits near :end of an element.
2021-12-16 12:03:18 +08:00
Ihor Radchenko 4bad221a60
test-org-element: Add new tests
* testing/lisp/test-org-element.el (test-org-element/cache): Add new
tests checking against intersected elements and checking that Phase 2
removes obsolete elements.
2021-12-16 11:53:01 +08:00
Ihor Radchenko 003968f94e
test-org-element: Rename cache-bugs test to cache-table
* testing/lisp/test-org-element.el (test-org-element/cache): The bug
has been fixed.  Old test name does not make sense anymore.
2021-12-16 11:52:22 +08:00
Nicolas Goaziou 7e2d9091d0 oc: Allow declaring cite styles as a function
* lisp/oc.el (org-cite-register-processor): Allow a function
as :cite-styles value.
(org-cite-supported-styles): Propagate change above.
* testing/lisp/test-oc.el (test-org-cite/supported-styles): Add test.
2021-12-12 15:42:29 +01:00
Nicolas Goaziou b4acde37ba lint: Allow user-defined checkers during linting
* lisp/org-lint.el (org-lint-add-checker): New function.
(org-lint--generate-reports): Checker function now must be specified.
It is not deduced anymore from the name of the checker.
* testing/lisp/test-org-lint.el (test-org-lint/add-checker): New test.
2021-12-01 16:09:13 +01:00
Nicolas Goaziou 6766c45bfd org-lint: Add checkers for citations and related
* lisp/org-lint.el (org-lint--checkers): Register new checkers.
(org-lint-non-existent-bibliography):
(org-lint-missing-print-bibliography):
(org-lint-invalid-cite-export-declaration):
(org-lint-incomplete-citation): New functions.
* testing/lisp/test-org-lint.el (test-org-lint/non-existent-bibliography):
(test-org-lint/missing-print-bibliography):
(test-org-lint/invalid-cite-export-declaration):
(test-org-lint/incomplete-citation): New tests.
2021-11-30 22:21:46 +01:00
Nicolas Goaziou 5d2e2cd1bc oc: Factor out string to cite export processor triplet conversion
* lisp/oc.el (org-cite-read-processor-declaration): New function.
(org-cite-store-export-processor): Use new function.
* testing/lisp/test-oc.el (test-org-cite/read-processor-declaration):
New test.
2021-11-30 22:21:46 +01:00
Kyle Meyer 6e7c54ed94 Merge branch 'bugfix' 2021-11-27 16:17:16 -05:00
Kyle Meyer 96d91bea65 test-org-attach-git: Fix recent failure to load tests
* testing/lisp/test-org-attach-git.el: Provide feature.

As of 9044b300e (org-test: Fix ERC errors using latest Emacs master,
2021-11-24), tests must provide a feature.
2021-11-27 16:16:51 -05:00
Kyle Meyer b9cf130c91 test-org-attach-git: Fix file name in header and footer
* testing/lisp/test-org-attach-git.el: Update file name in the header
and footer to match the actual file name.
2021-11-27 16:16:48 -05:00
Nicolas Goaziou 25640ace0f Merge branch 'bugfix' 2021-11-26 11:44:30 +01:00
Nicolas Goaziou 413afbe210 test-org: Fix failing test in non-English languages
* testing/lisp/test-org.el (test-org/auto-repeat-maybe): Do not assume
abbreviated day name is in English.
2021-11-26 11:43:20 +01:00
Ihor Radchenko 23138b9b11
Merge branch 'bugfix' 2021-11-24 20:10:03 +08:00
Ihor Radchenko 9044b300ee
org-test: Fix ERC errors using latest Emacs master
* testing/lisp/test-ob-C.el:
* testing/lisp/test-ob-awk.el:
* testing/lisp/test-ob-sed.el: Add missing provide.
* testing/lisp/test-property-inheritance.el: Fix incorrect feature
name.
* testing/org-test.el (org-test-load): Use `require' instead of
`load-file' to load tests.  `load-file' can lead to duplicate test
definitions that now trigger ERC errors.

See https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-11/msg01968.html
2021-11-24 20:06:15 +08:00
Ihor Radchenko 0d7cf4e402
test-ob.el: Remove duplicate test 2021-11-24 20:06:07 +08:00
Ihor Radchenko 7a14d6035c
Fix element property queries for inlinetasks
* lisp/org.el (org-get-tags): Do not ignore local tags in inlinetasks.
(org-in-commented-heading-p): Do not ignore commented inlinetasks.
* testing/lisp/test-org.el (test-org/get-tags): Add tests for
inlinetasks.

Fixes https://list.orgmode.org/CAKJdtO8-KkVvhcviTqhi+DMZmSK=o37jn1jJPM9qxcuXZPnGgw@mail.gmail.com/T/#u
2021-11-22 19:34:21 +08:00
Nicolas Goaziou 26e68816bd element: Integrate some syntax constants
* lisp/org-element.el (org-element-archive-tag):
(org-element-clock-line-re):
(org-element-comment-string):
(org-element-closed-keyword):
(org-element-deadline-keyword):
(org-element-scheduled-keyword):
(org-element-planning-keywords-re):
(org-element-planning-line-re):
(org-element-drawer-re):
(org-element-dynamic-block-open-re):
(org-element-headline-re): New constants.
(org-element-drawer-parser):
(org-element-dynamic-block-parser):
(org-element--footnote-separator):
(org-element--get-node-properties):
(org-element--get-time-properties):
(org-element-headline-parser):
(org-element-headline-interpreter):
(org-element-inlinetask-parser):
(org-element--list-struct):
(org-element-paragraph-parser):
(org-element-planning-parser):
(org-element-planning-interpreter):
(org-element--current-element):
(org-element--cache-for-removal):
(org-element-cache-map):
(org-element-context): Use new constants so as to not use org.el's.
* testing/lisp/test-org-element.el (test-org-element/headline-comment-keyword):
(test-org-element/headline-archive-tag):
* testing/lisp/test-ox.el (test-org-export/handle-options): Fix tests.
2021-11-20 11:37:52 +01:00
Kyle Meyer dbd192bbc6 Merge branch 'bugfix' 2021-11-06 17:11:40 -04:00
Kyle Meyer ada13f916c test-oc: Fix incorrect expectation
* testing/lisp/test-oc.el (test-org-cite/main-affixes): Fix spacing in
an expected string.

Link: https://list.orgmode.org/878ry1ovz8.fsf@nicolasgoaziou.fr
2021-11-06 17:10:18 -04:00
Kyle Meyer 77e2ecd71f test-oc: Add missing space to test docstring 2021-11-06 13:21:52 -04:00
Nicolas Goaziou 498a76857b Merge branch 'bugfix' 2021-11-03 16:29:59 +01:00
Nicolas Goaziou ad40282860 oc: Refactor affixes extraction
* lisp/oc.el (org-cite-main-affixes): New function.
* lisp/oc-natbib.el (org-cite-natbib--build-optional-arguments): Use
new function.
* testing/lisp/test-oc.el (test-org-cite/main-affixes): New test.
2021-11-03 16:27:53 +01:00
Ihor Radchenko 5f4fd0880a
org--get-expected-indentation: Consider section parent type
* lisp/org.el (org--get-expected-indentation): Consider new :parent
structure when `org-element-at-point' returns parent section and
headline elements.

* testing/lisp/test-org.el (test-org/indent-region): Add test.

Fixes https://list.orgmode.org/87pmrupu0s.fsf@gmail.com/T/#t
2021-10-24 19:46:00 +08:00
Nicolas Goaziou d2f4d4b457 Merge branch 'bugfix' 2021-10-23 14:33:18 +02:00
Nicolas Goaziou 52e6f1cf57 macro: Properly collect multiple authors
* lisp/org-macro.el (org-macro--collect-macros): Multiple lines are
allowed for AUTHOR keyword (per `org-export-options-alist') so make
sure we collect all of them.
* testing/lisp/test-org-macro.el (test-org-macro/author): Add test.

Reported-by: Vinicius Vinicius <vinicius.vin@yandex.com>
<http://lists.gnu.org/r/emacs-orgmode/2021-10/msg00727.html>
2021-10-23 14:32:00 +02:00
Nicolas Goaziou d3143feaf7 Fix sloppiness when collecting keywords
* lisp/org.el (org--collect-keywords-1): Use an accurate
function instead of an approximation. Accuracy trumps speed when parsing.
* testing/lisp/test-org.el (test-org/collect-keywords): New test.
2021-10-23 11:18:10 +02:00
Ihor Radchenko 004ac14a5b
Fix compatibility with Emacs 26
* lisp/org-compat.el (org-file-name-concat): Do not use
`string-empty-p'.
(combine-change-calls): Create a stub when `combine-change-calls' were
not yet available.
(org-replace-buffer-contents): Add compatibility function for
`replace-buffer-contents'.

* lisp/org-element.el (org-element--current-element): Do not use
`if-let'.
* lisp/org-persist.el (org-persist-gc): Do not use `when-let'.
* lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'.
* lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use
`org-replace-buffer-contents'.

* lisp/org.el (org-narrow-to-subtree, org--property-local-values,
org-entry-get-with-inheritance, org-in-commented-heading-p,
org-up-heading-safe, org-goto-first-child): Do not use
`if-let'/`when-let'.

* testing/org-test.el (org-test-at-time): Fallback to old
`decode-time' specification in older Emacs.
2021-10-17 14:34:10 +08:00
Ihor Radchenko 885808fd58
Fix incorrectly written test
* testing/lisp/test-org.el (test-org/entry-get): The test was passing
in the past because of bug in org.el.
2021-10-17 00:00:21 +08:00
Ihor Radchenko e70a8aac59
Use org-element-cache in place of text property cache in agenda
* lisp/org-agenda.el (org-agenda-skip): Use
`org-in-archived-heading-p' and `org-in-commented-heading-p' in place
of text property cache.

(org-agenda-get-todos, org-agenda-get-timestamps,
org-agenda-get-sexps, org-agenda-get-progress,
org-agenda-get-deadlines, org-agenda-get-scheduled,
org-agenda-get-blocks): Do not use text property cache in favour of
Org API functions.  The API functions use cache now.

* lisp/org-clock.el (org-element--cache-active-p): Declare function to
suppress compiler warning.

(org-clock-in): Do not use text property cache when element cache is
active.

* lisp/org-duration.el (org-duration-to-minutes): Do not change match
data.  It is needed to not break agenda---agenda relies on match data
not being altered.

* lisp/org.el (org-run-like-in-org-mode): Use element cache.
(org-refresh-category-properties): Use element cache.
(org-make-tags-matcher, org-agenda-prepare-buffers): Do not rely on
text property cache.

* testing/lisp/test-org.el (test-org/refresh-category-properties): Do
not use text property cache.
2021-10-16 23:50:21 +08:00
Ihor Radchenko 60c927f8b8
Add new element parser and cache tests 2021-10-16 23:42:30 +08:00
Ihor Radchenko fc80d052db
Re-implement org-element-cache and add headline support
* lisp/org-element.el (org-element-with-disabled-cache): New macro.

(org-element-greater-elements): Add new org-data element.  It
functions like a virtual headline containing the whole buffer.  The
org-data properties are like headlie properties, but according to the
top-level drawer.  org-data's category is the buffer's category as
defined by top-level property drawer, #+CATEGORY keyworsd, and the
buffer file name.

(org-element--cache-element-properties, org-element-set-element): New
variable containing properties to be transferred when updating changed
element in cache in `org-element-set-element'.

(org-element--get-node-properties): Allow parsing node propreties in
top-level drawer when new optional argument is passed.  Respect
PROPERTY+ syntax.

(org-element--get-global-node-properties): New function.  It returns
node properties for top-level property drawer.

(org-element-org-data-parser, org-element-org-data-interpreter):
Implement the new org-data element.

(org-element-headline-parser, org-element-section-parser): Add new
:robust-begin and :robust-end
properties delimiting safe changes that do not modify headline
element.

(org-element--list-struct): Fix cache update when adding a headline
inside list.

(org-element--current-element): Implement cache support.  Record
parsing mode (:mode) and parsing granularity (:granularity) in the
element properties.

(org-element-parse-buffer, org-element--next-mode): Support new
org-data element.

(org-element--parse-elements): Record parsing granularity in the
returned tree

(org-element-use-cache): Enable cache by default.

(org-element-cache-persistent): New variable controlling cache
persistance across sessions.  Enabled by default.

(org-element--cache-self-verify,
org-element--cache-self-verify-frequency,
org-element--cache-diagnostics, org-element--cache-map-statistics,
org-element--cache-map-statistics-threshold,
org-element--cache-diagnostics-level,
org-element--cache-diagnostics-ring,
org-element--cache-diagnostics-ring-size): New variables controlling
cache diagnostics and self-diagnostics.  Greatly simplifies cache
debugging.

(org-element--cache, org-element--cache-sync-requests,
org-element--cache-sync-timer): Make cache buffer-local by default.

(org-element--headline-cache): Implement separate cache storing only
headlines and inlinetasks.

(org-element--cache-size, org-element--headline-cache-size): New
variables containing cache sizes.  This is much faster than
`avl-tree-size'.

(org-element--cache-sync-requests): Update docstring explaning the
request list structure.

(org-element--cache-sync-keys-value): New variable replacing
`org-element--cache-sync-keys' hash table.  The hash table was not
reliable because it was using elements as keys.  Upon any cached
element update/shift, the keys were invalidated making cache ordering
incorrect and breaking the cache badly.  Now, the cache keys are
stored as :org-element--cache-sync-key element property and the new
variable stores marker value indicating the current sync request
cycle.  See `org-element--cache-key' for more details.

(org-element--cache-change-tic): New variable controlling buffer
modification count that is registered in cache.  This variable allows
catching "stealth" edits.

(org-element--cache-non-modifying-commands): New variable listing
commands that will not be slown down if we fill cache on the fly.

(org-element--request-key, org-element--request-beg,
org-element--request-end, org-element--request-offset,
org-element--request-parent, org-element--request-phase): New macros.
They improve code readability (especially when using nameless-mode).

(org-element--format-element, org-element--cache-log-message,
org-element--cache-warn): New macros implementing generic logging
functionality.

(org-element--cache-key): Add section and org-data element support.
Change cache key storage from hash map to :org-element--cache-sync-key
element property + `org-element--cache-sync-keys-value'.  We use the
latter to group all the cache keys during a single cache request
sequence.  Once sync request is fully complete, the
`org-element--cache-sync-keys-value' is updated making all the old
sync keys obsolete (they will still be store as element properties).

(org-element--headline-cache-root): New function returning headline
cache root.

(org-element--cache-active-p): Prevent cache updates when
`inhibit-modification-hooks' is non-nil, unless non-nil optional
argument is provided.

(org-element--cache-find): Share cache between indirect buffers and
the base buffer.  We have to do it because after-change hooks for
indirect buffer are not called in the base buffer and vice versa.  Add
support for section and org-data elements.

(org-element--cache-put): Implement new approach for cache key
storage.  Add diagnostics.  Indicate cached elements using :cached
element property.  Support cache size calculation.

(org-element--cache-remove): Invalidate parent contents when removing
element.  Support cache size calculation.  Detect cache corruption due
to misordered elements.

(org-element--cache-shift-positions): Support :robust-begin and
:robust-end element properties.

(org-element--cache-sync): Add diagnostics.  Add detailed comments.
Prevent slowdown when large cache chunks need to be deleted forcing
O(N) complexity cutoff.  In phase 2, fix cases when next request
contains deleted cache key.  In phase 2, fix scenario when newly
inserted element intersects with existing elements in cache.  In phase
2, detect obsolete parents removed from cache.

(org-element--open-end-p): New function checking if an element can
have blank lines right after its :contents-end.

(org-element--parse-to): Do not alter match data.  Process complex
parsing mode changes correctly.  Support headlines in cache.  Support
org-data parsing.  Add detailed comments.  Add diagnostics.

(org-element--cache-sensitive-re): Make list lines sensitive.

(org-element--cache-change-warning): Update docstring.  Now, the
variable can have t, nil, and number values.  Numbers are used to
provide more details about changed headlines.

(org-element--cache-before-change, org-element--cache-after-change):
Handle headline hierarchy.  Properly handle cache in indirect
buffers.

(org-element--cache-after-change): Update docstring clarifying the
return values.  Add special handling for headline and org-data
elements updating them in-place instead of removing together with the
whole contents when possible.  Use :robust-begin/:robust-end element
properties to detect robust changes.

(org-element--cache-submit-request): Add detailed comments.  Correctly
handle cache in indirect buffers.  Delegate element modifications to
`org-element--cache-for-removal'.

(org-element--cache-verify-element): New function for cache
self-verification.

(org-element--cache-persist-before-write,
org-element--cache-persist-before-read,
org-element--cache-persist-after-read): Implement cache persistance.

(org-element-cache-reset): Correctly handle cache in indirect
buffers.  Support cache persistance.  Support new cache size
calculation and new cache key schema.

(org-element-cache-map): New function analagous to `org-element-map',
but much faster.  The function overperforms org-ql written by Adam
Porter aka alphapapa [1] and reuses some ideas from there (namely,
fast element skipping via regexps).

[1] https://github.com/alphapapa/org-ql/

(org-element-at-point): The returned elements are now guaranteed to
have correct parents up to org-data.  New optional argument
CACHED-ONLY limits element search to current cache---if element is not
in cache and current command is not in cache
`org-element--cache-non-modifying-commands', the cache is not updated
and the function returns nil.  Also, support cache verification.

(org-element-at-point-no-context): New function.  It is analogous of
older `org-element-at-point' with no guarantee that :parent properties
are correct beyond direct parent heading.  This function does not
update cache and can be useful when cache updates should be avoided
for performance reasons.

* lisp/ob-core.el (org-babel-where-is-src-block-result): Support
section and org-data elements in cache.

* lisp/org-macro.el (org-macro-replace-all,
org-macro--find-keyword-value): Support org-element-cache.

* lisp/org-table.el (orgtbl-to-generic): Support org-element-cache.

* lisp/org.el (org-mode): Add cache persistance.

(org-up-element): Preserve old behaviour when error is returned for
section and org-data element.

*
testing/lisp/test-org-archive.el (test-org-archive/update-status-cookie):
Fix test when cache is active.

* testing/lisp/test-org-colview.el (test-org-colview/columns-update):
Fix test.

* testing/lisp/test-org-element.el (test-org-element/extract-element):
Add suport for new org-data element.

* testing/lisp/test-org-element.el (test-org-element/parent-property):
Fix equality check.  Parents returned by cache and `org-element-map'
may not be `eq' now.  Just `equal'.

* testing/lisp/test-org-element.el (test-org-element/context): Support
section and headline parents.
2021-10-16 23:22:18 +08:00
Marco Wahl d0b55739c0 org: Fix: Respect TAB in property drawer as separator
* lisp/org.el (org-property-drawer-re): Allow TAB as first
character after the property name's colon.
2021-10-11 14:08:01 +02:00
Nicolas Goaziou af67fa1ebe Merge branch 'bugfix' 2021-10-06 14:42:27 +02:00
Nicolas Goaziou 5f6e199143 footnote: Allow footnotes at footnote definition start
* lisp/org-footnote.el (org-footnote--allow-reference-p): Allow
footnotes at footnote definition start, right after label.
* testing/lisp/test-org-footnote.el (test-org-footnote/new): Add
tests.
2021-10-06 14:34:14 +02:00
Nicolas Goaziou b07c312f28 oc: Allow citations at footnote definition start
* lisp/oc.el (org-cite--allowed-p): Allow citations at footnote
definition start.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add tests.
2021-10-06 14:29:40 +02:00
Nicolas Goaziou 9b063251cf oc: Allow citations at footnote definition start
* lisp/oc.el (org-cite--allowed-p): Allow citations at footnote
definition start.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add tests.
2021-10-06 14:28:04 +02:00
Kyle Meyer cc2490a706 Prune Emacs 25.1 compatibility kludges
* lisp/oc-basic.el (org-cite-basic--field-less-p):
* lisp/ol-eww.el (org-eww-store-link):
* lisp/org-agenda.el (org-agenda-check-clock-gap):
* lisp/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve-clock, org-clock-resolve)
(org-resolve-clocks, (org-resolve-clocks-if-idle)
(org-clock-in, org-clock-sum): Drop now unnecessary use of
compatibility functions.

* lisp/org-compat.el (org-string-collate-lessp, org-decode-time)
(org-format-time-string, org-link-escape-browser, org-time-add)
(org-time-subtract, org-time-since, org-time-less-p): Mark as
obsolete.

The 9.5 release declared Emacs 25.1 as the minimum version.
2021-10-04 23:43:14 -04:00
Nicolas Goaziou d6f0e9e105 oc: Be stricter when introducing spaces before citations
* lisp/oc.el (org-cite-process-citations): Add a space before citation
only if it is preceded by a quotation mark.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add
tests.

Reported-by: Denis Maier <denismaier@mailbox.org>
<http://lists.gnu.org/r/emacs-orgmode/2021-09/msg00085.html>
2021-10-03 23:51:43 +02:00
Yasushi SHOJI 3a291b0f0e ox-publish.el: Add `org-html-publish-to-html' as the default publishing function
* lisp/org-macs.el (org-plist-delete-all): New function.

* lisp/ox-publish.el (org-publish-file): Add
`org-html-publish-to-html' as the default publishing function.

* testing/lisp/test-ox-publish.el (org-test-publish): Use
`org-plist-delete-all' to remove properties from the plist.

Reported-by: Christopher W. Ryan
See <https://list.orgmode.org/CAELBRWLgV-s6SGX=cevtN7iW8htwiLezR469T-cGMWE_6iX1+A@mail.gmail.com>
2021-09-29 09:14:43 +02:00
Jeremie Juste 51a60cd53f lisp/ob-R: Async evaluation in R
* lisp/ob-R.el (ob-session-async-R-indicator): Add constant
representing a prefix R to identity session.
(ob-session-async-org-babel-R-evaluate-session): New function to
evaluate R src block asynchrously.
(ob-session-async-R-value-callback): New function that calls back
the result of the asynchronous evaluation.
(org-babel-R-evaluate): Add `async' parameter and call
`ob-session-async-org-babel-R-evaluate-session' if `async'
parameter is present.
(org-babel-execute:R): Call `org-babel-comint-use-async' to check
if async is among `params' and add async parameter to
`org-babel-R-evaluate'.

* testing/lisp/test-ob-R.el: Add 7 more tests for async
evaluations, also taken from the `ob-session-async' package.

This is almost a carbon copy of Jack Kamm's `ob-session-async'.
The original source code can be found
https://github.com/jackkamm/ob-session-async.

Please refer to the following thread to trace back the discussion
on async evaluation in R:

https://list.orgmode.org/87eed9g9p6.fsf@gmail.com/
2021-09-28 18:22:12 +02:00
Max Nikulin 6300e0ebef test-org-protocol.el: Decode "+" to " " tests
testing/lisp/test-org-protocol.el
(test-org-protocol/org-protocol-store-link)
(test-org-protocol/org-protocol-capture): Cases to check that "+" is
decoded to space in query parameters (new style of URIs) but preserved
in path components (old style of org-protocol links).
2021-09-27 17:52:03 +02:00
Bastien 98fd6d5fd5 Remove references to deleted packages
* testing/lisp/test-ob-vala.el: Delete file.

* mk/default.mk (BTEST_OB_LANGUAGES):
* lisp/ox-man.el (org-man-source-highlight-langs):
* lisp/org.el (org-babel-load-languages): Remove references to
deleted packages.
2021-09-26 14:13:28 +02:00
Ihor Radchenko 54c2327f3a Allow :var header args to be assigned to cons cells
* lisp/ob-core.el (org-babel-disassemble-tables,
org-babel-gnuplot-process-vars): Use `proper-list-p' check instead of
`listp'.
(org-babel-disassemble-tables): Check list length before trying to
remove hline from a table assignment.
* testing/lisp/test-ob.el (test-ob/cons-cell-as-variable): Add the
test.
2021-09-26 10:21:20 +02:00
Ihor Radchenko d3d80c5948 Add test checking org-log-done specs
* testing/lisp/test-org.el (test-org/org-log-done): New test
2021-09-26 09:05:17 +02:00
Bastien 777c1c3cb5 Merge branch 'bugfix' 2021-09-25 18:02:19 +02:00
Max Nikulin ec7c16a060 ox-latex: Allow percent sign in 'src-block' caption
* lisp/ox-latex.el (org-latex-src-block): Prevent leak of percent sign
from caption to `format' first argument causing export failure due to
insufficient argument number.  The fix covers only the case of verbatim
environment.
* testing/lisp/test-ox.el
(test-org-export/latex-src-block-verbatim-caption): New test for src
block LaTeX export with cases of various formatting of caption and
verbatim environment.  Check that percent signs in caption and source
block body do not lead to errors.

Reported-by: Charest, Luc <charest.luc@hydroquebec.com>
<https://lists.gnu.org/archive/html/emacs-orgmode/2021-08/msg00017.html>
2021-09-25 18:02:08 +02:00
Ihor Radchenko a3c912cb29 Fix duplicate logbook entry for repeated tasks
* lisp/org.el (org-add-log-setup): Always run `org-add-log-note' via
`post-command-hook'.  Otherwise, there is no way to know if a note was
requested for `this-command'.  Running `org-add-log-note' directly
would, for example, break `org-auto-repeat-maybe' as reported in [1].

* lisp/org-agenda.el (org-agenda-todo): Avoid reintroducing the bug
fixed in c670379adf.

* testing/lisp/test-org.el: Add test checking the reported bug.

[1] https://orgmode.org/list/CAOn=hbcaW1R6vtun-E2r4LS=j3dp=VjqmjGtzy8UC1SyPArKbA@mail.gmail.com
2021-09-25 17:23:53 +02:00
Pedro Bruel bf1c4c7575 Include support for evaluating julia code
* lisp/ob-julia.el: included from org-contrib
* testing/lisp/test-ob-julia.el: start adapting from testing/lisp/test-ob-python.el
2021-09-25 16:00:02 +02:00
Marco Wahl 069bcba529 org: Fix functionality of org-insert-heading
* lisp/org.el (org-insert-heading): Fix insertion of headings when
  point is before any heading in the case of "respect content" insertion.

Kudos to Victor Stoichita. https://orgmode.org/list/87lf4594t3.fsf@svictor.net/
2021-09-18 14:54:09 +02:00
Nicolas Goaziou c839849aba footnote: Allow inserting footnotes at the end of table cells
* lisp/org-footnote.el (org-footnote--allow-reference-p): Allow
inserting footnotes at the end of table cells.
* testing/lisp/test-org-footnote.el (test-org-footnote/new): Add test.
2021-07-29 21:15:11 +02:00
Nicolas Goaziou 7ea9099725 oc: Allow inserting citations in table cells (part 2)
* lisp/oc.el (org-cite--allowed-p): Allow inserting a citation after
two or more spaces at the end of a table cell.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add
tests.
2021-07-29 21:13:01 +02:00
Nicolas Goaziou 78c450247b oc: Allow inserting citations in captions
* lisp/oc.el (org-cite--allowed-p): Allow inserting citations in captions.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add test.
2021-07-28 11:11:46 +02:00
Nicolas Goaziou af0fcb6833 element: Allow citations in table cells
* lisp/org-element.el (org-element-object-restrictions): Allow
citations in table cells.
* testing/lisp/test-org-element.el (test-org-element/citation-parser):
Add test.  Remove outdated test.
2021-07-28 10:32:29 +02:00
Nicolas Goaziou e844a6fd41 oc: Add Org Cite library
* lisp/oc.el: New file.
* testing/lisp/test-oc.el: New file.
2021-07-09 08:47:14 +02:00
Nicolas Goaziou 4c646a6bde ox: Introduce "raw" pseudo objects
* lisp/ox.el (org-export-raw-string): New function
(org-export-data):
(org-export-with-backend): React to raw objects.
* testing/lisp/test-ox.el (test-org-export/raw-string): New test.

A raw object is a pseudo-object (i.e., special object type that exists
only during export) with the property of being exported as-is, with no
processing from an export back-end.

It is particularly useful to add contents to, or pre-process objects
from, a parse tree.
2021-07-09 08:47:14 +02:00
Nicolas Goaziou fed07be5b8 element: Add citation support
* lisp/org-element.el (org-element-citation-key-re):
(org-element-citation-prefix-re): New variables.
(org-element--set-regexps): Set `org-element--object-regexp' so it
finds citations.
(org-element-all-objects): Add citation and citation-reference
objects.
(org-element-recursive-objects): Add citation object.
(org-element-object-restrictions): Add citation and citation-reference
to restrictions.
(org-element-secondary-value-alist): citation and citation references
can hold secondary strings.
(org-element-citation-parser):
(org-element-citation-interpreter):
(org-element-citation-reference-parser):
(org-element-citation-reference-interpreter): New functions.
(org-element--object-lex): Parse citations and citations references.
* testing/lisp/test-org-element.el (test-org-element/citation-parser):
(test-org-element/citation-reference-parser):
(test-org-element/citation-interpreter): New tests.

This patch adds support for [cite:@key], [cite:pre @key post]
[cite:global prefix; pre @key1 post; pre @key2 post; global suffix]
objects along with their [cite/style: ...] counterparts.
2021-07-09 08:47:14 +02:00
Allen Li 622f9fa76c org: Use crm for completing tags
* lisp/org-capture.el (org-capture-fill-template): Changed to use
completing-read-multiple.
* lisp/org.el (org-set-tags-command): Changed to use
completing-read-multiple.
(org-change-tag-in-region): Changed to use a simple completion table.
* testing/lisp/test-org.el (test-org/set-tags-command): Fixed tests.

Change various places which use `completing-read' to read tags using a
custom completion function to instead use `completing-read-multiple'
with a completion table instead.

This makes tab completion play better with alternative completion
frameworks such as vertico, selectrum, etc.

`org-change-tag-in-region' only reads a single tag, so it is changed
to use a completion table with `completing-read'.  This also makes it
play better with alternative completion frameworks.

Note that there is still one use for `org-tags-completion-function',
which is for completing tag matches.  Completing tag matches is
different from completing lists of tags since the separators (+, -,
etc) have semantic meaning.  This commit does not address that use
case.
2021-07-09 08:44:32 +02:00
Nicolas Goaziou dce8b3f254 Merge branch 'maint' 2021-05-20 15:45:45 +02:00
Nicolas Goaziou 13c78a5900 footnote: Allow new footnotes in empty cells
* lisp/org-footnote.el (org-footnote--allow-reference-p): allow
inserting new footnotes in empty cells.
* testing/lisp/test-org-footnote.el (test-org-footnote/new): Add
tests.

Reported-by: Uwe Brauer <oub@mat.ucm.es>
<http://lists.gnu.org/r/emacs-orgmode/2021-05/msg00940.html>
2021-05-20 15:44:27 +02:00
Jack Kamm 53fd5b774e ob-comint.el, ob-python.el: Async session evaluation
Adds functionality to ob-comint.el to implement async session eval on
a per-language basis.  Adds a reference implementation for ob-python.

* lisp/ob-comint.el (org-babel-comint-with-output): Remove comment.
(org-babel-comint-async-indicator, org-babel-comint-async-buffers,
org-babel-comint-async-file-callback,
org-babel-comint-async-chunk-callback,
org-babel-comint-async-dangling): Add buffer-local variables used for
async comint evaluation.
(org-babel-comint-use-async): Add function to determine whether block
should be evaluated asynchronously.
(org-babel-comint-async-filter): Add filter function to attach to
comint-output-filter-functions for babel async eval.
(org-babel-comint-async-register): Add function to setup buffer
variables and hooks for session eval.
(org-babel-comint-async-delete-dangling-and-eval): Add helper function
for async session eval.

* lisp/ob-python.el (org-babel-execute:python): Check for async header
argument.
(org-babel-python-evaluate): Check whether to use async evaluation.
(org-babel-python-async-indicator): Add constant for indicating the
start/end of async evaluations.
(org-babel-python-async-evaluate-session): Add function for Python
async eval.

*
testing/lisp/test-ob-python.el (test-ob-python/async-simple-session-output):
Unit test for Python async session eval.
(test-ob-python/async-named-output): Unit test that Python async eval
can replace named output.
(test-ob-python/async-output-drawer): Unit test that Python async eval
works with drawer results.
2021-05-18 09:13:28 -07:00
Bastien 4362b93018 Merge branch 'maint' 2021-05-16 10:36:42 +02:00
Nicolas Goaziou 8846ea71fa element: Fix drawer parsing
* lisp/org-element.el (org-element-drawer-parser): A single ":END:"
line should not be recognized as a drawer.
* testing/lisp/test-org-element.el (test-org-element/drawer-parser):
Add test.

Reported-by: Ihor Radchenko <yantar92@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2021-05/msg00819.html>
2021-05-16 10:14:54 +02:00
Kévin Le Gouguec f0447de941 Set org-adapt-indentation explicitly in some tests
* testing/lisp/test-org.el (test-org/indent-line)
(test-org/indent-region): Make sure `org-adapt-indentation' is
consistent with expected results.
2021-05-15 16:13:49 +02:00
Kévin Le Gouguec b183315e16 Set org-adapt-indentation explicitly in some tests
* testing/lisp/test-org.el (test-org/with-electric-indent)
(test-org/without-electric-indent): Make sure
`org-adapt-indentation' is consistent with expected results.
2021-05-15 16:13:49 +02:00
Ihor Radchenko 3f59ea981c Add a test for known bug in org-element-cache
* testing/lisp/test-org-element.el (test-org-element/cache-bugs): A
new test documenting a known bug:

1. Create initial file like:

P0

  P1
  | a | b |
<point>| c | d |

Note that second line of the table is not indented.  Now,
org-element-at-point returns table-row.

2. Modify the file to test org-element-cache

P0

- item

  P1
  | a | b |
<point>| c | d |

Now, the first (indented) row of the table belongs to item.  The
second row should be an individual table and org-element-at-point
returns table.
2021-05-15 16:13:49 +02:00
Ihor Radchenko f318cd6c40 Fix test-org-element/cache "Preserve local structures when re-parenting."
* testing/lisp/test-org-element.el (test-org-element/cache): Add
spaces to make the "abcd" table a single table.  The old version uses
example org text with two tables and was passing because of another
bug in org-element-cache.  Testing the old version with
org-element-use-cache set to nil would yield error, while it should
not.
2021-05-15 16:13:49 +02:00
Ihor Radchenko 7dcb1afb69 Improve org-link-plain-re
* lisp/ol.el (org-link-make-regexps): Allow URLs with up to two
levels of nested brackets.

* lisp/org.el (org-link-plain-re): Update docstring.

* testing/lisp/test-ol.el: Add tests for the plain link regular
expression.

(org-link-plain-re): Update docstring.  Now,

Now, URLs like [1] can be matched.  The new regexp is based on [2].
The docstring of `org-link-plain-re'  explicitly mentions that the
regexp must contain groups for the link type and the path.

[1] https://doi.org/10.1016/0160-791x(79)90023-x
[2] https://daringfireball.net/2010/07/improved_regex_for_matching_urls
2021-05-15 16:13:49 +02:00
Kévin Le Gouguec 4764a2fbf9 Set org-adapt-indentation explicitly in some tests
* testing/lisp/test-org.el (test-org/indent-line)
(test-org/indent-region): Make sure `org-adapt-indentation' is
consistent with expected results.
2021-05-15 14:45:23 +02:00
Kévin Le Gouguec d85f4158e2 Set org-adapt-indentation explicitly in some tests
* testing/lisp/test-org.el (test-org/with-electric-indent)
(test-org/without-electric-indent): Make sure
`org-adapt-indentation' is consistent with expected results.
2021-05-15 14:45:21 +02:00
Ihor Radchenko 6ab5299e5b Fix test-org-element/cache "Preserve local structures when re-parenting."
* testing/lisp/test-org-element.el (test-org-element/cache): Add
spaces to make the "abcd" table a single table.  The old version uses
example org text with two tables and was passing because of another
bug in org-element-cache.  Testing the old version with
org-element-use-cache set to nil would yield error, while it should
not.
2021-05-15 13:51:02 +02:00
Ihor Radchenko f313b81841 Improve org-link-plain-re
* lisp/ol.el (org-link-make-regexps): Allow URLs with up to two
levels of nested brackets.

* lisp/org.el (org-link-plain-re): Update docstring.

* testing/lisp/test-ol.el: Add tests for the plain link regular
expression.

(org-link-plain-re): Update docstring.  Now,

Now, URLs like [1] can be matched.  The new regexp is based on [2].
The docstring of `org-link-plain-re'  explicitly mentions that the
regexp must contain groups for the link type and the path.

[1] https://doi.org/10.1016/0160-791x(79)90023-x
[2] https://daringfireball.net/2010/07/improved_regex_for_matching_urls
2021-05-15 10:33:23 +02:00
Jeremie Juste 9014577df2 test-ob-R.el: add tests for how NA values are printed
* testing/lisp/test-ob-R.el (ert-deftest test-ob-r/NA-blank): new test
for :results value. Make sure that NA values in R data.frames are
empty string instead of nil previously

see https://orgmode.org/list/87pn1dufm2.fsf@gmail.com/
2021-05-03 00:29:09 +02:00
Jeremie Juste c0338142b7 test-ob-R.el: add tests for output with substrings matching prompt
* testing/lisp/test-ob-R.el (test-ob-r/output-with-<>): new test for output
  angle brackets
 (test-ob-R/output-nonprinted): New test for output results that aren't
explicitly printed.  (Here all the lines are expected to be printed
not just the last one)

Patch suggested by Jack Kamm:
https://orgmode.org/list/87h7slgbi5.fsf@gmail.com/
2021-05-03 00:18:33 +02:00
Bastien 379e22bfcc Merge branch 'maint' 2021-05-02 11:06:46 +02:00
Ihor Radchenko 0e7153e63d org-test: Fix wrong-numbre-of-arguments error on master+native-comp
* testing/org-test.el (org-test-at-time): Use correct number of
arguments in 'decode-time cl-letf binding. `decode-time' accepts up to
3 arguments on master.

The wrong-numbre-of-arguments error is raised on Emacs master
configured with native-comp support when running make test on Org mode
master.  Native-comp modifies function calls with optional arguments
in the way that omitted arguments are still provided as `nil'.  For
example, `decode-time' called as (decode-time time) in lisp source may
be compiled into (decode-time time nil nil) call by native-compiler.
If redefined `decode-time' does not accept 3 arguments, it result in
error.

See Emacs bug#48133.
2021-05-02 11:06:32 +02:00
Sébastien Miquel a2cb9b853d ob-tangle.el: Improve tangling
* lisp/ob-tangle.el (org-babel-tangle-collect-blocks): Group
collected blocks by tangled file name.
(org-babel-tangle): Avoid quadratic behavior in number of blocks and
set modes before writing to file.
* testing/lisp/test-ob-tangle.el (ob-tangle/block-order): Update test.
2021-05-01 22:30:42 +02:00
Bastien Guerry 047fa8c319 Merge branch 'maint' 2021-04-28 09:23:29 +02:00