Commit Graph

25510 Commits

Author SHA1 Message Date
Ihor Radchenko 22de2e26e7
Fix Emacs 26 compatibility
* lisp/oc-biblatex.el (org-cite-biblatex-export-citation): Do not use
`seq-first'.
* lisp/org-persist.el (org-persist-collection-let): Suppress warnings.
* lisp/ox-latex.el (org-latex-src--engrave-mathescape-p): Do not use
`if-let'.
(org-latex-src--engrave-code): Do not use `string-trim-right'.
* lisp/ox.el (org-export-link-localise): Add require for subr-x for
`thread-first'.
2022-07-24 20:57:07 +08:00
Ihor Radchenko d8133e80d8
Merge branch 'bugfix' 2022-07-24 20:29:20 +08:00
Ihor Radchenko 1c3a46268f
Backport from main: Fix compatibility with Emacs 26
* lisp/org-compat.el (org-replace-buffer-contents): Add compatibility
function for `replace-buffer-contents'.

* lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use
`org-replace-buffer-contents'.
2022-07-24 20:23:48 +08:00
Ihor Radchenko a0a078049b
Fix compiler warnings
* lisp/oc-basic.el (org-open-file): Declare function.
2022-07-24 20:19:47 +08:00
Robert Pluim 01b0fb14bc
Backport from main: Escape single left quotes in docstrings
* lisp/ob-core.el (org-babel-default-header-args):
* lisp/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/ob-lua.el (org-babel-lua-read-string):
* lisp/ob-table.el (org-sbe):
* lisp/oc-basic.el (org-cite-basic--shorten-names):
* lisp/org-agenda.el (org-agenda-sorting-strategy):
(org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/org-fold-core.el (org-fold-core--specs):
(org-fold-core-remove-folding-spec):
(org-fold-core-get-folding-spec):
(org-fold-core--isearch-overlays):
* lisp/org-plot.el (org--plot/prime-factors):
* lisp/org-table.el (org-table-collapse-header):
* lisp/org.el (org-special-ctrl-o):
(org-latex-to-html-convert-command):
* lisp/ox-html.el (org-html--unlabel-latex-environment):
* lisp/ox-publish.el (org-publish-find-property):
Use \\=' when there's a need for a single left quote in a docstring.

The emacs-29 byte compiler complains about such usage.
2022-07-24 20:19:11 +08:00
Ihor Radchenko afe50b7132
Fix Emacs 26 compatibility
* lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'.
* lisp/ox-ascii.el (org-ascii--describe-links):
* lisp/ox-md.el (org-md--headline-referred-p): Do not use
`ignore-error'.
* testing/org-test.el (org-test-at-time): Fallback to older definition
of `decode-time' when it cannot accept 3 arguments.
2022-07-24 20:11:03 +08:00
Ihor Radchenko 127e7fee49
ox-latex: Keep obsolete variable values removed in 97cfb959d
* lisp/org-compat.el (org-latex-babel-language-alist):
(org-latex-polyglossia-language-alist): Resurrect the variable values.
2022-07-23 22:16:54 +08:00
Ihor Radchenko abaee57ce6
Merge branch 'bugfix' 2022-07-23 14:17:37 +08:00
Ihor Radchenko e5cf0bc840
org-export: Do not use broken link handler on non-link elements
* lisp/ox.el (org-export-data): Only catch 'org-link-broken on link
objects.  Signaling 'org-link-broken for other element types, should
not happen and we should _not_ export such elements as "" or "[BROKEN
LINK...]".
2022-07-23 14:10:45 +08:00
Ihor Radchenko 14532ec6a5
ox-md: Fix export with broken links
* lisp/ox-md.el (org-md--headline-referred-p): Allow exporting
headlines when the document contains broken links and
`org-export-with-broken-links' is non-nil.  For broken links,
`org-export-resolve-link' throws an error - catch it and do not match
the headline against such broken link.
2022-07-23 14:10:19 +08:00
Ihor Radchenko 4631790fb9
ox-ascii: Fix export with broken links
* lisp/ox-ascii.el (org-ascii--describe-links): Skip broken links.
2022-07-23 14:10:13 +08:00
Juan Manuel Macias 97cfb959d1
* lisp/ox-latex.el: New variable `org-latex-language-alist'
(org-latex-language-alist): Unify in a single list
`org-latex-polyglossia-language-alist' and
`org-latex-babel-language-alist', and make the two variables
obsolete. However, it may be convenient in the future to replace this
list with a more robust one.  (See:
https://list.orgmode.org/taeb0a$r62$1@ciao.gmane.io)

(org-latex-guess-babel-language): This function has been modified so
that the new Babel command `babelprovide' is also recognized.  This
command is necessary to load the languages served by Babel exclusively
through an ini file.  Therefore, the new Babel syntax is supported
alongside the old one.  Note that languages that are served
exclusively via an ini file are not added to the Babel argument.
2022-07-23 12:57:11 +08:00
Ihor Radchenko 6c1e3dfa28
Merge branch 'bugfix' 2022-07-23 10:14:01 +08:00
Ihor Radchenko c779b7aa0e
org-babel-detangle: Fix :comments link for src blocks before first heading
* lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Allow fuzzy
matching when following the backlink to src block from tangles
source.  The current default value of
`org-link-search-must-match-exact-headline` makes
`org-link-open-from-string` treat fuzzy links as headlines without
falling back to fuzzy text search.  Bind it to nil to force fuzzy text
matching while detangling.

