Commit Graph

2100 Commits

Author SHA1 Message Date
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 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 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 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 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
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 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
Kyle Meyer 5a229cbc44 Update copyright year to 2022 2022-01-01 15:17:08 -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 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 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
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 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
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 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 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