Commit Graph

2288 Commits

Author SHA1 Message Date
Ihor Radchenko dc63cdd220
org-test-load: Make tests with missing dependencies more prominent
* testing/org-test.el (org-test-load): Skip test files that throw
'missing-test-dependency.  Skipped tests are explicitly listed in test
summary and thus more visible.  This also distinguishes such tests
from known bugs.
2022-11-16 16:44:49 +08:00
Ihor Radchenko a831c18baf
fixup! test-ob-python: Disable test failing on CI when using older Emacs 2022-11-16 16:31:40 +08:00
Ihor Radchenko d45a896289
test-ob-python: Disable test failing on CI when using older Emacs
* testing/lisp/test-ob-python.el (test-ob-python/assign-underscore):
Skip the test when running Emacs <28.  On older Emacs, python.el may
fail to load on slow machines, like during CI testing.

Link: https://lists.sr.ht/~bzg/org-build-failures/%3CCOCRNW71TUAP.L29E2AW6TQZ2%40cirno2%3E
2022-11-16 10:29:40 +08:00
Ihor Radchenko 3ef0e3c338
test-ob-python: Refactor test failing on CI to provide better backtrace
* testing/lisp/test-ob-python.el (test-ob-python/assign-underscore):
Do not wrap code into `should' form as much as possible to avoid
truncated backtrace.
2022-11-15 15:04:08 +08:00
Ihor Radchenko f83e45526b
org-toggle-item: Move footnote-definitions out of the lists
* lisp/org-list.el (org-toggle-item): When headings contain
footnote-definitions, move them out of the list.  Footnote-definitions
must not be indented and hence cannot belong to the list.  Ensure that
definitions do not slurp the following element after the list.
Consider when the list created by `org-toggle-item' is continued by an
existing list.
* testing/lisp/test-org-list.el (test-org-list/toggle-item): Add
tests.

