Commit Graph

17807 Commits

Author SHA1 Message Date
Ihor Radchenko f095cfc3c0
* lisp/org.el (org-store-log-note): Do not indent empty lines in notes
See https://orgmode.org/list/m235eo9d8b.fsf@ntnu.no
2022-07-31 13:07:06 +08:00
Ihor Radchenko 2ea0830f07
org-capture-kill: Fix capture boundaries when deleting empty lines above
* lisp/org-capture.el (org-capture-place-entry):
(org-capture-place-item):
(org-capture-place-table-line):
(org-capture-place-plain-text): Store beginning of the capture region
as marker.  This will make the ORIGIN move if
`org-capture-empty-lines-before` has to add/remove lines.

Fixes https://orgmode.org/list/CAGyCDkPos+W_MEJffSZga83NsOLZx2XGTYEmSGQuHQvS-sNa8A@mail.gmail.com
2022-07-31 13:05:16 +08:00
Ihor Radchenko 2861d9cad8
org-paste-subtree: Do not use `insert-before-markers'
* lisp/org.el (org-paste-subtree): Use `insert' instead of
`insert-before-markers'.  The former is what people usually expect and
doing otherwise is surprising.
* lisp/org-archive.el (org-archive-to-archive-sibling): Do not expect
`org-paste-subtree' to insert before markers.
2022-07-31 13:05:15 +08:00
András Simonyi 7e07611844
oc-csl.el: Add support for sub-bibliographies
* lisp/oc-csl.el (org-cite-csl--rendered-bibliographies): New function
to collect all #+print_bibliography keywords with their properties and
call Citeproc to render all sub-bibliographies in one go as required
by the API.  Return the formatted bibliographies as values in an alist
in which keys are the #+print_bibliography keyword options as plists.
Cache the return value in the export communication channel.
(org-cite-csl--bibliography-filter): New helper function to convert
plists representing #+print_bibliography options to the alist filter
form expected by Citeproc.
(org-cite-csl--rendered-citations): Call
`org-cite-csl--rendered-bibliographies' before rendering citations to
make sure that the complete sub-bibliography information is added to
the processor and, therefore, citation numbers are correct.
(org-cite-csl--render-bibliography): Instead of directly calling
Citeproc to render the bibliography, call
`org-cite-csl--rendered-bibliographies' and retrieve the formatted
bibliography from its return value based on the options passed as the
`props' argument.
2022-07-31 10:24:30 +08:00
Ihor Radchenko 785f003de5
org-fold-show-entry: Do not fold drawers unless requested
* lisp/org-fold.el (org-fold-show-entry): Do not fold drawers in the
unfolded entry unless the new optional argument is non-nil.  Folding
the drawers was introduced in 1027e02569, but does not follow the
function docstring.  Moreover, folding drawers creates unexpected
behaviour in some cases.  See
https://orgmode.org/list/m2a6bl4mmr.fsf@andrew.cmu.edu

* etc/ORG-NEWS (~org-fold-show-entry~ does not fold drawers by default
anymore): Document the change.

* lisp/org-agenda.el (org-agenda-show):
(org-agenda-show-and-scroll-up):
(org-agenda-show-1):
* lisp/org-compat.el (outline-toggle-children):
* lisp/org.el (org-move-subtree-down):
(org-return): Explicitly request folding drawers inside the revealed
entry in the places where it appears to make sense.

* lisp/org-timer.el (org-timer--get-timer-title): Do not unfold entry
at all.  This is a noninteractive function.
2022-07-31 10:17:08 +08:00
Bob Vergauwen a753d0dd26
lisp/ox-latex: Omit empty date
* lisp/ox-latex.el: (org-latex-template): When no date is provided or
the export option date is nil, the empty '\date{}' string is no
longer included in the exported latex document.

The default behaviour for ox-latex was to include an empty date line as
'\date{}'.  This empty date line can affect more complex latex templates
when the date is for example set by the template on compilation, or when
the date command is overwritten entirely.  In this new patch, the date
line is omitted from the exported document.

TINYCHANGE
2022-07-30 13:38:33 +08:00
Juan Manuel Macias d37c0ee5fa
lisp/ox-latex.el: Remove obsolete Babel and Polyglossia alists
* (org-latex--format-spec): The new variable is now `org-latex-language-alist'.
2022-07-28 20:29:22 +08:00
Ihor Radchenko bc875e5ccf
Fix feature regexp used to detect Org library names
* lisp/org.el (org-reload):
* mk/org-fixup.el (org-make-org-loaddefs): Distinguish ol-*.el and
oc-*.el libraries as parts of Org-related libraries.
2022-07-28 20:26:14 +08:00
Ihor Radchenko 5be0c709b3
* lisp/org.el (org-reload): Do not quote t symbol 2022-07-26 22:17:04 +08:00
TEC 6ad53fa22e
org: Correct regexp escaping to use regexp-quote
* lisp/org.el (org--confirm-resource-safe): `regexp-opt' was
accidentally used instead of `regexp-quote'.
2022-07-26 12:49:51 +08:00
Paul Eggert 6013cb161d Fix doc string quoting problems with '
The Emacs doc string convention is to document values as-is when that
is clear, and surrounded by `single quotes' otherwise. For example, a
doc string "(a b c)" stands for a list of symbols, and the doc string
"`a'" stands for a single symbol. The doc string "\\=`a" is typically
not correct for that single symbol, because that is equivalent to
"(quote a)" and the typical intent is to talk about the symbol, not
about the Lisp quoting construct.  One needs "\\=`X" only when talking
about something intended to be equivalent to "(quote X)", as in the
doc string "(provide \\='org-xyz)".
2022-07-25 13:10:29 -07:00
TEC 4504473779
ox-latex: Support svg images with unicode paths
* lisp/ox-latex.el (org-latex--inline-image): Testing with TeXLive 2022
finds that while \includegraphics is fine with unicode characters in the
file path, \includesvg needs \detokenize{...} to prevent errors.
2022-07-25 22:02:25 +08:00
TEC 394f494935
org-macro: Require vc in vc-modified-time
* lisp/org-macro.el (org-macro--vc-modified-time): Not all the vc
components needed are autoloaded, allowing for the error:
"vc-call-backend: Symbol’s value as variable is void: vc-log-view-type".
To prevent this issue from cropping up, vc is now required at the start
of `org-macro--vc-modified-time'.
2022-07-25 18:36:12 +08:00
Kyle Meyer 5a64429b27 Merge branch 'bugfix'
As mentioned in 2e36ac2ac (Merge single quote fixes from Emacs's
master, 2022-07-24), this merge is keeping Org main's side of
org-babel-lua-read-string and org-agenda-sorting-strategy rather than
the variant introduced in the Emacs repo that's now in bugfix.

Note that for org-agenda-sorting-strategy docstring I think it'd
probably be preferable to change main's

    \\='(time-up category-keep priority-down)

to a bare

    (time-up category-keep priority-down)

but, at least for this merge, I'm sticking to choosing between the
variables that are in one of the sides.
2022-07-24 16:53:32 -04:00
Stefan Kangas 6e991f4bb9 Backport commit 10b691987 from Emacs
; Fix typos
10b69198708105655c49b62ac7d6185abb7e02a7
Stefan Kangas
Sat Jul 16 10:07:38 2022 +0200
2022-07-24 16:22:34 -04:00
Kyle Meyer 2e36ac2ac1 Merge single quote fixes from Emacs's master
This brings in ports of bbf389ea6de (Audit quoting the quote character
in doc strings, 2022-04-22), 2d71fd3b041 (Further doc string quoting
fixes, 2022-04-22), and b2bce107b15 (Further audits of single quotes
in Lisp doc strings, 2022-05-24) from Emacs's master branch, resolving
conflicts with 01b0fb14b (Backport from main: Escape single left
quotes in docstrings, 2022-07-24).

In all cases, take Emacs's side.  There are two cases where I think
Org's version is preferable, org-babel-lua-read-string and
org-agenda-sorting-strategy.  Don't keep those _on bugfix_ to avoid
conflicts when Emacs's emacs-28 branch is merged to its master branch.
When I merge bugfix to main, I'll keep Org's variant, so they'll
eventually make it to Emacs's tree, just not as part of the Org 9.5.x
to emacs-28 syncing.
2022-07-24 16:18:15 -04:00
Lars Ingebrigtsen 9d29de23cf Backport commit b2bce107b from Emacs
* lisp/org.el (org-latex-to-html-convert-command):
* lisp/org-agenda.el (org-agenda-sorting-strategy): Audit use of
various single quotes in Lisp doc strings.

Further audits of single quotes in Lisp doc strings
b2bce107b15d6e0c2b773704179c6bf463525459
Lars Ingebrigtsen
Tue May 24 13:17:53 2022 +0200

[km] Org's bugfix branch is currently receiving commits from emacs-28,
     but this commit comes from Emacs's master branch.  I'm porting it
     because it has conflicts with bugfix's 01b0fb14b (Backport from
     main: Escape single left quotes in docstrings, 2022-07-24) and
     only touches docstrings.
2022-07-24 16:17:23 -04:00
Lars Ingebrigtsen 5fdbf159f2 Backport commit 2d71fd3b0 from Emacs
* lisp/ob-table.el (org-sbe): Further quoting fixes in doc strings.

Further doc string quoting fixes
2d71fd3b041506c68b5f1cd1e409e09e25778c34
Lars Ingebrigtsen
Fri Apr 22 17:16:42 2022 +0200

[km] Org's bugfix branch is currently receiving commits from emacs-28,
     but this commit comes from Emacs's master branch.  I'm porting it
     because it has conflicts with bugfix's 01b0fb14b (Backport from
     main: Escape single left quotes in docstrings, 2022-07-24) and
     only touches docstrings.
2022-07-24 16:17:23 -04:00
Lars Ingebrigtsen cea0263784 Backport commit bbf389ea6 from Emacs
* lisp/ox-publish.el (org-publish-find-property):
* lisp/ox-html.el (org-html--unlabel-latex-environment):
* lisp/org-table.el (org-table-collapse-header):
* lisp/org-plot.el (org--plot/prime-factors):
* lisp/org-agenda.el (org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/ob-lua.el (org-babel-lua-read-string):
* lisp/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/ob-core.el (org-babel-default-header-args): Fix
quoting in doc strings.  In code examples, the ' character is
quoted with \\=, and regularize 'foo to `foo', and quote strings
like "foo" instead of 'foo'.

