Commit Graph

2584 Commits

Author SHA1 Message Date
Karthik Chikmagalur 9cce40c94f
org-link: Customizable preview API for arbitrary link types
Add a customizable preview API for arbitrary link types.  Make
inline image previews a part of the more universal org-link
preview feature.  Each link type can now be previewed differently
based on a new link parameter.

* lisp/ol.el (org-link-parameters, org-link-preview-batch-size,
org-link-preview-delay, org-link-preview--timer,
org-link-preview--queue, org-link-preview-overlays,
org-link-preview--get-overlays, org-link-preview--remove-overlay,
org-link-preview, org-link-preview-region,
org-link-preview--process-queue, org-link-preview-clear,
org-link-preview-file, org-display-remote-inline-images,
org-image-align, org--create-inline-image,
org-display-inline-image--width, org-image--align): Add new
commands `org-link-preview', `org-link-preview-region' and
`org-link-preview-clear' for creating link previews for any kind
of link.  Add new org-link parameter `:preview' for specifying how
a link type should be previewed.  This link parameter is a
function called asynchronously to place previes.  File links and
attachments are previewed using inline image previews as before.
Move image handling utilities from lisp/org.el to lisp/ol.el.

* testing/lisp/test-org-fold.el: Use `org-link-preview'.

* lisp/org.el (org-toggle-inline-images,
org-toggle-inline-images-command, org-display-inline-images,
org--inline-image-overlays, org-inline-image-overlays,
org-redisplay-inline-images, org-image-align,
org-display-inline-remove-overlay, org-remove-inline-images,
org-startup-with-inline-images, org-startup-with-link-previews,
org-startup-options): Obsolete and move
`org-toggle-inline-images', `org-display-inline-images' and
`org-redisplay-inline-images' to org-compat.  These are obsoleted
by `org-link-preview' and `org-link-preview-region'.  Remove
`org-toggle-inline-images-command'.  Move the other internal
functions to org-link.  Rename `org-startup-with-inline-images' to
`org-startup-with-link-previews'.  Add new STARTUP options for
link previews to `org-startup-options': "linkpreviews" and
"nolinkpreviews".

* lisp/org-plot.el (org-plot/redisplay-img-in-buffer): Modify to
use `org-link-preview'.

* lisp/org-keys.el: Bind `C-c C-x C-v' to new command
`org-link-preview', which has the same prefix arg behaviors as
`org-latex-preview'.  In addition to these, it supports numeric
prefix args 1 and 11 to preview links with descriptions at
point/region (with 1) and across the buffer (with 11).

* lisp/org-cycle.el (org-cycle-display-inline-images,
org-cycle-display-link-previews, org-cycle-inline-images-display,
org-cycle-inline-link-previews): Use `org-link-preview' and
`org-link-preview-region'.  Rename inline-images functions and user
options to their link-previews equivalents:

- `org-cycle-display-inline-images' to `org-cycle-display-link-previews'
- `org-cycle-inline-images-display' to `org-cycle-inline-link-previews'

* lisp/org-compat.el (org-display-inline-remove-overlay,
org--inline-image-overlays, org-remove-inline-images,
org-inline-image-overlays, org-display-inline-images,
org-toggle-inline-images):

* lisp/org-attach.el (org-attach-preview-file): Add new `:preview'
link parameter for links of type "attachment", set to the new
function `org-attach-preview-file'.
2024-11-27 19:34:26 +01:00
Ihor Radchenko 4ff4828944
org-footnote--collect-references: Fix infinite recursion
* lisp/org-footnote.el (org-footnote--collect-references): Fix
infinite recursion when nested references form a closed loop.
* testing/lisp/test-org-footnote.el (test-org-footnote/sort): New
test.

Reported-by: Avraham Pinkas <ampinkas@gmail.com>
Link: https://orgmode.org/list/CAHEwkt8vnYGr1ZN-De9ec4bqBk_7yHARFAsZmY81u1GimSritA@mail.gmail.com
2024-11-23 20:44:07 +01:00
Jack Kamm 3ff21c7138 Add options to skip extra processing in org-babel-comint-with-output
This patch adds options to org-babel-comint-with-output to skip prompt
removal.  Allowing individual languages to handle this cleanup can be
more robust than relying on the generic ob-comint implementation.
This allows ob-python to switch back to using
`org-babel-comint-with-output' rather than its own bespoke
reimplementation, reducing code duplication.  Furthermore, this adds a
new implementation of ob-R non-async session output evaluation, that
is similar to the ob-python approach in that it avoids leaking
prompts, rather than relying on the cleanup from
`org-babel-comint-with-output'.  A test is added to test-ob-R.el to
demonstrate the improved robustness of the new approach; previously,
this test would fail due to a false positive prompt, but now passes.