Reported-by: Ypo <ypuntot@gmail.com>
Link: https://orgmode.org/list/877d3k70lu.fsf@localhost
2022-11-11 13:19:01 +08:00
Ihor Radchenko c41a2198f2
testing: Provide more debug info for diary sexps
* testing/org-test.el (org-test-run-batch-tests):
(org-test-run-all-tests): Bind `calendar-debug-sexp' to non-nil when
running tests.

See https://orgmode.org/list/t2hpe9$119m$1@ciao.gmane.io
2022-11-11 11:34:14 +08:00
Ihor Radchenko d620c30e6f
fixup! testing/lisp/test-ob-java.el: Skip when ob-java is not loaded 2022-11-10 16:58:07 +08:00
Ihor Radchenko f85865e59f
testing/lisp/test-ob-java.el: Skip when ob-java is not loaded
* testing/lisp/test-ob-java.el (featurep): Skip tests when ob-java is
not loaded.
2022-11-10 16:54:35 +08:00
Ihor Radchenko 5a6d00a3a3
test-org-num.el: Do not rely on fixed overlay order in `overlays-in'
* testing/lisp/test-org-num.el (test-org-num/max-level):
(test-org-num/skip-numbering):
(test-org-num/update):
* testing/lisp/test-org-table.el (test-org-table/toggle-column-width):
Do not expect specific overlay order in the return value of
`overlays-in'.  The order is not guaranteed by the docstring and has
been changed in Emacs 29.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59067
2022-11-09 10:12:44 +08:00
Ihor Radchenko e3a7c01874
Refactor `org-time-stamp-custom-formats' and `org-time-stamp-formats'
* lisp/org.el (org-time-stamp-formats):
* lisp/org.el (org-time-stamp-custom-formats): Change the default
values stripping leading "<" and trailing ">".  Update the docstring
explaining the format and that leading and trailing brackets are now
ignored.  Update the :type specification to more precise.
(org-time-stamp-format): Update the argument list and docstring
allowing to use the function more flexibly to find the time stamp
format for both `org-time-stamp-formats' and
`org-time-stamp-custom-formats'.  Rename `long' argument to more
accurate `with-time'.  Ignore brackets in the `org-time-stamp-formats'
and `org-time-stamp-custom-formats'.  Allow `inactive' argument to be
`no-brackets'
(org-format-timestamp):
(org-read-date-display):
(org-insert-time-stamp):
(org-display-custom-time):
(org-timestamp-translate):
* lisp/org-compat.el (org-timestamp-format): Rename
`org-timestamp-format' to `org-format-timestamp'.  The old variant is
too similar with other `org-time-stamp-format' function.  Also, use
`org-time-stamp-format' to determine the timestamp format instead of
using `org-time-stamp-formats' directly.
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps):
(org-agenda-get-progress):
* lisp/org-archive.el (org-archive-subtree):
(org-archive-to-archive-sibling):
* lisp/org-clock.el (org-clock-special-range):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--find-date):
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/date):
* lisp/ox-odt.el (org-odt--format-timestamp):
(org-odt-template):
* lisp/ox.el (org-export-get-date):
* testing/lisp/test-org.el (test-org/timestamp-format): Use
`org-time-stamp-format' instead of directly examining
`org-time-stamp-custom-formats' and `org-time-stamp-formats'.  Use the
new function name `org-format-timestamp'.
* etc/ORG-NEWS (Default values and interpretations of ~org-time-stamp-formats~ and ~org-time-stamp-custom-formats~ are changed):
(~org-timestamp-format~ is renamed to ~org-format-timestamp~):
(Updated argument list in ~org-time-stamp-format~): Document the
user-facing changes.

This commit documents and unifies previously undocumented assumptions
about the values of `org-time-stamp-formats' and
`org-time-stamp-custom-formats'.  Instead of fiddling with
leading/trailing brackets in the values, expedite the time format
calculation to `org-time-stamp-format'.  The undocumented assumption
about brackets in user option `org-time-stamp-custom-formats' is not
relaxed making the docstring correct.

Reported-by: Uwe Brauer <oub@mat.ucm.es>
Link: https://orgmode.org/list/87k04ppp1t.fsf@localhost
2022-11-07 15:05:37 +08:00
Daniel Ziltener 5e0c5c186d
org-babel: Add new "strip-tangle" :noweb argument value
* lisp/ob-tangle.el (org-babel-tangle-single-block): Strip noweb tags
from block if :noweb has been set to "strip-tangle".
* lisp/ob-core.el (org-babel-common-header-args-w-values): Add
"strip-tangle" as new allowed value.
* lisp/ob-core.el (org-babel-noweb-p): Add "strip-tangle" at the
appropriate positions.
* testing/lisp/test-ob-tangle.el (ob-tangle/strip-tangle): Add new test
case for "strip-tangle".
* doc/org-manual.org (Noweb Reference Syntax): Adjust documentation for
the noweb header argument.
* etc/ORG-NEWS: Add entry for new header argument value.

This patch adds the "strip-tangle" option for the :noweb header
argument.  This strips the noweb tags before tangling the block.  This can
be useful for e.g. testing purposes where one wants to use a block as
test case that can be both run inline as well as tangled into a file for
automated testing.

TINYCHANGE
2022-11-07 10:54:13 +08:00
Rudolf Adamkovič eefb14f9fa
test-org-clock: Test DWIM update of days
* testing/listp/test-org-clock (test-org-clock/clock-drawer-dwim): Add
new test for DWIM updates of days for clocks in logbook drawers.

Reported-by: Bruce E. Robertson <brucer42@gmail.com>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53393
2022-11-06 11:27:35 +08:00
Rudolf Adamkovič f7b16402e6
org-babel: Never throw away standard error
* lisp/ob-eval.el (org-babel-eval-error-notify): Do not insert
superfluous whitespace.
* lisp/ob-eval.el (org-babel-eval): Show standard error even if the
command exits with a zero code.
* testing/lisp/test-ob-shell.el(
ob-shell/standard-output-after-success,
ob-shell/standard-output-after-failure,
ob-shell/error-output-after-success,
ob-shell/error-output-after-failure,
ob-shell/error-output-after-failure-multiple,
ob-shell/exit-code,
ob-shell/exit-code-multiple
): Add tests to avoid regressions.
2022-11-04 10:48:38 +08:00
Ihor Radchenko b93a61af9c
org-latex-line-break-safe: Use safer value of "\\[0pt]"
* lisp/ox-latex.el (org-latex-line-break-safe):
(org-latex-table-row):
Change \empty ending to explicit optional argument.  \empty still has
undesired side effects in some cases.

* testing/lisp/test-org-table.el (test-org-table/to-latex):
* testing/lisp/test-ox-latex.el (test-ox-latex/verse): Update tests.

Reported-by: Juan Manuel Macías <maciaschain@posteo.net>
Link: https://orgmode.org/list/87o7u9rz1a.fsf@posteo.net
2022-10-29 10:34:05 +08:00
Ihor Radchenko 6bbd08f5aa
org-datetree-insert-line: Fix blank line insertion
* lisp/org-datetree.el (org-datetree-insert-line): Use
`org--blank-before-heading-p' check.