Audit quoting the quote character in doc strings
bbf389ea6deab229ba18dc519fe712ec982609d1
Lars Ingebrigtsen
Fri Apr 22 16:17:22 2022 +0200

[km] Org's bugfix branch is currently receiving commits from emacs-28,
     but this commit comes from Emacs's master branch.  I'm porting it
     because it has conflicts with bugfix's 01b0fb14b (Backport from
     main: Escape single left quotes in docstrings, 2022-07-24) and
     only touches docstrings.
2022-07-24 15:58:18 -04:00
Paul Eggert 540fcd0193 ox-publish: fix typo in function name
* lisp/org-compat.el (org-publish-cache-ctime-of-src):
New backward-compatibility alias.
* lisp/ox-publish.el (org-publish-cache-mtime-of-src):
Rename from org-publish-cache-ctime-of-src, since it
has always cached mtime not ctime.  All uses changed.
2022-07-24 09:39:25 -07:00
TEC 6de5431acc
org: Refactor rx to concat + regexp-opt
* lisp/org.el (org--confirm-resource-safe): Since Emacs 26 doesn't
support rx's (literal S) construct, use (concat (regexp-opt ...) ...)
instead.
2022-07-24 22:07:46 +08:00
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
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
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
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
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
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 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
Matt Huszagh 8be689f119
ob-core.el: Improve org-babel-default-header-args docstring
* lisp/ob-core.el (org-babel-default-header-args): Provide an example
illustrating one benefit of using closures as default header
arguments.  Additionally, explain how to provide the same type of
header argument multiple times in the default alist.
2022-07-09 13:20:47 +08:00
Matt Huszagh e8dd98d151
ob-core.el: Fix behavior of lambda default header arg vars
* lisp/ob-core.el (org-babel-merge-params): Permit multiple :var
default header arguments when using closures.
2022-07-09 13:20:46 +08:00
Ihor Radchenko e0e016c1ae
org-element: Do not try to sync element cache in the middle of a change
* lisp/org-element.el (org-element--cache-sync): Do not sync between
`before-change-functions' and `after-change-functions'.