* lisp/ob-comint.el (org-babel-comint--remove-prompts-p): New helper
function to parse the prompt-handling argument in
`org-babel-comint-with-output' and `org-babel-comint-async-register'.
(org-babel-comint-with-output): Add a new argument
to prevent extra processing for prompt cleanup.  Also, search for the
end-of-execution sentinel within the collected output rather than the
comint buffer, which doesn't depend on the position of point during
evaluation.
(org-babel-comint-async-register): Move parsing of prompt-handling
argument to `org-babel-comint--remove-prompts-p'.
* lisp/ob-python.el: Require subr-x for Emacs 27 compatibility.
(org-babel-python-send-string): Switch to using
`org-babel-comint-with-output', rather than bespoke reimplementation.
* lisp/ob-R.el: Require subr-x for Emacs 27 compatibility.
(ess-send-string): Declare external function.
(org-babel-R-evaluate-session): New implementation of output
evaluation that avoids leaking prompts, by writing the code block to a
tmp file and then sourcing it.
* testing/lisp/test-ob-R.el (test-ob-r/session-output-with->-bol): New
test for robustness against false positive prompts at the beginning of
a line.
2024-11-12 19:54:28 -08:00
Ihor Radchenko cab233fb96
org-test-for-executable: Detect stub executables
* testing/org-test.el (org-test-for-executable): Make sure that EXE
can be actually executed.  Some OSes (darwin) provide command stubs,
which are present, but useless to call.

Link: https://orgmode.org/list/CALo8A5ULVNQLhP=yReO-V9Uni=caqkjiQtcWUOrtr1XOXakjYA@mail.gmail.com
2024-11-09 15:53:22 +01:00
Jack Kamm 09e7bb0604 Merge branch 'bugfix' 2024-11-01 17:14:48 -07:00
Jack Kamm 23a3c82532 Disable async prompt removal in ob-R,python
* lisp/ob-comint.el (org-babel-comint-async-remove-prompts-p): New
variable to disable prompt removal in async output.
(org-babel-comint-async-filter): Check
`org-babel-comint-async-remove-prompts-p' before calling
`org-babel-comint--prompt-filter'.
(org-babel-comint-async-register): Added argument for whether prompts
should be removed from async output.
* lisp/ob-python.el (org-babel-python-async-evaluate-session): Set
option to inhibit prompt removal when registering async evaluators.
* lisp/ob-R.el (ob-session-async-org-babel-R-evaluate-session): Set
option to inhibit prompt removal when registering async evaluators.
* testing/lisp/test-ob-R.el (test-ob-R/async-prompt-filter): Test for
over-aggressive prompt removal.
2024-11-01 17:05:45 -07:00
Sean Whitton ac73e594c9 Replace use of if-let and when-let, obsolete in Emacs 31.0.50
* lisp/ob-R.el (org-babel-R-associate-session):
* lisp/ob-clojure.el (ob-clojure-nbb-command, ob-clojure-cli-command):
* lisp/ob-core.el (org-babel-execute-src-block):
* lisp/ob-exp.el (org-babel-exp-code):
* lisp/ob-julia.el (org-babel-julia-associate-session):
* lisp/ob-python.el
(org-babel-python--python-util-comint-end-of-output-p):
* lisp/ol.el (org-insert-link):
* lisp/org-attach.el (org-attach):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-compat.el (fboundp):
* lisp/org-element-ast.el (org-element-property-raw)
(org-element-put-property, org-element-copy):
* lisp/org-element.el (org-element-timestamp-interpreter)
(org-element--cache-key):
* lisp/org-goto.el (org-goto-location):
* lisp/org-lint.el (org-lint-suspicious-language-in-src-block)
(org-lint-export-option-keywords):
* lisp/org-macs.el (org-mks):
* lisp/org-persist.el: (org-persist-write:elisp):
* lisp/org-table.el (org-table-fedit-finish):
* lisp/org.el (org-entry-get-with-inheritance):
* lisp/ox-html.el (org-html--reference, org-html--build-mathjax-config)
(org-html-example-block):
* lisp/ox-latex.el (org-latex-table-row):
* lisp/ox.el (org-export--prune-tree)
(org-export--blindly-expand-include):
* testing/lisp/test-duplicates-detector.el
(test-duplicates-detector--find-duplicates):
* testing/lisp/test-ob-haskell-ghci.el
(test-ob-haskell-ghci-checking-buffers):
* testing/lisp/test-ob-python.el
(test-ob-python/async-local-python-shell):
* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-assoc-arrays)
(test-ob-shell/bash-uses-assoc-arrays-with-lists)
(test-ob-shell/remote-with-stdin-or-cmdline):
Replace use of if-let and when-let, obsolete in Emacs 31.0.50.