* testing/lisp/test-org-datetree.el (test-org-datetree/find-date-create):
(test-org-datetree/find-month-create):
(test-org-datetree/find-iso-week-create): Explicitly set
`org-blank-before-new-entry' assumed throughout the tests.

Note that the `auto' behavior in `org-blank-before-new-entry' is
somewhat arbitrary.  It currently prefers no blank lines by
default (when no other headings are present in the buffer).  I went
with fixing the tests rather than changing
`org--blank-before-heading-p' to prefer inserting blank lines.  This
should make lesser impact on the end users.

Reported-by: Richard Walker <walkerrichardj@gmail.com>
Link: https://list.orgmode.org/orgmode/CAFyNgSE4mAt+b0Ks8L9bg2LbHcXnayOh+bYyONTQ4jN+zx3C1w@mail.gmail.com/
2022-10-26 15:25:24 +08:00
stardiviner 87e50f467a
test-org-fold.el: Add test for inline image displaying when cycling
* testing/lisp/test-org-fold.el (test-org-fold/org-fold-display-inline-images):
Add unit test for inline image displaying when cycling.
2022-10-26 12:43:08 +08:00
Mikhail Skorzhinskii c3aa6a6d43
org-refile.el: Show refile targets with a title
* lisp/org-refile.el (org-refile-get-targets): Use a document
title (#+TITLE) instead of file or buffer name in outline path, if a
corresponding customisation option is set to 'title.  Fallback to a
filename if there is no title in the document.

* lisp/org-refile.el (org-refile-use-outline-path): Add a new option
'title, see above.
2022-10-25 14:53:14 +08:00
Ihor Radchenko 9a3dd429bb
org-babel-import-elisp-from-file: Fix when \"s are not around
* lisp/ob-core.el (org-babel-string-read): Only considered \" at the
string boundaries, not inside.
* testing/lisp/test-ob-shell.el (ob-shell/results-table): Add a test.
2022-10-23 14:30:57 +08:00
Rudolf Adamkovič 524e0e0b7b
test-ob: Test indentation of multiline text in list output
* testing/lisp/test-ob.el (test-ob/org-babel-results-indented-list):
Add a regression test for the recent change to ob-core list formatting
in e700578799.
2022-10-22 12:30:21 +08:00
Ihor Radchenko a83edd624b
fixup! ob-shell: Fix multi-line scripts in sessions 2022-10-22 12:28:31 +08:00
Ihor Radchenko 801c93638a
ob-shell: Fix multi-line scripts in sessions
* lisp/ob-comint.el (org-babel-comint-with-output): Clean up empty
output.  Such output is emitted unnecessarily for multi-line scripts.
* lisp/ob-shell.el (org-babel-shell-set-prompt-commands): Disable
PS2 and equivalent prompts.  Make sure that PROMPT_COMMAND does not
interfere with PS1 setting in POSIX shells.
(org-babel-sh-evaluate): Do not send input line-by-line.  Instead, let
`org-babel-coming-with-output' handle waiting for the output as well
as recording it.  Update to the new `org-babel-coming-with-output'
behavior of cleaning empty outputs.
* testing/lisp/test-ob-shell.el (test-ob-shell/session): Add a test.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/orgmode/m2r0zboix1.fsf@me.com/
2022-10-22 12:15:51 +08:00
Rudolf Adamkovič bed47b437d
test-ob-java: Test Java source block header arguments at all levels
* testing/lisp/test-ob-java.el (ob-java/lint-header-arguments):
Rename to ob-java/lint-header-args-block.

* testing/lisp/test-ob-java.el (ob-java/lint-header-args-heading):
Test source block header arguments at the heading level.

* testing/lisp/test-ob-java.el (ob-java/lint-header-args-buffer):
Test source block header arguments at the buffer level.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://orgmode.org/list/m2y1ta9rqe.fsf@me.com
2022-10-21 21:30:53 +08:00
Rudolf Adamkovič ee3dbb0fdb
ob-java: Define the list of all supported header arguments
* lisp/ob-java.el (org-babel-header-args:java): Complete the list of
header arguments supported for Java source blocks.
* testing/lisp/test-ob-java.el (ob-java/lint-header-arguments): Test
that the linter approves of all the supported arguments.
2022-10-21 11:43:19 +08:00
Bruno BARBIER 98cae03b7d
lisp/org-element: Add a parameters-line property to special blocks
Add a property `:parameters' to special blocks, to store the
PARAMETERS as a string.