Fixes https://orgmode.org/list/87tu7tdljo.fsf@no.workgroup
2022-07-09 12:08:49 +08:00
Matt Rudary a7cc95c60c
org-src.el: Add plain to org-src-window-setup customization
* lisp/org-src.el (org-src-window-setup): Add plain to the list of
valid choices for `org-src-window-setup'.

A previous change added it to the documentation and to the pcase that
process this variable in `org-src-switch-to-buffer', but the defcustom
did not include it as a valid option.

TINYCHANGE
2022-07-09 12:04:07 +08:00
András Simonyi b3b17cdb66
oc-csl.el: Add support for nocite citations
* lisp/oc-csl.el (org-cite-csl--rendered-citations): Collect nocite
style citations in a separate list as required by the citeproc-el
API. Set the output of all nocite citations to the empty string.
(org-cite-csl--nocite-p): New helper predicate for checking whether a
citation is a nocite.
2022-07-07 18:42:55 +08:00
Ihor Radchenko 0495961f36
org-auto-repeat-maybe: Use effective time for "LAST_REPEAT"
* lisp/org.el (org-auto-repeat-maybe): Use effective time when
recording LAST_REPEAT property.

Fixes https://orgmode.org/list/87sfnk7l0h.fsf@jonreeve.com
2022-07-07 18:16:14 +08:00
Ihor Radchenko db12a497d2
org-agenda: Use ARG instead of `current-prefix-arg'
* lisp/org-agenda.el (org-agenda): Use the function argument instead
of `current-prefix-arg' when calling agenda view.  This is safe
because `org-agenda' uses raw "P" interactive spec.

Fixes https://list.orgmode.org/m2pmimnymk.fsf@air.local.mail-host-address-is-not-set/T/#u
2022-07-07 18:00:57 +08:00
Ihor Radchenko bdf7afe20e
ob-core: Fix nil value of `org-babel-temporary-stable-directory'
* lisp/ob-core.el: Make sure that
`org-babel-temporary-stable-directory' is set to non-nil non-existent
directory.  Non-existent directory is required to avoid clashes when
multiple Emacs processes are running.

Fixes https://yhetil.org/emacs-devel/87sfnfhm6v.fsf@yandex.com
2022-07-07 17:27:50 +08:00
Daniel Fleischer 7135982022 lisp/ob-latex.el: Remove duplicate line.
* lisp/ob-latex.el (org-babel-header-args:latex): duplicate line.
2022-07-05 17:00:12 +03:00
Ihor Radchenko 080462198f
ob-gnuplot.el: Make :cache argument work with :var assignments
* lisp/ob-core.el (org-babel-temporary-stable-directory): New variable
holding a temporary directory name that does not change between Emacs
sessions.
(org-babel-remove-temporary-stable-directory): New function removing
`org-babel-temporary-stable-directory' on Emacs shutdown.
(org-babel-temp-stable-file): Generate stable temporary file name for
object storage.  The file name is constant for equal objects.
(org-babel-execute-src-block): Explicitly identify that if the result
is cached.
* lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars): Make use of
`org-babel-stable-file' to make expanded body stable with respect to
:var assignments.

Fixes https://orgmode.org/list/87mtn1o5mn.fsf@ucl.ac.uk
2022-07-04 21:03:16 +08:00
Ihor Radchenko ad304faea1
org-attach-attach: Avoid linking to path starting with ~
* lisp/org-attach.el (org-attach-attach): Auto-expand ~ in the file
patch when using symlink (`lns') attach method.

