Commit graph

25579 commits

Author SHA1 Message Date
Ihor Radchenko e73c5b7d0d
Fix Emacs 29 compiler warnings
* lisp/oc-basic.el (org-cite-basic--parse-bibliography): Do not use
obsolete `buffer-file-name' generalized variable.  Prefer
`set-visited-file-name'.
* lisp/ol-bibtex.el (org-indent-region): Declare function.
(org-bibtex-import-from-file): Remove unused variable.
* lisp/ol.el (org-link--decode-compound): Use `ash' instead of
obsolete `lsh'.
* lisp/org-macs.el: Do no use obsolete generalized variable
`buffer-string'.
* lisp/org-plot.el (org-plot/redisplay-img-in-buffer):
* lisp/org.el (image-flush):
(org-display-inline-images): Use `image-flush' instead of obsolete
`image-refresh'.
* lisp/ox.el (org-export-to-file): Quote ' in the docstring.

All other changes are changing obsolete `point-at-bol' and
`point-at-eol' to `line-beginning-position' and `line-end-position'.
2022-09-06 20:50:59 +08:00
Ihor Radchenko 0c055d2d31
org-compat: Add forward-compatibility for argument changes in adviced functions
* lisp/org-compat.el (outline-flag-region):
(outline-next-visible-heading):
(outline-back-to-heading):
(outline-on-heading-p):
(outline-hide-sublevels):
(outline-toggle-children): Accept arbitrary extra arguments and pass
them to original function if its arglist changes in future.

This patch is following the "no-breakage" policy:
>> I won't break your user experience.
https://bzg.fr/en/the-software-maintainers-pledge/
2022-09-06 20:14:23 +08:00
Ihor Radchenko a3788bd8be
org-scan-tags: Fix messed match groups in eeb4fa8c0
* lisp/org.el (org-scan-tags): Match space after TODO keyword outside
group and match the TODO-keyword in its own group.
2022-09-05 18:50:52 +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
Ihor Radchenko eeb4fa8c09
org-scan-tags: Fixup a1c923afd
* lisp/org.el: Drop missed 'words argument to `regexp-opt'.
2022-09-05 18:14:05 +08:00
Max Nikulin 76a5f30034
ol-info: Use org function instead of subr-x
* lisp/org-macs.el (org-unbracket-string): Handle empty suffix string.
* lisp/ol-info.el (org-info--link-file-node):
(org-info-description-as-command): Use `org-trim' and
`org-unbracket-string' instead of `string-trim' and
`string-remove-prefix' from the subr-x package.
2022-09-05 14:33:32 +08:00
Max Nikulin 1b647b00d0
ORG-NEWS: `org-info-description-as-command'
* etc/ORG-NEWS: Mention that `org-info' uses `:insert-description',
a new feature of `org-link-parameters'.
2022-09-05 14:33:27 +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
Ihor Radchenko 7811fc5925
org-compat: Fix incorrect usage of `apply' in ea665792b
* lisp/org-compat.el:
(outline-next-visible-heading):
(outline-back-to-heading):
(outline-on-heading-p):
(outline-hide-sublevels):
(outline-toggle-children): Use `funcall' instead of `apply'.  The
former does not expect the last argument to be a list of arguments.
2022-09-04 12:41:01 +08:00
Ihor Radchenko e81a094383
Assert all the Org files to load the same Org version
* lisp/org-compat.el (org-assert-version): New macro comparing Org
version at compile time and laod time.