* lisp/org-element.el (org-element-special-block-parser): Parse
PARAMETERS and set the property `:parameters'.

(org-element-special-block-interpreter): Interpret the property
`:parameters'.

*
testing/lisp/test-org-element.el (test-org-element/special-block-parser):
Add a new test for PARAMETERS.

(test-org-element/special-block-interpreter): Add new tests for PARAMETERS.
2022-10-20 17:39:55 +08:00
Bruno BARBIER 7d1e3dc38e
org-element-special-block-interpreter: Fix when no content
* lisp/org-element.el (org-element-special-block-interpreter): Use
empty string when content is nil.

*
testing/lisp/test-org-element.el (test-org-element/special-block-interpreter):
Test the case with no content.
2022-10-20 17:39:54 +08:00
Ihor Radchenko 4b9aef20d8
org-fold-hide-entry: Fix on empty heading with a child.
* lisp/org-fold.el (org-fold-hide-entry): Consider case when a child
heading is right at the next line below empty heading.
* testing/lisp/test-org-fold.el (test-org-fold/org-fold-hide-entry):
Add tests.

Reported-by: k_foreign@outlook.com
Link: https://orgmode.org/list/BY5PR10MB4289036F2436A909412E9D5096299@BY5PR10MB4289.namprd10.prod.outlook.com
2022-10-17 21:04:31 +08:00
Ihor Radchenko 5fa66c7ffc
org-latex-verse-block: Fix regression from 3f60acff7
* lisp/ox-latex.el (org-latex-verse-block): Fix logic replacing sole
paragraph breaks according to the new template.
* testing/lisp/test-ox-latex.el: New test file.
(org-test-with-exported-text): New macro for testing export.
(test-ox-latex/verse): New test.
* mk/default.mk (BTEST_RE): Select the new test by default.

Reported-by: Juan Manuel Macías <maciaschain@posteo.net>
Link: https://orgmode.org/list/875ygk6a8z.fsf@posteo.net
2022-10-16 11:17:03 +08:00
Max Nikulin 892df429f4
ox-latex: Use \empty instead of \relax after \\
* lisp/ox-latex.el (org-latex-line-break-safe, org-latex-table-row):
* testing/lisp/test-org-table.el (test-org-table/to-latex): Use \empty
instead of \relax to prevent interpreting following "*" and "[" as
optional parts of \\*[LENGTH] command.

Fix regression introduced by 3f60acff77. \\\relax\hline caused
misaligned \noalign error. Org markup:

    | a |
    |---|

