Commit graph

18915 commits

Author SHA1 Message Date
Ihor Radchenko 34ee6f1a21
Merge branch 'bugfix' 2023-08-13 19:24:50 +03:00
Ihor Radchenko 99cc9619c5
org-bibtex-yank: Fix bibtex parser not initialized in temp buffer
* lisp/ol-bibtex.el (org-bibtex-yank): Make sure that we parse bibtex
entry from the kill ring in a `bibtex-mode' buffer.  Otherwise,
calling `org-bibtex-read' (that calls `bibtex-parse-entry') may err
because some Bibtex parser variables are not initialized.

Reported-by: J. G. <jerzor@pacbell.net>
Link: https://orgmode.org/list/1939460027.3272000.1691771671040@mail.yahoo.com
2023-08-13 19:21:48 +03:00
Ihor Radchenko 36dcb2a23c
org-babel-combine-header-arg-lists: Describe arguments in the docstring
* lisp/ob-core.el (org-babel-combine-header-arg-lists): Describe all
the header arguments in the docstring.
2023-08-13 13:35:53 +03:00
Ihor Radchenko 70a082c9fb
org-babel-expand-src-block: Mention all the header arguments in the docstring
* lisp/ob-core.el (org-babel-expand-src-block): Explain all the header
arguments in the docstring.
2023-08-12 12:06:12 +03:00
Ihor Radchenko b5aaefb551
org-babel-variable-assignments:eshell: Prevent leaking values into results
* lisp/ob-eshell.el (org-babel-variable-assignments:eshell): Wrap
`setq' eshell call into `ignore' to prevent the variable assignment
values leaking into block output.  Fixes
`ob-eshell/variables-assignment'.
2023-08-12 11:17:15 +03:00
Rudolf Adamkovič 68aa438857
ob-sqlite: Use a transient in-memory database by default
* etc/ORG-NEWS (New features): Add a news entry.
* lisp/ob-sqlite.el (org-babel-execute:sqlite): Default ':db' to
":memory:" instead of throwing an error.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-file): Test the old behavior.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-memory): Test the new behavior.
2023-08-12 11:00:48 +03:00
Max Nikulin 2f79c63c2c
org-macs.el: Fix Emacs-26 compatibility
lisp/org-macs.el (org-string-width): Avoid multiple variables in
`setq-local' since it is not supported by Emacs-26.

The code caused the issue was added in 0c29f53ab8723.
2023-08-11 19:24:36 +03:00
Ihor Radchenko cfea24dc15
org-babel-expand-body:generic: Document all the arguments in the docstring
* lisp/ob-core.el (org-babel-expand-body:generic): Document VAR-LINES
in the docstring.
2023-08-11 14:22:28 +03:00
Ihor Radchenko 1c7444dc3a
org-element: Bump AST version
* lisp/org-element.el (org-element-cache-reset): Bump AST version to
avoid clashes with previous caches after bfe1179dc.
2023-08-11 12:48:24 +03:00
Ihor Radchenko bfe1179dcb
org-element: Fix consistency between incremental and recursive parsers
* lisp/org-element.el (org-element--parse-to): Remove numerous special
conditions added to satisfy tests in `test-org-element/at-point'.
They create divergence with `org-element-parse-buffer' by sometimes
parsing inner elements up to beyond parent's :contents-end.  Instead,
modify org-data, section, and headline parsers to make their contents
include trailing blank lines.  This way, `org-element-at-point' will
naturally transcend inside section at the end of a heading.
(org-element-headline-parser):
(org-element-org-data-parser):
(org-element-section-parser): Span :contents-end all the way up to
:end.  Set :post-blank to 0 all the time.  Adjust :robust-end.
(org-element--open-end-p): Remove no longer used function.

Reported-by: Tom Alexander <tom@fizz.buzz>
Link: https://orgmode.org/list/6dd08eb7-9468-402d-bf88-eefb01442b99@app.fastmail.com
2023-08-11 12:09:36 +03:00
Ihor Radchenko 0eb9aa798c
* lisp/ob-R.el: Fix some checkdoc warnings
(org-babel-execute:R):
(org-babel-variable-assignments:R):
(org-babel-R-initiate-session): Mention all the argument in the
docstring.
2023-08-10 13:58:14 +03:00
Ihor Radchenko 6c40983e86
org-with-remote-undo: Update docstring
* lisp/org-macs.el (org-with-remote-undo): Mention all the arguments.
Document that function is not useful outside agenda.
2023-08-09 11:47:07 +03:00
Ihor Radchenko f159adc269
org-element-property: Improve docstring
* lisp/org-element-ast.el (org-element-property): Clarify the meaning
of FORCE-UNDEFER argument.
2023-08-09 10:26:11 +03:00
Ihor Radchenko a18ebc7893
Revert "Avoid creating ID property during tangling"
This reverts commit 0b4e357d62.

The original bug report actually does not need special handling
because (1) some people actually want the "fixed" behavior with IDs
being created; (2) people who don't can set org-id-link-to-org-use-id
to 'create-if-interactive.

See https://orgmode.org/list/87v8e3p5fv.fsf@localhost
2023-08-08 15:54:56 +03:00
Ihor Radchenko 3780948905
lisp/ob-ditaa.el: Fix checkdoc warnings
* lisp/ob-ditaa.el (org-babel-execute:ditaa): Mention all the
arguments in the docstring.  Start error message from capital letter.
2023-08-08 12:38:14 +03:00
Jens Schmidt f689eb44f1
org-make-tags-matcher: Add starred property operators, fix quoting
* lisp/org.el (org-make-tags-matcher): Add starred property operators.
Recognize additional operators "==", "!=", "/=".  Clean up and
document match term parsing.  Remove needless and buggy unquoting of
minus characters in property and tag names.
(org-op-to-function): Recognize additional inequality operator "/=".

* doc/org-manual.org (Matching tags and properties): Add documentation
on starred and additional operators.  Document allowed characters in
property names and handling of minus characters in property names.

* testing/lisp/test-org.el (test-org/map-entries): Add tests for
starred and additional operators.  Add tests for property names
containing minus characters.

* etc/ORG-NEWS: (~org-tags-view~ supports more property operators):
Add announcement on starred and additional operators.

Link: https://orgmode.org/list/9132e58f-d89e-f7df-bbe4-43d53a2367d2@vodafonemail.de
2023-08-08 10:01:00 +03:00
Ihor Radchenko 30b747b86d
org-babel-execute:css: Mention arguments in the docstring
* lisp/ob-css.el (org-babel-execute:css): Fix docstring.
2023-08-06 12:10:21 +03:00
Ihor Radchenko da8fabf464
org-delete-indentation: Fix Emacs 26 compatibility
* lisp/org.el (org-delete-indentation): `delete-indentation' in Emacs
26 does not yet accept region boundaries.  Provide compatibility
fallback.
2023-08-06 10:22:18 +03:00
Roshan Shariff 4ea9a98f85
org-macs: Fix incorrect use of relative paths in org-compile-file
* org-macs.el (org-compile-file, org-compile-file-commands): Resolve
symlinks in default-directory before computing relative source path