Fixes https://orgmode.org/list/87zgh1qxfk.fsf@posteo.net
2022-07-23 10:10:24 +08:00
Ihor Radchenko b6098500ae
org-keys: Bind ESC <left> by default
* lisp/org-keys.el (org-mode-map): Bind `org-metaleft' to ESC <left>
by default, not just in terminals.  This completes the ESC <arrow>
binding group.  ESC <right>, <up>, and <down> are already bound and
missing ESC <left> can be confusing.

Reported in https://orgmode.org/list/Yf6lsTR3JSNSXRDX@x.local
2022-07-22 21:35:38 +08:00
Ihor Radchenko b713b9afa1
mk: Add make target "repro" for easy bug testing
* mk/default.mk (REPRO_DEBUG): New custom variable enabling extra
debugging facilities in Emacs instance open by make repro.
(REPRO_ARGS): Extra arguments passed to Emacs by make repro.
(REPRO_INIT):
(REPRO): Define Emacs cmd for testing.
* mk/targets.mk (.PHONY):
(repro): Add new target.
* doc/org-manual.org (Feedback): Describe the new make target.
2022-07-22 21:35:37 +08:00
TEC 99681ce389
org: Support completion of cite-related keywords
* lisp/org.el (org-get-export-keywords): Add BIBLIOGRAPHY, CITE_EXPORT,
and PRINT_BIBLIOGRAPHY to `org-options-keywords'.

It's worth noting that while based on the variable name
PRINT_BIBLIOGRAPHY may not seem to fit, it is in good company with
INCLUDE, and this variable is (exclusively) used as a list of
non-affiliated, non-block, non-export-backend-specific keywords for
pcomplete.  It may be a good idea to rename this for clarity, or split
it up in future.
2022-07-21 22:09:24 +08:00
Ihor Radchenko d2a110ffe2
org-attach-attach: Allow attaching directories using 'cp method
* lisp/org-attach.el (org-attach-attach): Use `copy-directory' when
FILE is a directory.  Remove trailing slash before processing.
2022-07-21 19:23:18 +08:00
TEC db6c229786
testing/lisp: Update to handle new download policy
* testing/lisp/test-ox.el: Bind `org-resource-download-policy' to t when
testing downloading.