\hline is allowed only immediately after \cr while \relax has some side
effects. Hope, \empty just expands to nothing.

Those who used \\ optional argument to adjust amount of space between
lines may add the following tricks:

    First,\\
    @@latex:{\vskip1em}@@second.

    | First                               |
    | @@latex:\noalign{\vskip1em}@@second |

Reported in
gerard.vermeulen, Wed, 12 Oct 2022 03:15:49 +0000.
https://list.orgmode.org/784cf8be450b7d676ddd60214cc847db@posteo.net
2022-10-14 10:27:14 +08:00
Ihor Radchenko 3e86487755
testing/lisp: Add missing `provide'
* testing/lisp/test-ob-sql.el (test-ob-sql):
* testing/lisp/test-ob-sqlite.el (test-ob-sqlite): Add missing provide
and use the correct file name in the comments.
2022-10-13 18:30:44 +08:00
Ihor Radchenko 08a1a91623
testing/lisp: Add missing `featurep' checks for required packages
* testing/lisp/test-ob-julia.el (featurep):
* testing/lisp/test-ob-ruby.el (featurep):
* testing/lisp/test-ob-scheme.el (featurep): Check for the required
external packages.
2022-10-13 18:30:07 +08:00
Ihor Radchenko 97672efdb0
testing/lisp/test-ob-eshell.el: Fix tests
* testing/lisp/test-ob-eshell.el (ob-eshell/execute):
(ob-eshell/variables-assignment): Do not expect
`org-babel-execute-src-block' to return the actual inserted src block
string.
2022-10-13 18:28:56 +08:00
Ihor Radchenko 4c0641837c
org-babel-script-escape: Turn empty lists into nil
* lisp/ob-core.el: Translate (), {}, and [] to nil.
* testing/lisp/test-ob.el (test-ob/script-escape): Add tests.

Reported-by: Jonas Bernoulli <jonas@bernoul.li>
Link: https://list.orgmode.org/87v8opfhk1.fsf@bernoul.li/T/#u
2022-10-12 19:46:14 +08:00
Liu Hui c57b030323
org-agenda: Make sure file restriction can be removed
* lisp/org-agenda.el: (org-agenda-restrict):
(org-agenda-restrict-begin):
(org-agenda-restrict-end):
(org-agenda-overriding-restriction): add docstrings.
(org-agenda):
(org-agenda-set-restriction-lock): Set `org-agenda-restrict' non-nil
during both temporary and extended file restriction.
(org-agenda-remove-restriction-lock): Revert commit df0e96ba4.
* testing/lisp/test-org-agenda.el (test-org-agenda/file-restriction):
Add a test.
2022-10-12 15:35:12 +08:00
Ihor Radchenko eb15341b3c
org-cycle-set-visibility-according-to-property: Do not change ancestor visibility
* lisp/org-cycle.el (org-cycle-set-visibility-according-to-property):
Do not unconditionally run `org-fold-reveal' for headlines with
"VISIBILITY" property.  `org-fold-reveal' can break the global
visibility and ancestor headline visibility settings.
*
testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property):
Add test.

Reported-by: Eduardo Suarez <esuarez@itccanarias.org>
Link: https://orgmode.org/list/20220409202736.GA28127@itccanarias.org
2022-10-12 13:47:41 +08:00
Ihor Radchenko 3f60acff77
ox-latex: Protect [...] after \\ to be interpreted as LaTeX argument
* lisp/ox-latex.el (org-latex-linebreak-safe): New constant holding
safe version of LaTeX line break.
(org-latex-table-matrix-macros):
(org-latex-clock):
(org-latex-line-break):
(org-latex-plain-text):
(org-latex-planning):
(org-latex--org-table):
(org-latex--math-table):
(org-latex-table-row):
(org-latex-verse-block): Use the new constant.

* testing/lisp/test-org-table.el (test-org-table/to-latex): Update
tests.