Commit 5a8a1d4ff [1] changed org-compile-file to use
`file-relative-name` for the SOURCE argument.  This was intended to
fix bug [2] by expanding ~ directories, like a shell.  Unfortunately,
this breaks when DEFAULT-DIRECTORY is a symlink and SOURCE has an
absolute path.

For example, on macOS Ventura, ~/Dropbox is a symlink to
~/Library/CloudStorage/Dropbox.  Suppose DEFAULT-DIRECTORY is
/Users/username/Dropbox and SOURCE is /var/tmp/test.org, so its
relative path is ../../../var/tmp/test.org.  But the working directory
of a compilation process is actually ~/Library/CloudStorage/Dropbox,
relative to which the source path resolves to
/Users/username/var/tmp/test.org.  The process thus cannot find the
source file.

This commit changes `org-compile-file` and its helper function
`org-compile-file-commands` to resolve symlinks in DEFAULT-DIRECTORY
before computing the relative path of SOURCE.  If SOURCE is already
relative, it is used as-is.  The absolute path is processed by
`expand-file-name`, avoiding bug [1].

[1] https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5a8a1d4ff
[2] https://orgmode.org/list/25528.42190.53674.62381@gargle.gargle.HOWL

TINYCHANGE
2023-08-06 09:44:13 +03:00
Ihor Radchenko 8dfd8c987c
org-format-latex: Add FIXME
* lisp/org.el (org-format-latex): Mark `overlay-recenter' call for
removal after Emacs 28 support is dropped.
2023-08-05 16:14:25 +03:00
Ihor Radchenko 0a5dd8cf68
org-babel--file-desc: Update docstring
* lisp/ob-core.el (org-babel--file-desc): Describe all the argument in
the docstring and clarify what the function returns.
2023-08-05 15:09:59 +03:00
Ihor Radchenko 222fdf9c57
Merge branch 'bugfix' 2023-08-05 14:00:18 +03:00
Ihor Radchenko 87b4de9617
org-publish-resolve-external-link: Fix links to non-Org files
* lisp/ox-publish.el: Do not try to call `org-at-heading-p' when not
in Org file.  `org-at-heading-p' and `org-entry-get' may err unless
inside Org buffer.
2023-08-05 13:57:45 +03:00
Ihor Radchenko 453c47b57d
fixup! org-element--cache-for-removal: Fix changing heading granularity
* lisp/org-element.el:
(org-element--cache-for-removal): Explicitly assign :granularity to
not deceive parser when parsing for different granularity than cache.
Cache is always using 'element granularity.