Fixes https://orgmode.org/list/CAN_Dec_LyTKgSN_kiftee9GULM7FPER5frQFant3n_2C3cwM-g@mail.gmail.com
2022-07-04 21:01:43 +08:00
Sébastien Miquel 4e42500613 org.el: Fix the filling of regions containing lists
* lisp/org.el (org-setup-filling): Set fill-forward-paragraph-function.
(org--single-lines-list-is-paragraph): New internal variable.  Whether
a list with single lines items should be considered a single
paragraph.
(org--paragraph-at-point): use org--single-lines-list-is-paragraph.
(org-fill-paragraph): When an active region contains a list ensure
every item get filled.
* testing/lisp/test-org.el (test-org/fill-paragraph):
(test-org/fill-region): Test behaviour of fill-paragraph and
fill-region with an active region containing a list.

When filling paragraphs in a region, do not treat a list with single
lines items as a single paragraph.
2022-07-04 12:43:09 +02:00
Stefan Kangas 0ed0dea229
Delete some Emacs 24 compat code
Org mode supports Emacs 26 or newer:
https://orgmode.org/worg/org-maintenance.html#emacs-compatibility

* lisp/org-compat.el (org-set-transient-map)
(org-font-lock-ensure): Delete compat aliases.  Update callers.
(org-define-error): Redefine as obsolete function alias for
`define-error'.  Update callers.
(string-suffix-p): Delete compatibility definition.

* lisp/org-fold-core.el (org-fold-core--seq-partition): Delete private
function and update callers to use `seq-partition'.