* testing/lisp/test-org.el: Bind `org-resource-download-policy' to t
when testing downloading.
2022-07-20 23:37:26 +08:00
Ihor Radchenko df1814b83e
org-html-format-latex: Preserve buffer-local settings
* lisp/ox-html.el (org-html-format-latex): Carry over buffer-local
variables when create LaTeX images.  Use `org-export-with-buffer-copy'
instead of `with-temp-buffer'.

Fixes https://orgmode.org/list/m2fsqr75md.fsf@ego.team
2022-07-20 15:11:41 +08:00
Ihor Radchenko 39005dc098
org-fold: Do not fold text inserted right after outline fold
* lisp/org-fold.el (org-fold-initialize): Do not extend the fold when
text is inserted right after it.  This resembles folding overlay
behavior used in previous Org versions and in the 'overlays
`org-fold-core-style'.

Fixes https://orgmode.org/list/871quprrra.fsf@gmail.com
2022-07-19 21:15:38 +08:00
Ihor Radchenko 3b7523acd0
ob-gnuplot: Fix stable file collision when converting data
* lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars): Use cons cell
of all the code block parameters and the actual assigned variable
value to generate filename for storing the data.  This fixes a
scenario when code block has two or more variable assignments that
were wrongly saved into the same file.  Before the commit, only the
last assigned variable value has been used by gnuplot for _all_ the
variables.
2022-07-19 18:02:56 +08:00
Ihor Radchenko 03543e17dd
org-src-font-lock-fontify-block: Transfer 'font-lock-face property
* lisp/org-src.el (org-src-font-lock-fontify-block): Copy
'font-lock-face text property in addition to 'face.  This is required
because Emacs does not enable `font-lock-mode' inside buffers with
names starting from space character (Org fontification buffers are
such).  Without `font-lock-mode' 'font-lock-face is not being remapped
to 'face text property and we may sometimes lose the information in
the major modes that do fontification by directly setting
'font-lock-face.

Reported in https://teddit.net/r/orgmode/comments/w2b0tw/syntax_highlighting_in_orgsource_blocks/igqdx18/
2022-07-19 12:19:57 +08:00
Ihor Radchenko 9917d69543
org-indent-region: Fix when `org-adapt-indentation' is 'headline-data
* lisp/org.el (org--get-expected-indentation): Remove the extra
condition added in e3b79ad2b in the cond branch for first line in an
element.  Checking `org-adapt-indentation' t value here trigger the
last default cond branch that assumes that we are _not_ at the first
line.

The new logic explicitly avoids inheriting indentation from previous
sibling when `org-adapt-indentation' is set to 'headline-data and the
previous sibling is satisfying "headline data" condition as in
`org-indent-line'.  The case when `org-adapt-indentation' is set to t
is already handled correctly when calculating the CONTENTSP
indentation for parent headline.

Fixes https://orgmode.org/list/c13cab60-bbc9-e69e-6d0d-7fe75c5908d6@kalysto.org
2022-07-18 21:00:13 +08:00
Ihor Radchenko 057df6cce2
org-open-at-point: Do not list links under headline that cannot be opened
* lisp/org-element.el (org-element-context): Do not alter match-data.
* lisp/org.el (org-open-at-point): Update docstring listing that
`org-open-at-point' opens src-blocks and citations.
(org-offer-links-in-entry): Do not display links within invalid contexts.

Reported in https://list.orgmode.org/PAXPR06MB77609E8C8E769CD7D769FA4BC6199@PAXPR06MB7760.eurprd06.prod.outlook.com/
2022-07-17 20:14:44 +08:00
Ihor Radchenko df0e96ba42
org-agenda-remove-restriction-lock: Remove 'file restriction
* lisp/org-agenda.el (org-agenda-remove-restriction-lock): Remove
agenda restriction set by `org-agenda-set-restriction-lock' called
with prefix argument.  `org-agenda-restrict' may be nil while
`org-agenda-overriding-restriction' is non-nil.