Add `org-assert-version' call to all files:

* lisp/org-macs.el:
* lisp/org-crypt.el:
* lisp/org-ctags.el:
* lisp/org-cycle.el:
* lisp/org-datetree.el:
* lisp/org-duration.el:
* lisp/org-element.el (avl-tree):
* lisp/org-entities.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-footnote.el:
* lisp/org-goto.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-keys.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-macro.el:
* lisp/org-mobile.el:
* lisp/org-mouse.el:
* lisp/org-num.el:
* lisp/org-pcomplete.el:
* lisp/org-persist.el:
* lisp/org-plot.el:
* lisp/org-protocol.el:
* lisp/org-refile.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-tempo.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-beamer.el:
* lisp/ox-html.el:
* lisp/ox-icalendar.el:
* lisp/ox-koma-letter.el:
* lisp/ox-latex.el:
* lisp/ox-man.el:
* lisp/ox-md.el:
* lisp/ox-odt.el:
* lisp/ox-org.el:
* lisp/ox-publish.el:
* lisp/ox-texinfo.el:
* lisp/ox.el:
2022-09-04 12:24:55 +08:00
Ihor Radchenko 1f1d8f909a
org-element-cache-map: Do not disable GC
* lisp/org-element.el: Do not disable GC.  This can make Emacs hang in
some particularly bad scenarios.  It is better to lose on performance
a bit compared to Emacs GC hanging.

The edge case is described in https://github.com/emacs-citar/citar/issues/397#issuecomment-1236226809
2022-09-04 10:01:03 +08:00
Bastien dc102f509a Merge branch 'bugfix' 2022-09-03 21:00:12 +02:00
Bastien 8ef6205a56 lisp/org.el: Bump version to 9.5.5 2022-09-03 20:54:27 +02:00
Ihor Radchenko a1c923afda
org-scan-tags: Allow arbitrary character classes in todo keywords
* lisp/org.el (org-scan-tags): Do not assume that todo keywords are
words.

Fixes https://orgmode.org/list/C5370FC1-ABBB-4FA1-8364-5B1DF0FB4755@irq0.org
2022-09-03 16:12:22 +08:00
Ihor Radchenko ea665792b2
org-compat: Use define-advice' instead of defadvice'
* lisp/org-compat.el (outline-flag-region):
(outline-next-visible-heading):
(outline-back-to-heading):
(outline-on-heading-p):
(outline-hide-sublevels):
(outline-toggle-children): Use `define-advice', remove redundant
interactive specs, and use `derived-mode-p' instead of `eq'
`major-mode'.

Suggested by Stefan Monnier.
2022-09-03 16:07:48 +08:00
Rudolf Adamkovič 710b6ca70e
Fix under-documented MathJax indentation option
* lisp/org/ox-html.el (org-html-mathjax-options): Add an example of a
valid value for the 'indent' MathJax option the docstring.
2022-09-02 20:43:40 +08:00
Rudolf Adamkovič 74d1a8c758
Fix incorrectly documented auto-numbering of MathJax equations
* lisp/org/ox-html.el (org-html-mathjax-options): Fix incorrect
choices for the 'autonumber' MathJax option in the docstring.
2022-09-02 20:43:40 +08:00
Ihor Radchenko e36c3cc21b
org-babel-sh-evaluate: Do not issue string :results value
* lisp/ob-shell.el (org-babel-sh-evaluate): Do not assume that
:results value always yields string value.  Avoid error when results
is nil.
2022-09-01 23:08:55 +08:00
Ihor Radchenko 5bb699e0fd
org-babel-insert-result: Do not err when inline src block returns nil
* lisp/ob-core.el (org-babel-insert-result): Do not throw error when
src block returns nil or "".

Originally reported in
https://reddit.com/r/orgmode/comments/wy78gi/inline_noweb_or_some_way_to_use_src_block_results/imiw1b0/
2022-09-01 21:16:50 +08:00
Ihor Radchenko 09406b1c98
org-macs: Make sure that fontification does not move point
* lisp/org-macs.el (org-looking-at-fontified):
(org-buffer-substring-fontified): Wrap fontification call into
`save-excursion' for safety.
2022-09-01 21:16:50 +08:00
Bastien f3f60e4ddb lisp/oc-csl.el: Add András Simonyi as the maintainer 2022-09-01 09:41:13 +02:00
Bastien ceac15c759 lisp/ob-processing.el: Add Jarmo Hurri as maintainer 2022-09-01 09:39:56 +02: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
Ihor Radchenko 06373a6438
ob-python: Fix Emacs bug#50514 when Python loads slowly
* lisp/ob-python.el (org-babel-python-initiate-session-by-key): Do not
rely on 10ms delay to initialize Python.  Wait until python process is
initialized using `org-babel-comint-wait-for-output'.
2022-08-28 09:27:24 +08:00
Ihor Radchenko 5ba90e161b
org-bibtex-import-from-file: Improve performance
* lisp/ol-bibtex.el (org-bibtex-put): Add new optional argument to
insert node property at point directly, without leveraging
`org-set-property'.  Add docstring.
(org-bibtex-write): Insert headline properties directly.  Add new
optional argument to suppress indentation.  Do not use `length' to
check if `org-bibtex-entries' list empty---`length' is too slow on
large lists.
(org-bibtex-import-from-file): Postpone indentation after all the
entries are imported.
* lisp/org.el (org-indent-region): Use cache.
2022-08-27 12:09:31 +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
Rohit Patnaik b7f4afe86c
lisp/ox-md.el: Add top level header setting
* lisp/ox-md.el (defcustom org-md-toplevel-hlevel): Define the customizable
variable that defines the top level heading to use when exporting to markdown.
(org-export-define-derived-backend): Read the value of the new
`org-md-toplevel-hlevel' variable into the `:options-alist' for this backend
(org-md--build-toc): Use the newly defined top-level heading setting to control
the heading level for the "Table of Contents" text.
(org-md-headline): Use the newly defined top-level heading setting as an offset
to the heading level calculated by `org-export-get-relative-level'.

This patch adds a new setting: `org-md-toplevel-hlevel' that controls which
Markdown heading level is used for top level headings.  This change makes
markdown export more like HTML export, which has a `org-html-toplevel-hlevel'
variable which does the same thing for HTML export.

TINYCHANGE
2022-08-26 21:00:28 +08:00
Ihor Radchenko a35d163685
ob-shell: Fix output containing strings matching `comint-prompt-regexp'
* lisp/ob-comint.el (org-babel-comint-wait-for-output): Do not rely on
`face-at-point' returning non-nil.
* lisp/ob-shell.el (org-babel-shell-set-prompt-commands): New constant
holding shell-specific commands to change prompt.
(org-babel-prompt-command): New variable holding command to be user to
set distinguishable prompt.
(org-babel-shell-initialize): Set `org-babel-prompt-command' according
to shell name.
(org-babel-sh-prompt): New variable holding default shell prompt.
(org-babel-sh-initiate-session): Change the default prompt to
`org-babel-sh-prompt' and alter `comint-prompt-regexp' to match it
tightly.