This commit is only needed on bugfix.  On main, :granularity is set
correctly.
2023-08-05 11:14:26 +03:00
Ihor Radchenko 5e378a6e13
org-capture-template-contexts: Improve docstring
* lisp/org-capture.el (org-capture-templates-contexts): Clarify that
function context definition is not a cons cell using example.
2023-08-05 09:53:13 +03:00
Ihor Radchenko 8d6ec48b84
org-end-of-subtree: Fix when inside inlinetask
* lisp/org.el (org-end-of-subtree): Do not consider inlinetasks as
dedicated subtrees.
* testing/lisp/test-org.el (test-org/end-of-subtree): New test.
2023-08-05 09:48:10 +03:00
Bastien 73cb528c24 Merge branch 'bugfix' 2023-08-04 13:08:25 +02:00
Juan Manuel Macias 07f099f84e lisp/ox.el: Fix inner smart quotes in French
* (org-export-smart-quotes-alist): Add correct French second level
quotation marks.
2023-08-04 13:03:03 +02:00
Ihor Radchenko 8dc71d915e
lisp/ob-core.el: Fix some checkdoc warnings
* lisp/ob-core.el (org-babel-where-is-src-block-head): Quote
`match-data'.
(org-babel-insert-result): Ensure two spaces between sentences.
(org-babel-temp-file): Clarify that `temporary-file-directory' refers
to a function.
2023-08-04 11:33:33 +03:00
Ihor Radchenko 6eb117da06
* lisp/ob-core.el (org-babel--expand-body): Document all the arguments 2023-08-04 11:33:18 +03:00
Ihor Radchenko 4fb8ad9990
lisp/ob-core.el: Add some missing docstrings
* lisp/ob-core.el (org-babel-execute-safely-maybe):
(org-babel-execute-maybe):
(org-babel-active-location-p): Add docstrings.
2023-08-04 11:33:01 +03:00
Ihor Radchenko 47b04383e7
fixup! org-id-update-id-locations: Optimize performance
Avoid modifying FILES by side effect.
2023-08-04 10:54:19 +03:00
Ihor Radchenko 11ce194dcf
org-string-width: Fix Emacs <29 compatibility
* lisp/org-compat.el (org-buffer-text-pixel-width): New function using
`buffer-text-pixel-size' in Emacs >=29 and falling back to
`window-text-pixel-size' in older Emacs.
* lisp/org-macs.el (org-string-width): Use the new function.
2023-08-04 10:53:17 +03:00
Ihor Radchenko f5467b53ec
lisp/ob-shell.el: Fix sessions for generic "shell" blocks
* lisp/ob-shell.el (org-babel-prompt-command): Remove variable.
(org-babel-sh-initiate-session): Set prompt according to
`shell-file-name' - either the value set in let-binding provided by
`org-babel-shell-initialize' or using the default Emacs value of
`shell-file-name'.
(org-babel-shell-initialize): Do not set `org-babel-prompt-command'.
Only let-bind `shell-file-name' according to shell variant in src
block.
2023-08-04 09:30:47 +03:00
Ihor Radchenko 5ed2763b15
org-id-update-id-locations: Optimize performance
* lisp/org-id.el (org-id--locations-checksum): New internal variable
holding list of files and their modification times for the last known
ID list.
(org-id-update-id-locations): Do nothing when the ID locations
correspond to the same ID file list and modification times.  Convert
SEEN-IDS to hash table for faster lookup of the duplicates.  Re-enable
element cache.  Avoid queries to heading properties that would force
full parsing.
2023-08-03 16:52:04 +03:00
Ihor Radchenko b11894aa55
org-lint: Use markers instead of line number to track report positions
* lisp/org-lint.el (org-lint--generate-reports): Store marker to
reports as text property in the Line field.
(org-lint--current-marker): New function retrieving marker
corresponding to current report.
(org-lint--jump-to-source): Jump using marker, not line number.

This fixes *Org Lint* report jumping to wrong location when the Org
buffer is edited while going through the report.
2023-08-03 16:03:56 +03:00
Ihor Radchenko 8b9e3be9a9
* lisp/ob-comint.el (org-babel-comint-async-dangling): Fix docstring
Make first line a complete sentence.
2023-08-03 11:45:15 +03:00
Ihor Radchenko 2c4c5fdd8b
Merge branch 'bugfix' 2023-08-03 08:29:54 +03:00
Ihor Radchenko bf45090f4c
org-element--cache-for-removal: Fix changing heading granularity
* lisp/org-element.el (org-element--cache-for-removal): Do not update
heading using object granularity.  `org-element-at-point' parses
headings without :title objects and cache updates should not change
this.
2023-08-03 08:28:01 +03:00
Ihor Radchenko 63e8cac2ca
org-goto-sibling: Fix when called from inlinetask
* lisp/org.el (org-goto-sibling): Do not try to find inlinetask
siblings.  Clarify the docstring.
* testing/lisp/test-org.el (test-org/goto-sibling): New test.
2023-08-02 16:06:02 +03:00
Ihor Radchenko 345d4e09b5
org-insert-drawer: Make sure that point is left inside drawer
* lisp/org.el (org-insert-drawer): Leave and reveal point inside
drawer even when we insert property drawer or drawer around region, as
advertised by the docstring.
2023-08-02 15:42:53 +03:00
Ihor Radchenko 83575624ab
Ensure that clocking drawer is inserted before point
* lisp/org-clock.el (org-clock-find-position): Insert before point
when creating drawers.  This makes sure that newly inserted drawer do
not interfere with user typing.  See f993ecd67.
* lisp/org-clock.el (org-clock-in): Add commentary.
2023-08-02 15:23:06 +03:00
Ihor Radchenko 28b6a231e9
org-element-normalize-contents: Fix when ELEMENT is anonymous
* lisp/org-element.el (org-element-normalize-contents): Use
`org-element-set-contents' to set contents instead of assuming
(TYPE PROP CONTENTS) structure.
2023-08-02 12:04:30 +03:00
Ihor Radchenko 8e2f6d94e9
ob-C: Fix docstrings
* lisp/ob-C.el (org-babel-execute:cpp):
(org-babel-expand-body:cpp):
(org-babel-execute:C++):
(org-babel-expand-body:C++):
(org-babel-execute:D):
(org-babel-expand-body:D):
(org-babel-execute:C):
(org-babel-expand-body:C):
(org-babel-C-execute):
(org-babel-C-expand-C++):
(org-babel-C-expand-C):
(org-babel-C-expand-D):
(org-babel-C-val-to-base-type):
(org-babel-C-var-to-C): Mention all the arguments.
(org-babel-prep-session:C):
(org-babel-load-session:C): Make first line a proper short description
consisting of a single sentence.
2023-08-02 10:42:39 +03:00
Ihor Radchenko 7b80334fda
org-lint-timestamp-syntax: Improve lint message
* lisp/org-lint.el (org-lint-timestamp-syntax): Mention the original
timestamp in the link message.

Reported-by: Fraga, Eric <e.fraga@ucl.ac.uk>
Link: https://orgmode.org/list/87y1iuyb3m.fsf@ucl.ac.uk
2023-08-02 09:31:44 +03:00
Ihor Radchenko 20d90b9790
org-lint-export-option-keywords: Improve message and ignore `org-default-properties'
* lisp/org-lint.el (org-lint-export-option-keywords): Mention which
backends the suspicious properties may belong to.  Avoid triggering on
`org-default-properties'.

Reported-by: Fraga, Eric <e.fraga@ucl.ac.uk>
Link: https://orgmode.org/list/87y1iuyb3m.fsf@ucl.ac.uk
2023-08-02 09:31:21 +03:00
Ihor Radchenko f9d2d92f42
Merge branch 'bugfix' 2023-08-02 08:18:15 +03:00
Ihor Radchenko 6c1ff952fe
Make transient overlay lists permanent-local
* lisp/org-clock.el (org-clock-overlays):
* lisp/org-colview.el (org-columns-overlays):
* lisp/org-num.el (org-num--overlays):
* lisp/org-table.el (org-table-header-overlay):
(org-table-coordinate-overlays):
* lisp/org.el (org-custom-properties-overlays):
(org-occur-highlights):
(org-inline-image-overlays): Mark as permanent-local to not lose track
of the overlays when changing major modes.

Reported-by: Eli Qian <eli.q.qian@gmail.com>
Link: https://orgmode.org/list/871qgmeleu.fsf@gmail.com
2023-08-02 08:16:47 +03:00
Ihor Radchenko 8aa6e8125d
lisp/ob-cal.el: Fix docstrings
* lisp/ob-calc.el (org-babel-execute:calc): Mention all the args.
(org-babel-calc-maybe-resolve-var): Add docstring.
2023-08-02 08:05:29 +03:00
Ihor Radchenko 323a669921
org-string-width: Remove unnecessary dedicated window check
* lisp/org-macs.el (org-string-width): Do not handle dedicated
selected window specially.  The bug fixed by 946abeb49 is no
longer reproducible using the release version of Emacs 29 and other
Emacs versions.  Apparently, it was caused by now-fixed Emacs bug
specific to Emacs 29.

Also, use `buffer-text-pixel-size' as in `string-pixel-width' from
Emacs master.  Using `window-text-pixel-size' requires setting buffer
to window, which is tricky when selected window is dedicated (see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64986).
2023-08-02 08:04:56 +03:00
Ihor Radchenko 884b84f7ad
org-string-width: Adapt Emacs commit 0c29f53ab8723
* lisp/org-macs.el (org-string-width): Make sure that default values
of `line-prefix' and `wrap-prefix' do not affect width calculation.