(cherry picked from commit bc7033f2d1)
2024-10-27 10:34:05 +08:00
Ihor Radchenko cff9c45afb
ox-texinfo: Fix definitions containing Org markup
* lisp/ox-texinfo.el (org-texinfo--match-definition): Consider :tag
being an anonymous node with multiple markup nodes.  Convert it to
plain Texinfo beforehand, so that it is available as a plain text.
Add new optional argument INFO to be able to run Org AST for :tag ->
Texinfo text conversion.
(org-texinfo--separate-definitions): Pass INFO to
`org-texinfo--match-definition'.
* testing/lisp/test-ox-texinfo.el (test-ox-texinfo/definition): New
test case.

Reported-by: 8dcc <8dcc.git@gmail.com>
Link: https://orgmode.org/list/87wmi09tdx.fsf@gmail.com
2024-10-26 10:36:59 +02:00
Sean Whitton bc7033f2d1 Replace use of if-let and when-let, obsolete in Emacs 31.0.50
* lisp/ob-R.el (org-babel-R-associate-session):
* lisp/ob-clojure.el (ob-clojure-nbb-command, ob-clojure-cli-command):
* lisp/ob-core.el (org-babel-execute-src-block):
* lisp/ob-exp.el (org-babel-exp-code):
* lisp/ob-julia.el (org-babel-julia-associate-session):
* lisp/ob-python.el
(org-babel-python--python-util-comint-end-of-output-p):
* lisp/ol.el (org-insert-link):
* lisp/org-attach.el (org-attach):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-compat.el (fboundp):
* lisp/org-element-ast.el (org-element-property-raw)
(org-element-put-property, org-element-copy):
* lisp/org-element.el (org-element-timestamp-interpreter)
(org-element--cache-key):
* lisp/org-goto.el (org-goto-location):
* lisp/org-lint.el (org-lint-suspicious-language-in-src-block)
(org-lint-export-option-keywords):
* lisp/org-macs.el (org-mks):
* lisp/org-persist.el: (org-persist-write:elisp):
* lisp/org-table.el (org-table-fedit-finish, orgtbl--skip)
(orgtbl--skipcols):
* lisp/org.el (org-entry-get-with-inheritance):
* lisp/ox-beamer.el (org-beamer--format-frame):
* lisp/ox-html.el (org-html--reference, org-html--build-mathjax-config)
(org-html-example-block):
* lisp/ox-latex.el (org-latex-table-row):
* lisp/ox.el (org-export--prune-tree)
(org-export--blindly-expand-include):
* testing/lisp/test-duplicates-detector.el
(test-duplicates-detector--find-duplicates):
* testing/lisp/test-ob-haskell-ghci.el
(test-ob-haskell-ghci-checking-buffers):
* testing/lisp/test-ob-python.el
(test-ob-python/async-local-python-shell):
* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-assoc-arrays)
(test-ob-shell/bash-uses-assoc-arrays-with-lists)
(test-ob-shell/remote-with-stdin-or-cmdline):
Replace use of if-let and when-let, obsolete in Emacs 31.0.50.
2024-10-24 17:04:40 +08:00
Ihor Radchenko 39264d3d41
ox-texinfo: Fix escaping commas inside commands with multiple arguments
* lisp/ox-texinfo.el (org-texinfo--sanitize-content): Sanitize commas
everywhere to make sure that we do not end up with text commas being
interpreted as argument separator in @command{arg1, arg2, ...}.  This
approach will produce @comma{} even when it is not necessary, but it
is the safest approach.
(org-texinfo-plain-text): Update the comment.
* testing/lisp/test-ox-texinfo.el (test-ox-texinfo/escape-special-characters):
New test.

Reported-by: 8dcc <8dcc.git@gmail.com>
Link: https://orgmode.org/list/87set58skp.fsf@gmail.com
2024-10-19 10:29:13 +02:00
Ihor Radchenko da0f6eff75
ox-texinfo: Fix edge case with - Variable: nil:: definition
* lisp/ox-texinfo.el (org-texinfo--split-definition): Do not store
definition options as :attr_texinfo read by
`org-export-read-attribute'.  `org-export-read-attribute' is incapable
of reading literal nil.  Instead, store the options literally, as is,
in a special non-standard syntax node property.
(org-texinfo-special-block): Make use of syntax node property used by
`org-texinfo--split-definition', when present.
* testing/lisp/test-ox-texinfo.el (test-ox-texinfo/definition): New
test.

Reported-by: 8dcc <8dcc.git@gmail.com>
Link: https://orgmode.org/list/87plo98a8g.fsf@gmail.com
2024-10-14 20:39:47 +02:00
Ihor Radchenko b6dbf88810
org-footnote-new: Do not throw an error at bol for inline/anonymous footnotes
* lisp/org-footnote.el (org-footnote--allow-reference-p): New optional
argument indicating that the footnote reference is going to be
anonymous/inline.  It is then allowed to be at bol.
(org-footnote-new): Check whether a footnote reference can be inserted
in place taking into account the footnote type.
* testing/lisp/test-org-footnote.el (test-org-footnote/new): New test
cases.

Reported-by: Suhail Singh <suhailsingh247@gmail.com>
Link: https://orgmode.org/list/877carzufa.fsf@gmail.com
2024-10-13 11:03:32 +02:00
Jack Kamm c07028671d
ox-icalendar: Fix export of diary-style timestamps
* lisp/ox-icalendar.el (org-icalendar-entry): Include timestamps of
type diary when `:with-timestamps' is `active'.
* lisp/ox.el (org-export--skip-p): Include timestamps of type diary
when `:with-timestamps' is `active'.
*
testing/lisp/test-ox-icalendar.el (test-ox-icalendar/diary-timestamp):
Unit test for exporting timestamps of type diary.
2024-09-22 12:22:33 +02:00
Jens Lechtenbörger 9cbf0c99c3
test-ox-publish.el: Add tests for publish cache
* testing/lisp/test-ox-publish.el (org-test-publish): Add optional
arguments `timestamp-flag' and `pubdir' for control over existing
local variables, add optional argument `keep-pubdir-p' for conditional
deletion of publication directory.
(org-test-publish-touch): New function to change modification time of
file.
(test-org-publish/publish-cache): New function with tests.

* testing/examples/pub-cache/source.org:
* testing/examples/pub-cache/config.org: New example files.
2024-09-17 20:32:15 +02:00
Rudolf Adamkovic 6443c83bd1
ox-texinfo: Support links in headings
* etc/ORG-NEWS (Texinfo exporter now supports links in headings):
Announce the new feature.
* lisp/ox-texinfo.el: (org-texinfo--format-entries,
org-texinfo--get-node, org-texinfo--sanitize-title-reference,
org-texinfo--sanitize-title): A 2-step change: (1) Rename
`--sanitize-title' to `--sanitize-title-reference' and (2) create a
new `--sanitize-title' sanitation function.  The new function is less
strict in that does not remove links, which should be allowed in
sectioning commands, such as `@unnumbered'.  The old function remains
more strict, which is useful for generating `@node' names, for
example.
* testing/lisp/test-ox-texinfo.el:
(test-ox-texinfo/headings-with-links): Test the new functionality to
avoid regressions in the future.
2024-09-16 20:54:08 +02:00
Rudolf Adamkovič 4829bacffe
ox-texinfo: Fix automatic @ref titles
* lisp/ox-texinfo.el (org-texinfo--@ref): Fix an incorrect assumption
that Texinfo uses node names for automatic link text.  It does not.
Instead, it uses the corresponding section title.  For example, if a
node is named `a' its section is named `A', the Org link to the node
`a' written as `[[...][xxx]]' ends up being rendered as "A", which
means the link description the Org user provided is ignored.
2024-09-15 14:08:19 +02:00
Slawomir Grochowski 07dd3bcae6
org-columns-compile-format: Fix regexp
* lisp/org-colview.el (org-columns-compile-format): Refactor
string-based regexp to `rx' form.  Fix regexp: When an empty
parentheses () is in the column format string then the regexp
can't capture the operator which is in curly brackets {}.
(org-columns-new): prevent adding empty parantheses '()' to 'column
format string' when 'column title' is empty.
* testing/lisp.test-org-colview.el (test-org-colview/compile-format):
New test case: check if operator will be captured when there is
empty parantheses '()' in 'column format string'.

Reported-by: Sławomir Grochowski <slawomir.grochowski@gmail.com>
Link: https://list.orgmode.org/orgmode/877ccczt83.fsf@gmail.com/
2024-08-31 15:31:13 +02:00
Ihor Radchenko 482bc31565
org-babel-demarcate-block: Fix keeping BEGIN_SRC/END_SRC case
* lisp/ob-core.el (org-babel-demarcate-block): Keep case in
 #+BEGIN_SRC and #+END_SRC keywords splitting src block.
* testing/lisp/test-ob.el (test-ob/keep-case): New test.

Reported-by: Rudolf Adamkovič <rudolf@adamkovic.org>
Link: https://orgmode.org/list/m2y152f8s3.fsf@adamkovic.org
2024-08-14 11:02:18 +02:00
Ihor Radchenko 114c764035
Remove test introduced in 190f47222
* testing/lisp/test-org-macs.el (test-org/string-width): Remove the
new test.  It is not working in batch mode, where pixel width cannot
be calculated.
2024-07-22 21:01:20 +02:00
Ihor Radchenko 190f472227
org-string-width: Round fractional widths
* lisp/org-macs.el (org-string-width): Fix zero-width
spaces (displayed as 1 pixel) being treated and full-width characters.
* testing/lisp/test-org-macs.el (test-org/string-width): Add new test.

Reported-by: Daniel <daniel@algebra20.de>
Link: https://orgmode.org/list/877cddbfkb.fsf@algebra20.de
2024-07-22 19:59:58 +02:00
stardiviner f2141541b4
ob-core: Unify Org Babel related buffer names using constant variable
* lisp/ob-core.el (org-babel-results-buffer-name): Define constant
variable for buffer name.
(org-babel-open-src-block-result): Use the
`org-babel-results-buffer-name'.
* lisp/ob-eval.el (org-babel-error-buffer-name): Add docstring.
* testing/lisp/test-ob-octave.el (org-babel-error-buffer-name):
(ob-octave/graphics-file):
(ob-octave/graphics-file-session):
(ob-octave/graphics-file-space):
* testing/lisp/test-ob-shell.el (org-babel-error-buffer-name):
(test-ob-shell/dont-error-on-babel-error):
(test-ob-shell/standard-output-after-failure):
(test-ob-shell/error-output-after-success):
(test-ob-shell/error-output-after-failure):
(test-ob-shell/error-output-after-failure-multiple):
(test-ob-shell/exit-code):
(test-ob-shell/exit-code-multiple): Use variable for buffer names.
2024-07-16 19:09:45 +02:00
Ihor Radchenko e0924db3c5
orgtbl-to-generic: Retain special rows in code block table output
* lisp/org-table.el (orgtbl--skip):
(orgtbl--skipcols): New helper functions.
(orgtbl-to-generic): Use `org-export-as' machinery to setup table
export instead of duplicating ox.el internals.  Retain special rows in
tables when exporting to Org.  Org export is used by ob-core to format
the code block output and will thus retain special rows.
* testing/lisp/test-org-table.el (test-org-table/to-generic): Adjust
test to expect special rows to be exported.
* etc/ORG-NEWS (~orgtbl-to-generic~ retains special rows when
exporting to Org): Announce the breaking change.

Reported-by: Rudolf Adamkovič <rudolf@adamkovic.org>
Link: https://orgmode.org/list/87r0ch6q9h.fsf@localhost
2024-07-10 15:54:44 +02:00
Ihor Radchenko f7ef4071b2
org-list-struct-apply-struct: Fix item contents breaking out of the item
* lisp/org-list.el (org-list-struct-apply-struct): Make sure that we
never shift item contents to or before the item indentation.
* testing/lisp/test-org-list.el (test-org-list/cycle-bullet): Add new
test.

Reported-by: vitalij@gmx.com
Link: https://orgmode.org/list/871q42qbn7.fsf@gmx.com
2024-07-10 15:39:26 +02:00
Ihor Radchenko 69ef1832bb
Merge branch 'bugfix' 2024-07-09 18:07:27 +02:00
Ihor Radchenko 022bb471c1
org-indent-line: Fix indentation inside src blocks with `electric-indent-mode'
* lisp/org.el (org-indent-line): Use `indent-according-to-mode' to
indent in src block's major mode.  Using `indent-line-function' fails
when `electric-indent-mode' wants to suppress <tab> indentation.
* testing/lisp/test-org.el (test-org/with-electric-indent): Add test.

Reported-by: the_wurfkreuz <the_wurfkreuz@proton.me>
Link: https://orgmode.org/list/5O9VMGb6WRaqeHR5_NXTb832Z2Lek_5L40YPDA52-S3kPwGYJspI8kLWaGtuq3DXyhtHpj1J7jTIXb39RX9BtCa2ecrWHjijZqI8QAD742U=@proton.me
2024-07-09 18:05:41 +02:00
Nate Nichols d38d53a178
ox-html: Add an ability to specify :html-head as a string or function
* lisp/ox-html.el (org-html-head):
(org-html-head-extra): Allow value to be a function.
(org-html-normalize-string-or-function): New helper function.
(org-html--build-head): Use the new helper to handle the function
value of :html-head and :html-head-extra export options.
* etc/ORG-NEWS:
(~org-html-head~ and ~org-html-head-extra~ can now be specified as
functions): Document the new feature.
* testing/lisp/test-ox-html.el (ox-html/test-normalize-string-or-function):
New test.

TINYCHANGE
2024-07-07 17:24:01 +02:00
Ihor Radchenko b64dbd838f
org-babel-sh-evaluate: Always provide shebang in script files
* lisp/ob-shell.el (org-babel-sh-evaluate): When running src block as
script file, make sure that shebang is always added on top.  This is
to prevent <shell> <script> command in shells like dash form using
/bin/sh to evaluate scripts without shebang.  (In contrast with bash
that uses itself).  Add comment highlighting that
`with-connetion-local-variables' sets `shell-file-name' and
`shell-command-switch' as necessary.
*
testing/lisp/test-ob-shell.el (test-ob-shell/remote-with-stdin-or-cmdline):
Add new test.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://list.orgmode.org/orgmode/v0an63$3n2$1@ciao.gmane.io/
2024-06-27 15:07:19 +02:00
Ihor Radchenko 1c7b3ed26b
ob-shell: Pass :cmdline arguments consistently regardless of :shebang
* lisp/ob-shell.el (org-babel-sh-evaluate): When invoking script file
generated from the code block, consistently use
<shell-name> -c <script-file> <cmdline-args> command line, even when
:shebang is header argument is provided.  The previous approach with
<script-file> <cmdline-args> call caused differences in how shell
parsed the provided command line arguments.
* testing/lisp/test-ob-shell.el (test-ob-shell/cmdline): New test.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/18f01342a2f.124ad27612732529.8693431365849276517@excalamus.com
2024-06-27 14:17:03 +02:00
Ihor Radchenko 840cb395aa
test-org-capture/entry: Fix Emacs 27 compatibility
* testing/lisp/test-org-capture.el (test-org-capture/entry): Use
`org-dlet' instead of `dlet' that is not yet available in Emacs 27.
2024-06-18 18:09:21 +02:00
Nafiz Islam 5265153fc5
org-capture-templates: Allow headline/olp target to be function or symbol
* doc/org-manual.org: Add target spec format for function and symbol
for headline and olp.
* etc/ORG-NEWS: Announce the updated options for
`org-capture-templates'.
* lisp/org-capture.el (org-capture-templates): Update customization
type for `file+headline', `file+olp', and `file+olp+datetree' targets,
and update docstring.
(org-capture-expand-headline): Define a new function that computes
headline string from target spec.
(org-capture-expand-olp): Define a new function that computes olp list
from target spec.
(org-capture-set-target-location): Use `org-capture-expand-headline'
to expand headline, and use `org-capture-expand-olp' to expand outline
path.
* testing/lisp/test-org-capture.el (test-org-capture/entry): Add tests
for at most three different kinds of target for `file+headline',
`file+olp', and `file+olp+datetree'.
(test-org-capture/org-capture-expand-olp): Add tests for
`org-capture-expand-olp'.
2024-06-18 14:33:55 +02:00
Stefan Monnier 96d149a660
testing/lisp/*.el: Fix second arg to `signal'
The second argument to `signal' should be a list, as explained in its
docstring.  Fix `missing-test-dependency' signals accordingly.
2024-06-15 16:27:24 +02:00
Stefan Monnier cb758720f3
testing/org-test.el (<toplevel>): Remove dead code
(featurep 'org) is always non-nil here since we have a (require 'org)
further up.  I suspect other `require's nearby could be removed or
moved to toplevel.
2024-06-15 16:27:15 +02:00
Rudolf Adamkovič c4434f825d
ob-lua: Do not confuse list-like strings with lists
* lisp/ob-lua.el (org-babel-lua-wrapper-method): Prevent Org Babel
from confusing strings that look like lists with actual lists.
* testing/lisp/test-ob-lua.el (test-ob-lua/result/none):
(test-ob-lua/result/nil):
(test-ob-lua/result/nil/multiple):
(test-ob-lua/result/boolean):
(test-ob-lua/results/number/integer):
(test-ob-lua/results/number/integer/negative):
(test-ob-lua/results/number/integer/multiple):
(test-ob-lua/results/number/real):
(test-ob-lua/results/number/real/multiple):
(test-ob-lua/results/number/infinity):
(test-ob-lua/results/string/single-quotes):
(test-ob-lua/results/string/double-quotes):
(test-ob-lua/results/string/multiple):
(test-ob-lua/results/string/list-like):
(test-ob-lua/results/string/list-like/brackets):
(test-ob-lua/results/string/list-like/curlies):
(test-ob-lua/results/string/list-like/multiple):
(test-ob-lua/result/table):
(test-ob-lua/result/table/pretty-print):
(test-ob-lua/result/table/pretty-print/sorted):
(test-ob-lua/results/value-separator): Add new tests.
2024-06-15 14:59:09 +02:00
Rudolf Adamkovič 58e5d1d5a6
ob-lua: Remove half-baked session support
* lisp/ob-lua.el (org-babel-execute:lua):
(org-babel-prep-session:lua):
(org-babel-load-session:lua):
(org-babel-lua-session-buffer):
(org-babel-lua-with-earmuffs):
(org-babel-session-buffer:lua):
(org-babel-lua-without-earmuffs):
(lua-default-interpreter):
(lua-which-bufname):
(lua-shell-buffer-name):
(org-babel-lua-initiate-session-by-key):
(org-babel-lua-initiate-session):
(org-babel-lua-evaluate):
(org-babel-lua-evaluate-external-process):
(org-babel-lua-evaluate-session):
(org-babel-lua-read-string): Remove all unfinished Lua and Emacs Lisp
code related to sessions and emit a user error when a Lua session is
requested.
* testing/lisp/test-ob-lua.el (test-ob-lua/no-sessions): Test the user
error emitted when requesting a Lua session.

Link: https://list.orgmode.org/87y192etb4.fsf@localhost/
2024-06-15 14:59:07 +02:00
Rudolf Adamkovič 3ccc1ca6ec
ob-lua: Escape double quote characters in results
* lisp/ob-lua.el (org-babel-lua-wrapper-method): Escape all double
quote characters in Lua before giving them to Org Babel.
* testing/lisp/test-ob-lua.el (test-ob-lua/escaping-quotes): Test
automatic escaping of double quote characters.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://list.orgmode.org/216278dc-075c-47d1-94dc-f5bde8346b3c@gmail.com/
2024-06-15 14:59:06 +02:00
Ihor Radchenko 8f40da6bf6
Merge branch 'bugfix' 2024-06-13 17:31:05 +02:00
Ihor Radchenko 96113f3b59
org-export--set-variables: Fix variable assignment
* lisp/ox.el (org-export--set-variables): Assume that variables are
listed as (var value) - as a list.  Only use the second element of the
list as the value, following example in `org-export-get-environment'.
(org-export-get-environment): Use `org-export--set-variables'.
* testing/lisp/test-ox.el (test-org-export/bind-keyword): Add new
test.

Reported-by: Suhail Singh <suhailsingh247@gmail.com>
Link: https://orgmode.org/list/87cyonhuq3.fsf@gmail.com
2024-06-13 17:26:44 +02:00
Ihor Radchenko dc2f270ac4
org-agenda: Fix multi-day ranges with non-nil `org-agenda-default-appointment-duration'
* lisp/org-agenda.el (org-agenda-get-blocks): Force
`org-agenda-default-appointment-duration' to be nil for time blocks -
they already have begin/end time, even if during different days.
* testing/examples/agenda-file2.org (five):
* testing/lisp/test-org-agenda.el (test-org-agenda/time-grid): New
test.

Reported-by: hrdl <git@hrdl.eu>
Link: https://orgmode.org/list/ZldNYYtvvQp0dILB@t490.localdomain
2024-06-09 14:25:58 +02:00
Ihor Radchenko 453cb0883a
Merge branch 'bugfix' 2024-06-06 17:23:11 +02:00
Ihor Radchenko e6c5f25c13
org-babel-exp-code: Fix exporting src blocks with :var arguments
* lisp/ob-exp.el (org-babel-exp-code): Do not use resolved argument
values when formatting the code block.  Resolved argument values may
contain awkward data like full (long) table contents, various Elisp
data (including non-printable), etc.  Simply using verbatim src block
parameters as they appear in the original buffer is more reliable.
(org-babel-exp-inline-code-template):
(org-babel-exp-code-template): Update docstrings, drop %flags
placeholder, which is no longer supported using the current src block
syntax.
* etc/ORG-NEWS (=ox-org= preserves header arguments in src blocks):
Drop "non-default" when explaining how header arguments are formatted.
We cannot know which values are default and which not without
resolving the values - something we cannot do as it turned out.
* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
(ob-export/export-src-block-with-flags):
(ob-export/body-with-coderef): Update the tests.
2024-06-06 14:44:01 +02:00
Rens Oliemans a62f75c841
org-capture: Allow table-line entry to start without |
* lisp/org-capture.el (org-capture-place-table-line): Prepend
table-line begin ('|') if the template does not start with it.

* testing/lisp/test-org-capture.el (test-org-capture/table-line):
Verify that a template gets prepended with a '|' if it does not start
with it.
2024-06-04 15:17:12 +02:00
Rens Oliemans 0c8fba93fe
org-capture: Allow entry template to start without heading
* lisp/org-capture.el (org-capture-place-entry): Prepend heading to
template if the template does not yet start with a heading.

* testing/lisp/test-org-capture.el (test-org-capture/entry): Add two
tests: no error is raised when org-capture is called with a template
that does not start with a heading; and org-capture should error with
a template with a lower heading after a higher heading.

Link: https://list.orgmode.org/877chnc0lr.fsf@localhost/
2024-06-04 15:17:11 +02:00
Kyle Meyer de0df5b925
org-test: Fix zone-dependent miscalculation of days of week
* testing/org-test.el (org-test-day-of-weeks-seconds): Specify seconds
for formatting with UTC as time zone.
(org-test-day-of-weeks-abbrev):
(org-test-day-of-weeks-full): Use UTC as time zone when formatting
input.

Avoid calling format-time-string with the local time zone because that
gives the wrong result in some cases.  For example, 2222222 is
supposed to produce the locale's name for "Tuesday" but, when the
local time zone is +0000, (format-time-string "%A" 2222222) returns
the locale's name for "Monday".
2024-06-04 15:01:31 +02:00
Kyle Meyer 671ca44df0 test-org-clock: Fix typo in test name 2024-06-01 17:10:58 -04:00
Ihor Radchenko 0450cf0e85
Fix test failures for thingatpt support on Emacs 27
* testing/lisp/test-org.el (test-org/thing-at-point/url): Disable test
in old Emacs that do not yet support custom
`thing-at-point-provider-alist'.
* etc/ORG-NEWS (Org links now support ~thing-at-point~): Clarify Emacs
versions where the new feature is supported.
2024-05-27 14:27:35 +02:00
Jim Porter 66cb45658d
Add support for 'thing-at-point' to get URL at point
* lisp/org.el (thingatpt): Require.
(org--link-at-point, org--bounds-of-link-at-point): New functions...
(org-mode): ... add to 'thing-at-point-provider-alist' and friends.