Fixes https://list.orgmode.org/CKK9TULBP2BG.2UITT31YJV03J@laptop/T/#mc8e3ca2f5f1b9a94040a68b4c6201234b209041c
2022-08-26 20:47:13 +08:00
Ihor Radchenko 3c11e9df6e
org-element-cache-map: Do not refresh cache before processing
* lisp/org-element.el (org-element-cache-map--recurse): Remove.
(org-element-cache-map): Do not perform a cache-filling pass.  This is
not gaining any speed in practice.
2022-08-23 14:53:02 +08:00
Ihor Radchenko dd0a723603
org-fold-core: Do not override default fontification
* lisp/org-fold-core.el: Remove the code overriding
`font-lock-default-fontify-region'.  Emacs itself is skipping
fontification of invisible text and doing it more efficiently.  The
org-fold fontification overrides are redundant, except when some
poorly written third-party code is forcing fontification inside folded
regions.  However, Org does not need to entertain poorly written third
party code, especially when the required supporting code is reducing
font-lock performance and is complicating the maintenance.
(org-fold-core--specs):
(org-fold-core-add-folding-spec): Remove `:font-lock-skip' spec.
(org-fold-core-initialize):
(org-fold-core--fontifying):
(org-fold-core-region):
(org-fold-core--force-fontification):
(org-fold-core-fontify-region): Remove custom fontification.
* lisp/org-fold.el (org-fold-initialize): Remove `:font-lock-skip'
spec.
* lisp/org-macs.el (org-fold-core--force-fontification):
(org-with-forced-fontification):
(org-buffer-substring-fontified):
(org-looking-at-fontified): Remove org-fold's font-lock logic.
2022-08-23 12:01:34 +08:00
Ihor Radchenko 090dacb0a9
org-fast-tag-selection: Make group tags separator not break alignment
* lisp/org.el (org-fast-tag-selection): Start " : " group tags
separator before tag column in the menu.

Reported in https://orgmode.org/list/62f04f7c.d40a0220.9da67.0a2cSMTPIN_ADDED_BROKEN@mx.google.com
2022-08-22 19:51:47 +08:00
Ihor Radchenko 5184c4382d
org-export: Make results of named code blocks a valid link target
* lisp/ox.el (org-export-search-cells): Use #+RESULTS keyword as
search cell when #+NAME is not provided.  Update the docstring
accordingly.
(org-export-resolve-fuzzy-link): Update the docstring.

* doc/org-manual.org (Exporting Code Blocks): Document the new
behavior and explain the details of exporting links to named code
blocks/results.

Fixes https://orgmode.org/list/010201826cb68597-bf75d596-7890-4dd0-b9ff-0c7b617b4dd4-000000@eu-west-1.amazonses.com
2022-08-22 19:50:10 +08:00
Ihor Radchenko 2dfdc89535
org-babel: Do not echo output of resolved noweb references
* lisp/ob-core.el (org-babel-execute-src-block): Post-process and
return results even when "none" results parameter is given.  Document
that the result value is returned, as it is assumed by
`org-babel-ref-resolve'.
(org-babel-result-cond): Do return results even when "none" results
parameter is given.