Link: https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29&id=0c29f53ab8723dd5a9f31ce8a6e913cc08132e56
2023-08-01 10:06:01 +03:00
Ihor Radchenko f03b839530
lisp/ob-awk.el: Fix docstrings
* lisp/ob-awk.el (org-babel-execute:awk):
* lisp/ob-awk.el (org-babel-awk-var-to-awk): Detail all the argument
in the docstring.
2023-07-31 14:17:22 +03:00
Ihor Radchenko f409cb4e52
ox: New option `org-export-expand-links'
* lisp/ox.el (org-export-options-alist): New export option toggling
environment variable expansion in link paths.
(org-export-expand-links): New customization.
(org-export--expand-links): New function expanding environment
variables all the link paths in AST.
(org-export-expand-include-keyword):
(org-export--blindly-expand-include): Add new optional arguments to
expand environment variables in INCLUDE file paths.  Update
docstrings.
(org-export--annotate-info): Call `org-export--expand-links' during
export and pass :expand-links parameter to
`org-export-expand-include-keyword'.
* doc/org-manual.org (Export Settings): Document the new option.
* etc/ORG-NEWS (New export option ~org-export-expand-links~): Announce
new option.

Link: https://list.orgmode.org/orgmode/87pm6fbnlo.fsf@localhost/
2023-07-31 11:24:40 +03:00
Ihor Radchenko 68ba286fee
org-lint-link-to-local-file: Expand environment variables in path
* lisp/org-lint.el (org-lint-link-to-local-file): Try to expand
environment variables in file paths before testing if the linked file
exists.
2023-07-31 11:20:26 +03:00
Kyle Meyer d3f587fadf org-find-open-clocks: Fix recent bug in handling of match data
* lisp/org-clock.el (org-find-open-clocks): Prevent clock match data
from being clobbered by downstream org-element-at-point call.
2023-07-30 17:56:54 -04:00
Jens Schmidt eabc9bfecf
ol-gnus.el: Fix issue when storing links from Gnus article buffers
* lisp/ol-gnus.el (org-gnus-store-link): Switch to
`gnus-summary-buffer' when calling functions that are intended to be
called only there.