Reported-by: Stewart Thomas <sjt015@bucknell.edu>
Link: https://orgmode.org/list/ce760fc3-5aae-144d-2d02-7dea215f73fc@gmail.com
2022-10-11 11:32:52 +08:00
Ihor Radchenko 8901fd2261
Add a regression test for `org-export-with-buffer-copy'
* testing/lisp/test-ox.el (test-org-export/org-export-copy-buffer):
Make sure that `org-export-with-buffer-copy' does not show up when
Emacs is searching for buffers associated with file.
2022-10-10 17:36:11 +08:00
Ihor Radchenko 31de027c12
test-ob-java: Use `temporary-file-directory'
* testing/lisp/test-ob-java.el (ob-java/simple-dir):
(ob-java/simple-dir-with-package): Prefer `temporary-file-directory'
over `org-babel-temporary-directory'.  The latter is nil in
noninteractive Emacs during tests.

Reported-by: Christian Köstlin <christian.koestlin@gmail.com>
2022-10-09 12:30:00 +08:00
Ihor Radchenko ba8fbd0cda
testing/lisp/test-ob-java.el: Add missing `provide' 2022-10-09 12:13:30 +08:00
Ihor Radchenko 3de74bbeff
fixup! org-export-copy-buffer: Prevent saving to disk
* lisp/ox.el (org-export--generate-copy-script): Set
`write-contents-functions' after running `major-mode'.
* testing/lisp/test-ox.el (test-org-export/org-export-copy-buffer):
Add test.
2022-10-07 17:46:15 +08:00
Nicholas Vollmer 7f3a6cf6e7
org-capture: Add template hook properties
* lisp/org-capture.el (org-capture-templates): Document template hook properties.
(org-capture-finalize): Execute :prepare/:before/:after-finalize functions.
(org-capture-place-template): Execute :hook functions.

* doc/org-manual.org: Document template hook properties.

* etc/ORG-NEWS: Add news entry for template hook properties.