Fixes https://list.orgmode.org/87v8w2qdgp.fsf@gmail.com
2022-07-17 20:07:13 +08:00
Ihor Radchenko 702b0a81e1
org-agenda-clock-report-header: Update docstring
See https://orgmode.org/list/87o808j6si.fsf@yandex.com
2022-07-17 17:07:52 +08:00
Ihor Radchenko b4a72ddf98
org-agenda-show-current-time-in-grid: Use more common Unicode arrow
* lisp/org-agenda.el (org-agenda-current-time-string): Use more
commonly available "←" char indicator instead of "⭠".  Suggested in
https://orgmode.org/list/875yk1e3h1.fsf@posteo.net.  This patch does
not fully solve the problem with `char-displayable-p' returning
non-nil when the char cannot be actually displayed in agenda, but it
should at least make the issue less severe until we find a more
accurate test.  In any case, the Unicode version of the agenda grid
will be available for more users with this patch.
2022-07-17 16:54:34 +08:00
Ihor Radchenko 064afa0c01
org-indent: Fix edge case when edited region ends at headline leading stars
* lisp/org-indent.el (org-indent-refresh-maybe): Extend affected
region to the whole line after END.

Fixes https://orgmode.org/list/t4lpos$l3p$1@ciao.gmane.io
2022-07-17 16:51:54 +08:00
Ihor Radchenko 79f0969ccc
* doc/org-manual.org (Using CDLaTeX to enter math): Clarify ' binding
See https://orgmode.org/list/CAJczNmB95tdWgYcb6gP-B4LH5+W0sBMyA+Z38Fh7Sy+ksfpmbw@mail.gmail.com
2022-07-17 16:50:43 +08:00
Max Nikulin e08ce5b27d
test-org.el: Add some tests for `org-test-with-timezone'
* testing/lisp/test-org.el (test-org/org-time-string-to-time):
Check that no daylight saving time value is forced for
`org-parse-time-string' and `org-encode-time' calls.
2022-07-17 16:40:19 +08:00
Max Nikulin ae1db7df39
Use `org-encode-time' helper macro
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, agenda-bulk-action):
* lisp/org-capture.el (org-capture-fill-template):
* lisp/org-clock.el (org-clock-get-sum-start)
(org-clock-special-range, org-clocktable-shift)
(org-clocktable-steps):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-datetree.el (org-datetree-find-iso-week-create)
(org-datetree-insert-line):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-matcher-time):
* lisp/org.el (org-current-time, org-current-effective-time)
(org-add-planning-info, org-read-date, org-read-date-display)
(org-read-date-analyze, org-eval-in-calendar)
(org-calendar-select, org-display-custom-time)
(org-calendar-select-mouse, org-time-string-to-time)
(org-time-from-absolute, org-at-clock-log-p)
(org-date-from-calendar, org-get-cursor-date)
(org-timestamp-to-time):
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
* lisp/ox-icalendar.el (org-icalendar-convert-timestamp):
Avoid direct calls of `encode-time', use `org-encode-time' instead.

Org supports Emacs-26, but the recommended way to call `encode-time'
changed in Emacs-27.  In Emacs-29 DST and TZ elements of the single list
arguments became optional.  In Org it is still convenient to call the
function with separate arguments without explicit DST and TZ arguments.
The `org-encode-time' should mitigate attempts to modernize Org code
directly in the Emacs repository.
2022-07-17 16:40:18 +08:00
Max Nikulin 8908a1bda1
org-macs.el: Introduce a helper for `encode-time'
* lisp/org-macs.el (org-encode-time): New compatibility and convenience
helper macro to allow a list for time components or separate arguments
independently of Emacs version.
* testing/lisp/test-org.el (org-test-with-timezone): New macro to ensure
that some code is executed with certain TZ environment value and thus
particular daylight saving time or other time shift rules are active.
* testing/lisp/test-org.el (test-org/org-encode-time): Tests for various
ways to call `org-encode-time'.

Ensure recommended way to call `encode-time' for Emacs-27 and newer with
hope to avoid bugs due to attempts to modernize the code similar to
bug#54731.  6-elements list may be allowed as `encode-time' argument
since Emacs-29, see bug#54764.
2022-07-17 16:38:53 +08:00
Max Nikulin f3802b017c
testing/lisp: Use `org-time-string-to-time'
* testing/lisp/test-org.el (test-org/org-read-date, test-org/deadline)
(test-org/schedule, test-org/time-stamp, test-org/timestamp-from-time):
* testing/org-test.el (org-test-at-time): Use `org-time-string-to-time'
instead of composition of `org-parse-time-string' and `encode-time'.