Link: https://list.orgmode.org/orgmode/2fa5914d-2cbf-f41f-8be6-e79e77794140@vodafonemail.de
2023-07-30 19:31:58 +03:00
Ihor Radchenko a6f3b24a67
Merge branch 'bugfix' 2023-07-30 12:30:40 +03:00
Ihor Radchenko d1d0c30e65
org-property-value: Define face as non-nil
* lisp/org-faces.el (org-property-value): Set default value to inherit
from `font-lock-string-face' instead of using invalid face value of
nil.

Reported-by: Mauro Aranda <maurooaranda@gmail.com>
Link: https://orgmode.org/list/41956a5a-44c2-c1ea-e1e5-d018a8656e48@gmail.com
2023-07-30 12:29:17 +03:00
Ihor Radchenko dd586c5f42
* lisp/org-macs.el (org-time-convert-to-list): Provide declaration
Update obsolete declaration using the function that is used now.
This fixes native-comp warning.
2023-07-30 12:27:21 +03:00
Ihor Radchenko 01bf57488c
lisp/org.el: Define `org-rear-nonsticky-at' defsubst before its first usage
This fixes compiler warning.
2023-07-30 12:26:49 +03:00
Ihor Radchenko d5006e195a
Merge branch 'bugfix' 2023-07-30 12:22:09 +03:00
Ihor Radchenko da1bc002f2
Backport Emacs commit 670174a6d5f
* lisp/org-macs.el (org-replace-escapes): Suppress byte-compiler
warning about modifying constant string.

Unlike, 39786a8dbf, this commit does not
create merge conflicts.
2023-07-30 12:21:37 +03:00
Ihor Radchenko d38ca59230
ob-gnuplot: Fix links and verbatim when converting tables
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Use custom
backend to export table data.  The backend will export links verbatim,
without trying to resolve them and drop verbatim markers from data
fields.

Reported-by: Paul Stansell <paulstansell@gmail.com>
Link: https://orgmode.org/list/CAMJKaZzHuLxPoTg6FWUgt-U8QSHmuB3Kdqmk_E_0GH+jUZMSag@mail.gmail.com
2023-07-29 11:26:39 +03:00
Ihor Radchenko 2452f5de6d
org-export-get-all-transcoders: Fix when :parent is not symbol
* lisp/ox.el (org-export-get-all-transcoders): Handle :parent backend
not being symbol.
2023-07-29 11:26:03 +03:00
Ihor Radchenko de9f89e4be
org-babel-execute-src-block: Fix with :cache yes :results append/prepend
* lisp/ob-core.el (org-babel-execute-src-block): Do not remove
previous result when :cache is yes, but :results requests
appending/prepending the new result.
2023-07-28 12:11:31 +03:00
Evgenii Klimov 3ee10d57f1
ob-tangle.el: Avoid relative file names when grouping blocks to tangle
* lisp/ob-tangle.el (org-babel-tangle-single-block,
org-babel-tangle-collect-blocks): Make target file name attribute,
used internally to group blocks with identical language, to be
absolute.
(org-babel-effective-tangled-filename): Avoid using relative file
names that could cause one block to overwrite the others in
`org-babel-tangle-collect-blocks' if they have the same target file
but in different formats.
2023-07-28 10:16:36 +03:00
Ihor Radchenko dc78f09465
org-up-heading-safe: Fix when parent is not a heading
* lisp/org.el (org-up-heading-safe): Do not assume that
`org-element-parent' is always a heading.  Use `org-element-lineage'
to get parent heading specifically.  Move point to current heading
even when no parent heading is available, as expected by some of the
other Org routines.  Document moving point when no parent.
* testing/lisp/test-org.el (test-org/up-heading-safe): Add tests.

Reported-by: Daniel Liden <djliden91@gmail.com>
Link: https://orgmode.org/list/CAG=u__pAT9k_AsRG6cpyPPUt0__5S7o=3a8WWkAijuPPuGc7Cg@mail.gmail.com
2023-07-26 11:01:34 +03:00
Ihor Radchenko ac0042184e
org-bibtex-headline-format-function: Factor out lambda default value
* lisp/ol-bibtex.el (org-bibtex-headline-format-default): New function
to be used as the default value of
`org-bibtex-headline-format-function'.
(org-bibtex-headline-format-function): Update the default value.

Link: https://orgmode.org/list/87edl71tyu.fsf@localhost
2023-07-25 13:50:09 +03:00
Ihor Radchenko 39de4a1848
org-babel-sh-evaluate: Fix edge case when :shebang is set and :dir is remote
* lisp/ob-shell.el (org-babel-sh-evaluate): Pass remote local file
name as command when executing script with :shebang.  `org-babel-eval'
will fail when SCRIPT-FILE is TRAMP file name.