* testing/lisp/test-org.el (test-org/thing-at-point/url): New test.

* etc/ORG-NEWS: Announce this change.
2024-05-26 14:51:31 +02:00
Morgan Smith a3c1a85021
Fix typos surrounding `org-agenda-skip-scheduled-repeats-after-deadline'
* etc/ORG-NEWS: Fix typos.
* testing/lisp/test-org-agenda.el: Fix typos.
2024-05-24 19:56:07 +02:00
Ihor Radchenko e6c7b0f15e
testing/lisp/test-org.el (test-org/org-todo-prefix): Add test case 2024-05-21 12:12:11 +02:00
Ihor Radchenko 81f84ae679
testing/lisp/test-org.el (test-org/org-ctrl-c-ctrl-c): Add test case 2024-05-21 11:47:26 +02:00
Ihor Radchenko bae1b1fe70
Revert "org-table-eval-formula: Fix parsing of mode string when formula has ;"
This reverts commit 5af0625113.

The commit broken handling custom `format' spec for formula results:

Reported-by: Daniel Clemente <n142857@gmail.com>
Link: https://orgmode.org/list/CAJKAhPDFrgZY6sgefxu85qjEXnE2_HkPCHzbDOLsAD4Je57z7w@mail.gmail.com
2024-05-21 11:09:46 +02:00