According to the manual ":results none" should only affect how the
results of evaluation are inserted into the buffer.  However, the
results are simply ignored currently.  Fix this.
* lisp/ob-ref.el (org-babel-ref-resolve): Set :results to "none" when
resolving noweb references.  Together with the above changes, this
makes Org not echo the results value yet returning the value
programatically.

Reported in https://orgmode.org/list/7702b511-c289-5688-c64c-fb673324a63a@posteo.eu
2022-08-22 19:49:32 +08:00
Ihor Radchenko 1b5ccb1097
org-manual: Document `org-babel-default-inline-header-args'
* doc/org-manual.org (System-wide header arguments): Update the
default value of `org-babel-default-header-args'.  Document that
inline source blocks use a different set of the default arguments.
2022-08-22 19:48:47 +08:00
Max Nikulin 8d93f9b6b4
org-manual.org: Update links to MathJax docs
* doc/org-manual.org (Footnotes): Fix links to particular sections in
MathJax manual.

Scheme is not changed to https: since the site prefers http:

    curl -I https://docs.mathjax.org/
    HTTP/2 302
    date: Sun, 03 Oct 2021 16:04:15 GMT
    location: http://docs.mathjax.org/en/latest/
2022-08-22 10:35:07 +08:00
Ihor Radchenko ccca8549a2
org-align-tags: Fix tag alignment in inlinetasks
* lisp/org.el (org-align-tags): Re-use 'line-prefix text property when
`org-indent-mode' is enabled.  The old version partially copy-pasted
the org-indent code and missed the new changes in inlinetask
alignment.  The new approach should be robust against future
org-indent changes.

Fixes https://orgmode.org/list/25334.19025.107017.390781@gargle.gargle.HOWL
2022-08-20 15:13:14 +08:00
Ihor Radchenko a0b8b7303b
org-inlinetask: Fix infinite loop caused by 5f184b5f2
* lisp/org-inlinetask.el (org-inlinetask-toggle-visibility): Accept
optional argument forcing folding/unfolding.
(org-inlinetask-hide-tasks): Do not use `backward-char' since it can
cause infinite loop.  Force folding instead.

Fixes https://orgmode.org/list/CAKJdtO8+bh4G-Mzhp7k1x9SGfjo9PxdmncdHcUJKCk6PbK9d=g@mail.gmail.com
2022-08-20 14:48:38 +08:00
Ihor Radchenko 8eb3f93748
Fix wide docstring warnings
* lisp/ob-core.el (org-babel-expand-noweb-references--cache-buffer):
* lisp/org-src.el (org-edit-comment-block): Update docstrings.
2022-08-20 14:27:17 +08:00
Ihor Radchenko b4e41b9879
org-insert-heading-respect-content: Fix test failures after a1af06d64
* lisp/org.el (org-insert-todo-heading-respect-content): Ignore the
optional argument always inserting a heading.
2022-08-20 14:24:47 +08:00
Duy Nguyen 2cc2d8f1f6
lisp/org-clock.el: Show file title in org-clock clocktable
* lisp/org-clock.el (org-clocktable-defaults): Add default value for
new clock table option `:filetitle'.
(org-clock-get-file-title): Add new function to extract title of org file.
(org-clocktable-write-default): Print org file name in clock table if
`:filetitle' is set to `t'.