The actual goal is to prepare to replace `encode-time' by
`org-encode-time' compatibility and convenience macro.
2022-07-17 16:38:52 +08:00
Paul Eggert a4105d0942
Use higher level helpers instead of `encode-time'
* lisp/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
Prefer org-time-string-to-seconds to doing it by hand.
* lisp/org-macs.el (org-2ft):
Prefer org-time-string-to-seconds to doing it by hand.
* lisp/org-table.el (org-table-eval-formula):
Prefer org-time-string-to-time to doing it by hand.

Max Nikulin:
A larger patch "Improve Org usage of timestamps" was suggested in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54764#10

Only cosmetic changes are selected for this patch.
2022-07-17 16:38:51 +08:00
Max Nikulin a189697681
Fix tests for `org-parse-time-string' and `org-clock'
* testing/lisp/test-org.el (ert-deftest test-org/org-parse-time-string):
Update test expectations to use DST of -1 (guess) after fix of
`org-parse-time-string'.
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
Do not change timezone from nil to 0.  Prevent test failures in zones
other than UTC.
2022-07-17 16:38:51 +08:00
Paul Eggert 132a9d304e
Use unknown DST instead of standard time in timestamps
* lisp/ol.el (org-store-link): Prefer plain (encode-time ...)
to (apply 'encode-time ...), for speed.
* lisp/org-macs.el (org-parse-time-string): Return unknown DST,
not standard time.
* lisp/org.el (org-read-date-analyze): Return a timestamp with a DST
flag of -1 (unknown) rather than nil (standard time).

Max Nikulin:
A larger patch "Improve Org usage of timestamps" was suggested in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54764#10

Changes selected for this patch normalizes timestamp format:
if it is a list than it should contain 9 elements to be compatible
with Emacs-27 and Emacs-28 `encode-time' single argument, nil should not
be used for DST field since it means standard time while actual value
is unknown and should be guessed.