* lisp/org-macs.el (org-without-partial-completion): Move from here...
* lisp/org-compat.el (org-without-partial-completion): ...to here.
Redefine as obsolete function alias for `progn'.
2022-07-02 12:10:00 +08:00
Stefan Kangas 41e19f1d7a
; Fix typos 2022-07-01 17:42:52 +08:00
Stefan Kangas 998a0aacd3
Improve look of agenda on graphical displays
* lisp/org-agenda.el (org-agenda-block-separator)
(org-agenda-time-grid, org-agenda-current-time-string): Improve
default visual elements on graphical displays.  Inspired by
org-modern.el by Daniel Mendler <mail@daniel-mendler.de>.
2022-06-30 15:25:32 +08:00
TEC 30953bd7b7
ox-latex: Pass on custom-env with src blocks
* lisp/ox-latex.el (org-latex-src-block): Fix an earlier oversight where
the custom environment was not passed on from `org-latex-src-block' to
`org-latex-src-block--custom'.
2022-06-29 23:18:55 +08:00
Stefan Kangas ea05f43435
* lisp/org-install.el: Delete file
See: <https://lists.gnu.org/r/emacs-orgmode/2022-06/msg00822.html>
2022-06-29 20:27:54 +08:00
Ihor Radchenko 26878e28e7
org-persist: Bump storage version to ignore bugged persisted data
* lisp/org-persist.el (org-persist--storage-version): Bump version to
avoid loading recently broken persisted element cache.
2022-06-29 13:49:34 +08:00
Ihor Radchenko aa5bc2c760
org-element-cache: Make sure that cache is correctly synced before saving
* lisp/org-element.el (org-element--cache-persist-before-write): Sync
cache before force-overwriting transient cache keys.
2022-06-29 09:16:01 +08:00
Ihor Radchenko eb796ae432
org-element-cache: Use `buffer-size' to detect silent modifications
* lisp/org-element.el (org-element--cache-diagnostics-modifications):
(org-element--cache-silent-modification-check): Remove variables that
were introduced to deal with false positives.  The new check is more
reliable.
(org-element--cache-last-buffer-size): New variable storing the last
known buffer size registered before/after handled buffer edits.
(org-element--cache-sync): Use `buffer-size' instead of
`buffer-chars-modified-tick' heuristics.  `buffer-size' may not catch
all the modifications, but it does not cause numerous
false-positives triggered by quail.  See Emacs Bug#51766 for the
detailed discussion.
(org-element--cache-before-change):
(org-element-cache-reset): Record buffer size before/after changes.
* lisp/org-macs.el (org-unique-local-variables): Do not carry over
buffer-local `org-element--cache-last-buffer-size' when cloning
buffer.
2022-06-29 09:15:52 +08:00
Ihor Radchenko d788fe9927
org-persist: Remove read cache introduced in f77800c68
* lisp/org-persist.el (org-persist--read-cache): Remove variable.
(org-persist-read):
(org-persist-write): Do not use `org-persist--read-cache'.  Using
`sx-hash-equal' as unique key indicating as-read data is not
reliable for deeply nested structures like `org-element--cache'.  The
`sx-hash-equal' returns the same value regardless of the cache
contents.  See Emacs Bug#56255.
2022-06-29 09:06:12 +08:00
Aaron L. Zeng ac7b8f9d2e
org-agenda-with-point-at-orig-entry: Fix body indentation
* lisp/org-agenda.el (org-agenda-with-point-at-orig-entry): Indent
like `org-with-point-at'.

TINYCHANGE
2022-06-27 20:46:13 +08:00
Daniel Fleischer 036939b5b1 lisp/ox-latex.el: indentation, small refactor
* lisp/ox-latex.el (org-latex-table-cell): indentation, parenthesis
convention, combining 2 `let' blocks.
2022-06-27 08:32:11 +03:00
Daniel Fleischer 321bfb88b5 lisp/ox-latex.el: tabbing code refactor
* lisp/ox-latex.el (org-latex-table, org-latex--align-string-tabbing)
(org-table--org-tabbing): simple documentation changes, code
indentation, code simplification.

See
https://lists.gnu.org/archive/html/emacs-orgmode/2022-06/msg00700.html.
2022-06-26 21:44:54 +03:00
Rudolf Adamkovič 15068ce30a
Fix incorrectly documented MathJax options
* lisp/org/ox-html.el (org-html-mathjax-options): Fix some incorrect
choices for `indent' and `autonumber' in the docstring.
2022-06-26 14:22:52 +08:00
Stefan Kangas e82ce43929
Add missing commands to org-agenda-custom-commands docstring
* lisp/org-agenda.el (org-agenda-custom-commands): Add missing
commands.  Add crossreference to the Info manual.
2022-06-26 12:52:18 +08:00
Stefan Kangas 13d97ee18c
Prefer "website" to "homepage"
Emacs now advises using "website" (instead of "homepage") and
consequently to use the "URL" comment header instead of "Homepage".