* doc/org-manual.org (The clock table): Include new `:filetitle'
option in manual for clock table.

* etc/ORG-NEWS (New =:filetitle= option for clock table): Include new
`:filetitle' option for clock table.

Allow user to show org file title instead of file name in the
clock table.  If the file does not have a title defined, the file name
will be shown in the clock table.

TINYCHANGE
2022-08-20 14:11:39 +08:00
Ihor Radchenko a1af06d643
org-insert-heading-respect-content: Fix the argument order
* lisp/org.el (org-insert-todo-heading-respect-content): Fix the order
of arguments inside the `org-insert-todo-heading' call.

Fixes https://orgmode.org/list/m1a683p42k.fsf@rrudakov-mbp.lan
2022-08-20 14:01:49 +08:00
Ihor Radchenko 1aaa0baab4
Merge branch 'bugfix' 2022-08-20 13:55:21 +08:00
Eric S Fraga 4dff42f6a6
lisp/ob-julia.el: Fix session support for Julia
* ob-julia.el (org-babel-julia-evaluate-session, commentary): Add line
to initialize ESS so that Julia sessions work.  Also added text in
commentary about Julia packages that sessions require.  Fix
contributed by Stephen Eglen.  See discussion:
https://stat.ethz.ch/pipermail/ess-help/2022-August/013113.html.
2022-08-20 13:54:43 +08:00
Eric S Fraga 3690628398
lisp/ob-julia.el: Fix session support for Julia
* ob-julia.el (org-babel-julia-evaluate-session, commentary): Add line
to initialize ESS so that Julia sessions work.  Also added text in
commentary about Julia packages that sessions require.  Fix
contributed by Stephen Eglen.  See discussion:
https://stat.ethz.ch/pipermail/ess-help/2022-August/013113.html.
2022-08-20 13:53:53 +08:00
Juan Manuel Macias 243ded74ba
doc/org-manual.org: documentation for `org-latex-language-alist'
* etc/ORG-NEWS: update the news with the new variable.
2022-08-20 13:45:19 +08:00
Ihor Radchenko 45e02e6bc6
* doc/org-manual.org (Formula syntax for Calc): Fix typo
Add missing ")".

Reported in https://orgmode.org/list/60220ee13e35ee2e3956654d6d3ef866@openmail.cc
2022-08-19 13:35:24 +08:00
Ihor Radchenko f28288c255
org-agenda-align-tags: Do not trigger fold checks
* lisp/org-agenda.el (org-agenda-align-tags): Do not try to check for
folded regions in agenda.
2022-08-18 20:11:44 +08:00
Ihor Radchenko 97d4d927f2
org-agenda-prepare-buffers: Avoid excessive memory allocation
* lisp/org.el (org-agenda-prepare-buffers): Avoid creating huge lists
when computing `org-todo-keywords-for-agenda',
`org-done-keywords-for-agenda', and
`org-todo-keyword-alist-for-agenda'.  Instead of using `append' in
every single agenda file + `org-uniquify' on a giant lists at the end,
check and add unique list elements in place.

This patch reduces load on Emacs GC when the number of agenda files is
large.
2022-08-18 19:10:59 +08:00
Ihor Radchenko 4080938d60
org-agenda-prepare-buffers: Avoid repetitive updates of agenda menu
* lisp/org.el (org-agenda-file-menu-enabled): New variable controlling
whether `org-mode' updates the agenda file list in the menu.
(org-mode): Honor the new variable.
(org-agenda-prepare-buffers): Suppress `org-install-agenda-files-menu'
when opening the agenda files.  Run it once at the end.

This commit reduces performance overheads when the number of agenda
files is large.
2022-08-18 19:08:45 +08:00
Ihor Radchenko d3a9c424ba
org-encode-time: Refactor into top-level `defmacro'
* lisp/org-macs.el (org-encode-time): Rewrite, avoiding top-level `if'
statement that triggers
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56746

Also, fix the docstring warnings.
2022-08-16 17:16:41 +08:00