Ignacio Casso reported a problem with agenda
https://list.orgmode.org/PAXPR06MB7760238F410CBE3203F78EE0C61E9@PAXPR06MB7760.eurprd06.prod.outlook.com
due to Emacs commit dd0727e1ec1 changing Org code.  It was mostly reverted
by 8ef37913d3 (bug#54731).  Code in the Org repository did not have
the bug, but it safer to add protection against similar refactoring.
2022-07-17 16:38:50 +08:00
Stefan Kangas bf930b6fe5
; * lisp/org-refile.el (org-refile-targets): Fix typo. 2022-07-17 16:36:14 +08:00
Ihor Radchenko c550a42902
oc-basic: Parse @string entries in BiBTeX bibliographies
* lisp/oc-basic.el (org-cite-basic--parse-bibtex): Expand string
abbreviations in the .bib bibliography files.

Fixes https://list.orgmode.org/orgmode/25288.4658.491916.790389@gargle.gargle.HOWL/
2022-07-17 16:24:36 +08:00
TEC 0583a0c5ea
org: Add setting for remote file download policy
* lisp/org.el (org-resource-download-policy, org-safe-remote-resources):
Two new customisations to configure the policy for downloading remote
resources.
(org--should-fetch-remote-resource-p, org--safe-remote-resource-p,
org--confirm-resource-safe): Introduce the new function
`org--should-fetch-remote-resource-p' for internal use determining
whether a remote resource should be downloaded according to the download
policy.  This function makes use of two helper functions,
`org--safe-remote-resource-p' and `org--confirm-resource-safe'.
(org-file-contents): Apply `org--safe-remote-resource-p' to file
downloading.

* lisp/org-persist.el (org-persist-write): Apply
`org--safe-remote-resource-p' to url downloading.

* lisp/org-attach.el (org-attach-attach, org-attach-url): Apply
`org--safe-remote-resource-p' to url downloading.
2022-07-16 17:46:01 +08:00
Nicholas Vollmer d947988722
* lisp/ob-core.el: Fix docstring quote usage
(org-babel-default-header-args): escape syntactic single quote in docstring
(org-babel-result-to-file): escape syntactic single quote in docstring
2022-07-14 21:34:32 +08:00
Ihor Radchenko 8e2fed82ed
org-fold: Make sure that changes do not leave partially folded headings
* lisp/org-fold-core.el (org-fold-core--fix-folded-region): Check
fragility in all the indirect buffers.
* lisp/org-fold.el (org-fold--reveal-headline-at-point): New function
revealing heading line or full heading when the heading only contains
blank lines.
(org-fold--reveal-outline-maybe): Check headline at the end of folded
region as well.  Use `org-fold-core--fix-folded-region'.
* lisp/org.el (org-insert-heading): Make sure that the newline in
front of heading is revealed.
2022-07-12 21:51:40 +08:00
Ihor Radchenko f29ccf3161
test-org-fold: Cover the issue fixed by previous commit
*
testing/lisp/test-org-fold.el (test-org-fold/org-fold-reveal-broken-structure):
Test `org-delete-char' instead of `delete-char'.  The former is the
function used interactively.
2022-07-12 21:30:58 +08:00
Ihor Radchenko a79a742cbf
Revert "org.el: Improve performance of deletion commands"
This reverts commit 46df681336.

The optimization broke folding fragility checks.
2022-07-12 15:05:45 +08:00
Ihor Radchenko c66bdb0c9b
org-fold-core-style: Clarify "error-prone" in the docstring
* lisp/org-fold-core.el (org-fold-core-style): Explain that the new
folding with text properties can be problematic with third-party
packages, not with Org itself.

See https://orgmode.org/list/877d4jve13.fsf@gmail.com
2022-07-12 09:02:47 +08:00
Ihor Radchenko 654005394b
org-list-struct-apply-struct: Do not rely on `match-data' after edits
* lisp/org-list.el (org-list-struct-apply-struct): Refresh
`org-list-full-item-re' match data if we edit the bullet.  Fixes
https://orgmode.org/list/62cbc0f3.1c69fb81.13d5e.e250SMTPIN_ADDED_BROKEN@mx.google.com
* testing/lisp/test-org-list.el (test-org-list/indent-item): Add test
checking for the reported bug.
2022-07-11 19:13:07 +08:00
Ihor Radchenko 53e6aa866e
org-agenda: Make sure that clock report header has trailing newline
* lisp/org-agenda.el (org-agenda-list): Add trailing newline to
`org-agenda-clock-report-header' if there is none.
2022-07-11 13:01:50 +08:00
Ihor Radchenko c231e93b56
ol-docview: Throw an error when trying to open non-existing file
* lisp/ol-docview.el (org-docview-open): Throw an error when file does
not exist.  Creating an empty document buffer is not useful here.

Fixes https://orgmode.org/list/87zgklmd0g.fsf@localhost
2022-07-11 13:00:05 +08:00
Al Haji-Ali bc33c0133d
lisp/org.el: Save restrictions in all agenda file buffers
* lisp/org.el (org-agenda-prepare-buffers): Call
`org-with-wide-buffer' for every buffer in the agenda, instead of
calling `save-excursion'/'`save-restrictions' just for the current
buffer, to save restrictions in all buffers.  Use
`with-current-buffer' instead of `save-excursion'/'`set-buffer'.

See https://list.orgmode.org/orgmode/87y1x588rs.fsf@thinkpad.mail-host-address-is-not-set/

TINYCHANGE
2022-07-10 18:02:13 +08:00
Ihor Radchenko 5b45ad083c
oc-basic: Detect malformed bibtex bibliographies
* lisp/oc-basic.el (org-cite-basic--parse-bibtex): Validate the
bibliography before parsing.  Display list of issues if any (via
`bibtex-validate`).
(org-cite-basic--parse-bibliography): Set buffer file name needed by
`bibtex-validate`.  Empty the cache in case of error.
2022-07-09 17:12:47 +08:00