* testing/lisp/test-org-capture.el: Add tests for template hook properties.
2022-10-07 13:38:52 +08:00
Rudolf Adamkovič 48ac65bea0
ob-sed-test: Make the tests pass on BSD systems, such as macOS
* testing/examples/ob-sed-test.org: Fix BSD sed incompatibility
2022-10-07 12:10:20 +08:00
Jonas Bernoulli 9b690462a3
Allow returning empty list from post-processing block
* lisp/ob-ref.el (org-babel-ref-resolve): When the result an empty
list, then treat it as a list, not as the symbol nil.
* testing/lisp/test-ob.el (test-ob/post-header-arguments): Add new
test.
* etc/ORG-NEWS (Post-processing code blocks can return an empty list):
Document change in behavior.
2022-10-07 12:06:30 +08:00
Liu Hui edf5afc1d8
Fix filter preset problem for sticky agenda
* lisp/org-agenda.el (org-agenda-local-vars):
(org-agenda-filters-preset): Add a new variable
`org-agenda-filters-preset' for storing per-buffer filter presets.
(org-agenda):
(org-agenda-filter-any):
(org-agenda-prepare):
(org-agenda-finalize):
(org-agenda-redo):
(org-agenda-filter-by-tag):
(org-agenda-filter-make-matcher):
(org-agenda-set-mode-name):
(org-agenda-reapply-filters): Use `org-agenda-filters-preset' for
getting and setting per-buffer filter presets, rather than modifying
the global symbol property.  Change `org-lprops' from symbol property
to per-buffer text property.  Delete unused `last-args' symbol
property.
* testing/lisp/test-org-agenda.el (test-org-agenda/sticky-agenda-filter-preset):
(test-org-agenda/redo-setting): Add tests.
2022-10-07 11:43:32 +08:00
Ihor Radchenko 506d5b12dd
org-comment-line-break-function: Avoid built-in Emacs comment machinery
* lisp/org.el (org-comment-line-break-function): Rely on Org
parser (`org-adaptive-fill-function') to determine comment filling.
Handle nil values of `fill-prefix' correctly.

* testing/lisp/test-org.el (test-org/default-indent-new-line): New
test.  Written by Kaushal Modi <kaushal.modi@gmail.com>
https://list.orgmode.org/CAFyQvY36DkBSNy2mPxDNZWeoTjUK8mAqgJM-zHxNamfReqGkuQ@mail.gmail.com/

Reported-by: Richard Lawrence <richard.lawrence@uni-tuebingen.de>
Link: https://list.orgmode.org/87lf18fue9.fsf@aquinas.i-did-not-set--mail-host-address--so-tickle-me/
2022-10-04 19:47:11 +08:00
Thierry Banel aa3eac143d ob-C: do not swallow double quotes on raw output
* lisp/ob-C.el (org-babel-C-execute): Remove the erroneous
  call to `org-babel-read' when output is raw.
* testing/examples/ob-C-test.org (Output),
  testing/lisp/test-ob-C.el (ob-C/ouput-doublequotes):
  Add a test with double quotes output.

https://list.orgmode.org/orgmode/bc004962-679e-498f-b245-ae253aae6271@www.fastmail.com/
2022-09-27 16:20:57 +02:00
Ihor Radchenko 0a6a56c804
org-adapt-indentation: Fix 'headline-data checks
* lisp/org.el (org--at-headline-data-p): New function used to check if
element at point belongs to headline data.
(org--get-expected-indentation):
(org-indent-line): Use `org--at-headline-data-p' instead of
explicit (and inaccurate) condition.
* testing/lisp/test-org.el (test-org/indent-region): Add tests.

Fixes incorrect LOGBOOK drawer indentation when
`org-adapt-indentation' is set to 'headline-data.
2022-09-24 14:07:31 +08:00
Rudolf Adamkovič c940b460c7
ox-texinfo: Include LaTeX in Texinfo exports
* lisp/ox-texinfo.el (org-texinfo-with-latex): New customize.
* lisp/ox-texinfo.el (org-texinfo-latex-environment): New function.
* lisp/ox-texinfo.el (org-texinfo-latex-fragment): New function.
* lisp/ox-texinfo.el (org-texinfo-supports-math-p): New function.
* lisp/ox-texinfo.el (org-texinfo-supports-math--cache): New variable.
* lisp/ox-texinfo.el (texinfo): Set latex-environment.
* lisp/ox-texinfo.el (texinfo): Set latex-fragment.
* testing/lisp/test-ox-texinfo.el: Add basic tests.
2022-09-21 15:29:50 +08:00
Ihor Radchenko cb8bf4a0d0
org-babel-expand-references: Fix :noweb-ref expansion
* lisp/ob-core.el (org-babel-expand-noweb-references): Do not rely on
reference cache being populated as a condition that all the references
in buffer have been processed.  Set this information explicitly.
* testing/lisp/test-ob.el (test-ob/noweb-expansion): Add new test.
2022-09-17 15:52:24 +08:00
Ihor Radchenko e3348ccc03
org-batch-test-init: Remove dead code
* testing/org-batch-test-init.el (lambda): Remove the code that has
never been working.  One could still rewrite the code using
`autoloadp', but it would break things terribly and should not be
needed as autoload does not need to be updated after changing the
`load-path'.  See
https://orgmode.org/list/jwvedwczhbv.fsf-monnier+emacs@gnu.org
2022-09-16 11:33:26 +08:00
Ihor Radchenko 6074a22bcb
testing: Address FIXMEs identified in 1a5e3f931
* testing/lisp/test-ob.el (test-ob/blocks-with-spaces):
(test-ob/specific-colnames):
* testing/lisp/test-oc.el (test-org-cite/export-capability):
* testing/lisp/test-ol.el (test-org-link/store-link):
* testing/lisp/test-org.el (test-org/set-regexps-and-options):
* testing/org-test.el (org-test-base-dir): Address typos and
non-existent variables.

(missing-test-dependency): Use `define-error'.
(org-test-load): Set `org-id-locations-file' when running tests.

* testing/lisp/test-ox.el (test-org-export/bind-keyword): Clarify
about variable symbol defined inside setupfile #+BIND statemtn.
2022-09-16 11:30:16 +08:00
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