Link: https://www.reddit.com/r/orgmode/comments/14zh2yi/orgbabel_shebang_not_working_on_with_tramp_dir/
2023-07-23 17:38:09 +03:00
Ihor Radchenko ef391c882c
org-babel--shell-command-on-region: Remove obsolete workaround
* lisp/ob-eval.el (org-babel--shell-command-on-region): Remove
workaround for ancient Emacs version < minimal supported Emacs 26.
2023-07-23 17:35:44 +03:00
Ihor Radchenko 36c254ae30
org-lint: Add checkers for square brackets inside link description
* lisp/org-lint.el (org-lint-confusing-brackets):
(org-lint-brackets-inside-description):
(trailing-bracket-after-link):
(unclosed-brackets-in-link-description): New checkers testing for
trailing extra "]" after links and for unmatched opening "[" inside
link description.
2023-07-21 12:36:47 +03:00
Ihor Radchenko 6a2d84e501
ob-lilypond: Resolve FIXME
* lisp/ob-lilypond.el: Use `org-src-lang-modes' to inform Org babel
about non-standard mode name instead of using `defalias'.
* testing/lisp/test-ob-lilypond.el (ob-lilypond/check-lilypond-alias):
Remove test.
2023-07-20 10:02:07 +03:00
Ihor Radchenko 724135ddaf
fixup! org-do-emphasis-faces: Make sure that 'invisible property is not sticky 2023-07-19 10:05:30 +03:00
Ihor Radchenko 3e3b873d3f
org-do-emphasis-faces: Make sure that 'invisible property is not sticky
* lisp/org.el (org-do-emphasis-faces): Mark invisible text property in
emphasis markers non-sticky.  This is usually not a problem as we
manage invisible text property via font-lock.  However subtle bugs may
exist with non-interactive calls to Elisp primitives that inherit text
properties (like `indent-to').

Reported-by: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Link: https://orgmode.org/list/8b691a7f-6b62-d573-e5a8-80fac3dc9bc6@vodafonemail.de
2023-07-18 11:10:46 +03:00
Ihor Radchenko 5b6268c29e
org-columns--truncate-below-width: Fix Emacs 27 compatibility
* lisp/org-colview.el (org-columns--truncate-below-width): Do not use
extra optional arguments that are only available since Emacs 28.
2023-07-17 12:57:35 +03:00
Ihor Radchenko 3007511f3f
org-string-width: Reuse buffer when calculating string width
* lisp/org-macs.el (org-string-width): Use dedicated buffer instead of
creating a new one every time.  The idea is from `string-pixel-width'.
2023-07-17 12:33:03 +03:00
Ihor Radchenko c730caf512
org-babel-result-to-file: Fix when in indirect buffer
* lisp/ob-core.el (org-babel-result-to-file): Consider file name in
base buffer when calculating base directory.

Reported-by: 赵一宇 <zhyznd@163.com>
Link: https://list.orgmode.org/orgmode/3d69c850.69db.18953ae45da.Coremail.zhyznd@163.com/
2023-07-17 12:04:05 +03:00
Ruijie Yu 8739a95782
Let org-columns correctly detect string-widths in code
TODO: maybe I should also make a test directly on
`org-columns-add-ellipses'.  Will do in next iteration unless
objections.

* lisp/org-colview.el (org-columns--truncate-below-width): add a
helper function that will trim off just enough data from string to
fit into expected width.
(org-columns-add-ellipses): make sure to do truncation correctly
even in CJK locales (where an ellipsis character takes two
spaces).

* testing/lisp/test-org-colview.el
(test-org-colview/substring-below-width): add test to make sure
helper function is correct.
(test-org-colview/columns-width): fix incorrect expectations for
CJK locales about ellipses.
2023-07-17 11:06:32 +03:00
Ihor Radchenko c0dbcf361e
org-store-link: Move already stored link to front by default
* lisp/ol.el (org-link-store-existing): New customization controlling
how to deal with already stored links.
(org-store-link): Respect the new customization, allowing duplicates
to (1) be added anyway; (2) be ignored; (3) be moved to front of
`org-stored-links'.  The default is (3).
* etc/ORG-NEWS (~org-store-link~ now moves an already stored link to
front of the ~org-stored-links~): Document the breaking change.

Reported-by: Samuel Wales <samologist@gmail.com>
Link: https://list.orgmode.org/orgmode/CAJcAo8sjD3_FX5pFQ4git9wRDNM3bMqTgP-R5mM8zcf1B3mjPg@mail.gmail.com/
2023-07-15 15:31:41 +03:00
Liu Hui 5e31dcdd9a ob-python: Fix async evaluation
* lisp/ob-python.el (org-babel-python-async-evaluate-session): Bind
`python-shell-buffer-name' inside the temp buffer.
* testing/lisp/test-ob-python.el (test-ob-python/async-local-python-shell):
Add test.
2023-07-13 17:24:41 -07:00
Ihor Radchenko c9b80f06d4
org-fold-core-next-folding-state-change: Optimize performance
* lisp/org-fold-core.el (org-fold-core-next-folding-state-change):
Avoid repetitive searches all to way to LIMIT.  Instead, limit the
next searches by the limit computer by previous.
2023-07-13 19:32:49 +03:00
Ihor Radchenko 17096b3f4c
Refactor `org-src--contents-for-write-back'
* lisp/org-src.el (org-src--contents-for-write-back-1): New function
that is passed indentation parameters and contents explicitly, without
relying on buffer-local variables in current buffer.  The function
extracts variable-independent code and removes unused MARKER.
(org-src--contents-for-write-back): Use the new function, passing the
parameters according to buffer-local values in src edit buffer.
2023-07-13 12:28:13 +03:00
Ihor Radchenko 1967aa43e5
org-src-preserve-indentation: Refactor handling src block flags
* lisp/org-src.el (org-src-preserve-indentation-p): New function
checking whether block should preserve indentation.  This function
abstracts away the check for block type, indentation flag, and
customized `org-src-preserve-indentation' value.
(org-src--edit-element):
* lisp/ob-core.el (org-babel--normalize-body):
(org-babel-read-element):
(org-babel-update-block-body):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/org-element.el (org-element-example-block-interpreter):
(org-element-src-block-interpreter):
* lisp/org.el (org-fixup-indentation):
(org-indent-region):
* lisp/ox.el (org-export-unravel-code): Use the new function instead
of duplicating code.

* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Add FIXME.  We
do not have access to the block element here and cannot easily check
the flag.

* lisp/ob-tangle.el (org-babel-tangle-single-block):
* lisp/org-src.el (org-src-font-lock-fontify-block):
* lisp/org.el (org-indent-line): Check block flag in addition to `org-src-preserve-indentation'.

This commit unifies logic deciding whether to preserve block
indentation into a single place to avoid confusion.
2023-07-13 11:51:15 +03:00
Ilya Chernyshov c74c4ab18d
lisp/org-element.el: Add new timestamp property :range-type
The new property is needed to reduce ambiguity when interpreting the
parsed data.

* lisp/org-element.el (org-element-timestamp-interpreter): Preserve old
behavior when :range-type is `nil'.  Take into account :range-type
value when interpreting ranges.  When :range-type is `timerange',
return a timerange (<YYYY-mm-DD HH:MM-HH:MM>).  If :range-type is
`daterange' return a daterange (<...>--<...>).  When :range-type is
nil, return a daterange (as it was before).  When :range-type is
`daterange' or `timerange' and :type is `active'/`inactive', throw an
error.
(org-element-timestamp-parser): Add :range-type property.

* lisp/org.el (org-timestamp-split-range): Make sure that :range-type
is nil for a split timestamp.

* testing/lisp/test-org-element.el
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add tests for :range-type
property.

* etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property.

Link: https://list.orgmode.org/orgmode/87y1ot6dqz.fsf@gmail.com/
2023-07-12 11:12:46 +03:00
Ihor Radchenko 0b6f9f8677
Fix typo in `org-todo-log-states' variable name
* doc/org-manual.org (Priorities):
* lisp/org.el (org-update-parent-todo-statistics): Fix incorrect
spelling of `org-todo-log-states' variable.

Reported-by: Evgenii Klimov <eugene.dev@lipklim.org>
Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://list.orgmode.org/orgmode/e900a08d-11af-9106-423e-28a2befe813d@gmail.com/
2023-07-11 12:06:52 +03:00
Akira Kyle 8fa7f0279e
org-html-link: Fix relative links with :html-link-use-abs-url
* lisp/ox-html.el (org-html-link): When publishing relative links with
both :html-link-use-abs-url and :html-link-home, ensure the correct
link is constructed.  Never append `home' to absolute paths.

TINYCHANGE
2023-07-10 11:16:32 +03:00
Max Nikulin 879ba22ef6
org-compat.el: `org--flatten-tree' for Emacs-26 compatibility
* lisp/org-compat.el (org--flatten-tree): New internal compatibility
alias or function based on `flatten-tree' added to Emacs-27.1.
* lisp/org-protocol.el (org-protocol-flatten): Convert to an obsolete
function alias.
(org-protocol-flatten-greedy): Use the `org--flatten-tree' new
compatibility alias or function instead of `org-protocol-flatten'.
* lisp/org-src.el (org-src--get-known-shells): Make the function
compatible with Emacs-26 by using `org--flatten-tree' instead of
`flatten-tree'.

Reported as: Justin to emacs-orgmode. [PATCH] org-src: flatten-tree is
Emacs 27.1; require compat. Tue, 4 Jul 2023 19:21:05 -0400.
https://list.orgmode.org/0288575b-fde8-0e7d-ac74-1f0ac93ce56f@vallon.homeip.net
2023-07-08 12:09:25 +03:00
Max Nikulin caa27be102
org-element.el: Fix Emacs-26 compatibility
* org-element.el (org-element--current-element-re): Use `rx-to-string'
instead of `rx' to expand variables.
(org-element--cache-setup-change-functions): Avoid multiple variables in
`setq-local'.

Reported as: Justin to emacs-orgmode. [BUG] org-element loading fails
with "regexp" argument not "stringp" Tue, 4 Jul 2023 19:51:44 -0400.
https://list.orgmode.org/2ff109c7-b3ec-27ac-e75d-ae5ddac14746@vallon.homeip.net
2023-07-08 12:09:24 +03:00
Sébastien Miquel 2e2ed40553
org-src.el: Use native value of `indent-tabs-mode' for indentation
* lisp/org.el (org-indent-line): Simplify native indentation inside
src block.  Ensure we add the org indentation if the line is empty.
* lisp/org-macs.el (org-do-remove-indentation): Preserve
indentation (spaces vs tabs) past the common indentation to remove.
Do not empty blank lines.
* lisp/org-src.el (org-src--contents-for-write-back): Preserve the
native indentation (spaces vs tabs).  If necessary, add a common org
indentation to the block according to org's `indent-tabs-mode'.
(org-src-font-lock-fontify-block): Display the native indentation tab
characters with a fixed width, according to the native tab width
value, to preserve vertical alignement in the org buffer.
* testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update
tests.  Indentation no longer obeys `indent-tabs-mode' from the org
buffer, but is separated in an eventual org part, and the native part.

Link: https://list.orgmode.org/87a5wcez7e.fsf@localhost/T/#t
2023-07-07 11:58:43 +03:00
Ihor Radchenko 7c6302e203
org-agenda-show-new-time: Fix when window is very narrow
* lisp/org-agenda.el (org-agenda-show-new-time): When window is
narrower than timestamp, do not try to display timestamps starting at
negative column.

Reported-by: Nick Römer <nick.romer@skynet.be>
Link: https://orgmode.org/list/4196e86e.19136.1891ceef131.Webtop.154@skynet.be
2023-07-05 16:12:19 +03:00
Evgenii Klimov 402f72ad4f
lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands
* lisp/org.el (org-metaleft-final-hook, org-metaright-final-hook,
org-metaup-final-hook, org-metadown-final-hook): Define final hooks
for S-cursor commands.
(org-metaleft, org-metaright, org-metaup, org-metadown): Add final
hooks to M-commands and document them in the docstring.

* lisp/org.el (org-shiftup, org-shiftdown, org-shiftright,
org-shiftleft): Document hooks for S-cursor commands in the docstring.

* lisp/org.el (org-shiftmetaleft-final-hook,
org-shiftmetaright-final-hook, org-shiftmetaup-final-hook,
org-shiftmetadown-final-hook): Define final hooks for the S-M-cursor
commands.
(org-shiftmetaleft, org-shiftmetaright, org-shiftmetaup,
org-shiftmetadown): Add final hooks to the S-M-cursor commands and
document hooks in the docstring.

* etc/ORG-NEWS (New final hooks for Modifier-Cursor keys): Document
new hooks.

TINYCHANGE
2023-07-05 13:40:19 +03:00
Justin Vallon f18fad60b6
org-id-uuid: Use compat org-time-convert-to-list for emacs <27.1
* lisp/org-macs.el (org-id-uuid): Use `org-time-convert-to-list'
instead of `time-convert', which is not yet available in Emacs 26.
2023-07-05 13:28:38 +03:00
Evgenii Klimov 48fffa5dac
org-insert-link: Keep the link in `org-stored-links' if it was not inserted
* lisp/ol.el (org-insert-link): Keep the link in `org-stored-links' if
the command was interrupted by the user during the reading of a
description from the minibuffer.

TINYCHANGE
2023-07-04 13:43:21 +03:00
Ihor Radchenko e34b72eec6
org-make-tags-matcher: Do not try collecting tags from non-Org buffers
* lisp/org.el (org-make-tags-matcher): When building tag completion
table, do not attempt to call `org-get-buffer-tags' when current
buffer is not an Org buffer.

Reported-by: Colin Baxter <m43cap@yandex.com>
Link: https://orgmode.org/list/87ilb1fakk.fsf@yandex.com
2023-07-03 15:28:08 +03:00
Ihor Radchenko 38f87aa30a
Update Ihor Radchenko's email address
* lisp/ob-gnuplot.el:
* lisp/org-cycle.el:
* lisp/org-element-ast.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-persist.el: Update contact email of the maintainer/author.
2023-07-03 11:08:49 +03:00
Ihor Radchenko 02ad2a114f
lisp/org-element-ast.el: Fix copyright notice
Make copyright consistent with the rest of Org.
2023-07-03 11:06:55 +03:00
Ihor Radchenko 948c896448
Rename org-element-property-1' to org-element-property-raw'
The new name is more readable.

Link: https://orgmode.org/list/87sfail69e.fsf@localhost
2023-07-01 14:36:32 +03:00
Ihor Radchenko 66c8e94732
lisp/org-element-ast.el: Fix typo in commentary 2023-07-01 14:36:31 +03:00
Ihor Radchenko f97aeaa243
org-fold-core--isearch-setup: Use `add-function'
* lisp/org-fold-core.el (org-fold-core--isearch-setup): Use
add-function, respecting the value of `isearch-filter-predicate'.
(org-fold-core--isearch-filter-predicate-overlays): Remove.

Link: https://yhetil.org/emacs-devel/87o7lxpip9.fsf@web.de
2023-07-01 14:36:31 +03:00
Ihor Radchenko 7f337a2b95
org-fold-core: Fix isearch with `org-fold-core-isearch-open-function'
* lisp/org-fold-core.el (org-fold-core--with-isearch-active): New
macro, signaling `org-fold-core-region' to store newly created folds
in `org-fold-core--isearch-overlays'.
(org-fold-core-region): Respect the new macro.  Respect fold priority
for overlays.
(org-fold-core--isearch-setup): Do not run
`org-fold-core--clear-isearch-overlays' twice.
(org-fold-core--isearch-show): Fix when point is not on the match.
(org-fold-core--isearch-show-temporary): Rewrite, limiting to overlays
only and simplifying the code.
(org-fold-core--create-isearch-overlays): Extend link folds to full
link.
(org-fold-core--clear-isearch-overlay): Do not expect to be called in `isearch-mode-end-hook'.
* lisp/org-fold.el (org-fold--isearch-reveal): Respect argument.
2023-07-01 14:36:30 +03:00