* README:
* README_ELPA:
* doc/org-guide.org (Creating Footnotes):
* doc/org-manual.org (Creating Footnotes):
* etc/styles/README (URL): Prefer "website" to "homepage".

* lisp/*.el:
* mk/org-fixup.el: Replace the "Homepage" header comment with "URL".
2022-06-26 10:10:48 +08:00
Ihor Radchenko 197d500607
org-element-cache: Setup before/after-change-functions in indirect buffers
* lisp/org-element.el (org-element--cache-setup-change-functions): New
function setting up `org-element--cache-before-change' and
`org-element--cache-after-change'.
(org-element-cache-reset): Setup before/after-change-functions inside
indirect buffers.
2022-06-25 16:10:22 +08:00
Ihor Radchenko 620fb24050
org-keys: Do not rely on deprecated boolean value of `window-system'
* lisp/org-keys.el: Do not rely on boolean value of `window-system'.
Such usage is deprecated.  Use `display-graphic-p' instead.
2022-06-25 16:05:16 +08:00
Ihor Radchenko bcfed0f341
org-cycle.el: New custom setting `org-cycle-hide-drawer-startup'
* lisp/org-cycle.el (org-cycle-hide-drawer-startup):
* lisp/org-cycle.el (org-cycle-set-startup-visibility): Add new
customization to control initial folding state of the drawers.
* lisp/org.el (org-startup-options): Provide #+STARTUP option for the
new setting.

Fixes https://list.orgmode.org/m235gww8wg.fsf@ntnu.no/T/#u
2022-06-25 13:17:45 +08:00
Robert Pluim 2b1b428918
org.el (org-read-date): Point to Info documentation
* lisp/org.el (org-read-date): Add reference to Info documentation,
mainly because that describes all the available calendar navigation
commands.
2022-06-23 21:27:21 +08:00
Ihor Radchenko dbcc2e04f9
Merge branch 'bugfix' 2022-06-23 21:21:19 +08:00
David Lukes 0dc27a8837
oc-basic.el: Stringify year from CSL-JSON date-parts
* lisp/oc-basic.el (org-cite-basic--parse-json): Make sure year
extracted from date-parts is returned as string.  Raise error if
original type other than number or string.

The stringifiation is motivated by errors like the following on Emacs 28
with nativecomp:

Error during redisplay: (jit-lock-function 544) signaled
(wrong-type-argument "Argument is not a string or a secondary string:
2007")

Additionally, the type check will warn users about problems in their
CSL-JSON bibliographies.

Fixes https://list.orgmode.org/875ykv4k2q.fsf@localhost/T/#t

TINYCHANGE
2022-06-23 21:20:53 +08:00
Ihor Radchenko 7c61a3a801
org-unfontify-region: Handle invisible parts of links
* lisp/org.el (org-unfontify-region): Reveal folded parts of links.

Fixes https://orgmode.org/list/m2wndakbk0.fsf@ntnu.no
2022-06-21 20:26:22 +08:00
Stefan Kangas e7e37c5b26 org-agenda.el: Improve docstrings of agenda date navigation commands
* lisp/org-agenda.el (org-agenda-goto-date)
(org-agenda-goto-today, org-agenda-later, org-agenda-earlier):
Improve documentation and add crossreferences.
2022-06-21 08:03:53 +03:00
Daniel Fleischer 4a0d951c64 ox-latex tabbing environment support
* lisp/ox-latex.el: New `org-latex--align-string-tabbing',
`org-table--org-tabbing' functions.  Modified `org-latex-table-cell' to
use optional tabbing delimiters.

* etc/ORG-NEWS: support in ox-latex for tabbing environment.

* doc/org-manual.org: mention support for new environment.

Created-by: Bob Vergauwen <emacs@vergauwen.me>
2022-06-21 07:34:21 +03:00