Commit graph

17889 commits

Author SHA1 Message Date
Ihor Radchenko 15658b8665
org-fold-core: New API to fold/restore buffer folding state
* lisp/org-fold-core.el (org-fold-core-get-regions): New function to
retrieve the list of folded regions in buffer.
(org-fold-core-regions): New function to set folding state in buffer
according to the list returned by `org-fold-core-get-regions'.
(org-fold-core-save-visibility): New macro, equivalent to
`org-fold-save-outline-visibility'.
2022-08-13 14:59:01 +08:00
Ihor Radchenko 687d5702d2
org-fold-core-next-folding-state-change: Fix when using overlays
* lisp/org-fold-core.el (org-fold-core-next-folding-state-change):
Consider overlay properties.
2022-08-13 14:55:50 +08:00
Hraban Luyat 8a781d35dc
ob-tangle.el: fix ‘:comments noweb’ double linking
* lisp/ob-tangle.el: Refactor the double implementation to a single
helper function.  This avoids the double link wrapping.

* testing/lisp/test-ob-tangle.el: Add unit tests.

Babel tangle allows inserting comments at the tangled site which link
back to the source in the org file.  This linking was implemented
twice, to handle separate cases, but when using ‘:comments noweb’ it
ended up going through both codepaths.  This resulted in doubly
wrapped links.

By refactoring all link generation into a single function, this double
wrapping is avoided.

Example file, /tmp/test.org:

    * Inner
    #+name: inner
    #+begin_src emacs-lisp
    2
    #+end_src

    * Main
    #+header: :tangle test.el :comments noweb :noweb yes
    #+begin_src emacs-lisp
    1
    <<inner>>
    #+end_src

Before:

    ;; [[file:test.org::*Main][Main:1]]
    1
    ;; [[[[file:/tmp/test.org::inner][inner]]][inner]]
    2
    ;; inner ends here
    ;; Main:1 ends here

After:

    ;; [[file:test.org::*Main][Main:1]]
    1
    ;; [[file:test.org::inner][inner]]
    2
    ;; inner ends here
    ;; Main:1 ends here
2022-08-13 14:39:09 +08:00
Ihor Radchenko 6acc58c9c6
* lisp/org.el (org-get-buffer-tags): Remove text properties from tags
Do not preserve buffer text properties.  They may will be shown in the
completion as well, which is not expected by users.

Fixes https://orgmode.org/list/CAKJdtO_0aUmiKFjS34hoD525vMFkUJuVCCzGrFfR_Lt2_Vm58g@mail.gmail.com
2022-08-11 19:38:33 +08:00
Ihor Radchenko ad802a923b
Merge branch 'bugfix' 2022-08-11 13:34:16 +08:00
Ihor Radchenko 70a311b001
ox-icalendar: Avoid processing ignored elements
* lisp/ox-icalendar.el (icalendar): Use nil transcoders instead of
`ignore' for ignored element types.  Otherwise, `org-export-data'
still exports the ignored element contents, including resolving links,
and the result is ignored.  The contents might contain broken links
and hence lead to errors despite the whole element not supposed to be
exported.

Fixes https://orgmode.org/list/45aa417a-7eb1-1070-b0dd-17bdd7d1448f@mailbox.org
2022-08-11 13:33:15 +08:00
Tom Gillespie 76643256f2
ol-man: Set window point not buffer point and wait before search
* lisp/ol-man.el (org-man-open): Set window point not buffer point and
wait before search.  When passed man:path::SEARCH `org-man-open' uses
`search-forward' to jump to the location of e.g. a heading.  Prior to
this fix it only used `search-forward', which will not change the
point of the cursor in the window, meaning that even if there is a
match it will not appear.  Use `accept-process-output' to block until
the manpage finishes rendering before searching the buffer so that
there will be something to find.
2022-08-10 19:46:54 +08:00
András Simonyi be7f61171f
oc-csl: Add missing function declaration
* lisp/oc-csl.el (citeproc-add-subbib-filters): Declare function.
2022-08-09 21:18:17 +08:00
András Simonyi c7d484130c
oc-csl: Add support for title, locators and bibentry citation styles
* lisp/oc-csl.el: Register the newly added citation styles "title",
"locators and "bibentry" as supported by the "csl" export processor.
(org-cite-csl--create-structure-params): Add support for the creation
of citation structures with the new citation styles.
2022-08-09 20:00:28 +08:00
Hanno Perrey 4db67da68d
org.el: Improve automatic fast tag selection keys
* lisp/org.el (org-fast-tag-selection): After automatically assigning
a-z as keys for selection, offer A-Z range.  Continue with characters up
to tilde character before showing only blanks.  Replaces previous logic
where also hard-to-type characters were assigned.

TINYCHANGE
2022-08-08 21:17:03 +08:00
Ihor Radchenko 00adad9357
org-src: Fix invisible text in src block fontification
* lisp/org-src.el (org-src-font-lock-fontify-block): If fontified text
has `invisible' text property, avoid interfering with Org folding
making the invisibility of lower priority compared to folding.

Fixes https://orgmode.org/list/87zgghrsd2.fsf@gmail.com
2022-08-07 18:33:11 +08:00
Ihor Radchenko a303a794f8
Support interactive editing of comment blocks
* lisp/org-src.el (org-edit-comment-block): New command to edit
comment block elements.  The command auto-escapes Org markup inside.
(org-src--contents-area):
* lisp/org.el (org-insert-structure-template):
(org-edit-special): Support comment blocks.
* etc/ORG-NEWS (Interactive commands now support escaping text inside
comment blocks):
(New command ~org-edit-comment-block~ to edit comment block at point):
Document the new features.

See https://orgmode.org/list/87y1wc3ruw.fsf@mat.ucm.es
2022-08-07 17:39:08 +08:00
Joseph Turner 9cc60dee48
lisp/ob-plantuml.el: Insert results in buffer
When :results header arg is set to a value that doesn't include
"file", insert txt output in buffer below src block.

TINYCHANGE
2022-08-06 16:20:10 +08:00
Ihor Radchenko a0b21e3f1c
* lisp/org.el (org-set-tags-command): Put local tags on top
See https://orgmode.org/list/7AB4F327-24D0-4BA5-BD20-B329D4CBBF0A@hoowl.se
2022-08-06 15:59:47 +08:00
Juan Manuel Macias e47bcb0213
lisp/ox-latex.el: `org-latex-language-alist' improved
* (org-latex-language-alist): Alist between language code and
corresponding properties, such as Babel/Polyglossia options and
language names.  Each element of the list consists of a cons cell,
where car is the language code and cdr is a property list.
* (org-latex-guess-babel-language): Modified to adapt the function to
the new structure of `org-latex-language-alist'.
* (org-latex-guess-polyglossia-language): Modified to adapt the function to
the new structure of `org-latex-language-alist'.
* (org-latex--format-spec): Modified to adapt the function to
the new structure of `org-latex-language-alist'.
2022-08-06 15:08:02 +08:00
Ihor Radchenko 22eedaea86
lisp/ol.el: Fix some docstring style issues
* lisp/ol.el (org-store-link): Start sentence from capital letter.
(org-insert-link): Add double space between sentences.
2022-08-06 14:01:44 +08:00
Ihor Radchenko 3858a97ac3
* lisp/ol.el (org-insert-link): Fix edge case when ALL-PREFIXES is nil
Fix `rx-to-string' error when no link types are registered in Org.

See https://orgmode.org/list/8bbccdb4-52f4-b9b5-eb10-252bb15108ec@gmail.com
2022-08-06 13:49:08 +08:00
Hugo Heagren e3a05d09b7
ol.el: add description format parameter to org-link-parameters
* ol.el (org-link-parameters): Add parameter `:insert-description', a
string or a function.
* (org-insert-link): If no description is provided (pre-existing or as
an argument), next option is to use the `:insert-description' (if
non-nil) parameter to generate one.
* (org-link-make-description-function): Add documentation to describe
behaviour of nil return value, like that of `:insert-description'.

Default descriptions are predictable within a link type, but because
link types are quite diverse, are NOT predictable across many types.
A type-parameter is thus a good place to store information on the
default description.
2022-08-06 13:46:31 +08:00
Ihor Radchenko 5a1b050310
org-colview: Do not rely on `current-column' ignoring display properties
* lisp/org-macs.el (org-current-text-column): New macro calculating
current column without accounting display text properties.

* lisp/org-colview.el (org-columns-check-computed):
(org-columns-next-allowed-value):
(org-columns-new):
(org-columns-delete):
(org-columns-edit-attributes):
(org-columns-widen):
(org-columns-move-right):
(org-columns-move-left):
(org-columns-update): Use the new macro when calculating point
position in the column view table overlay.  Do _not_ use the new
macro when we want to get the visual column position of the point.

Fixes "test-org-colview/" failures on Emacs 29 after Emacs commit
4243747b1b8c3b7e3463822804b32e83febe2878:

;; Fix 'current-column' in the presence of display strings

;; * src/indent.c (check_display_width): Support calculation of width
;; of 'display' properties whose values are strings.  This fixes the
;; value returned by 'current-column' when display strings are
;; present between BOL and point.  (Bug#53795)

See https://orgmode.org/list/CACnOyijQc7BDDtrYQb+=VoGWkpWAyMu7O4qsvGpsU6SCgwiM8Q@mail.gmail.com
2022-08-06 13:33:44 +08:00
Ihor Radchenko 8f5bf17255
org-id-update-locations: Scan all the open Org buffers
* lisp/org-id.el (org-id-update-id-locations): Always scan all the
open Org file buffers for IDs.

Fixes https://orgmode.org/list/87r11zifjy.fsf@gmail.com
2022-08-05 20:43:11 +08:00
Ihor Radchenko 215de6176b
Partially revert "org-mode: Make local variables effective during Org startup"
This reverts commit e22b4eb7aa.

See
https://list.orgmode.org/87r11wkmew.fsf@ucl.ac.uk/T/#mab6359ed2107d5515c6bb6b266551f0c5049ceca

The problem with the commit is that correctly loading local variables
early requires re-implementing all the built-in tricks done by Emacs,
like not enabling local variables in temp buffers or non-file buffers.

In addition, even if we call `hack-local-variables' manually, Emacs
will repeat the normal call later, possibly asking for non-safe
variables twice.

In conclusion, the whole idea of manual triggering local variables is
fragile and should better be handled by Emacs itself via stable API.

testing/.dir-locals.el is kept.
2022-08-05 19:57:36 +08:00
TEC 4702a73031
org: Fix resource prompt in non-file buffers
* lisp/org.el (org--confirm-resource-safe): When `buffer-file-name' is
nil, skip over file-specific behaviour.
2022-08-03 21:39:24 +08:00
Étienne Deparis 79dfb16d52
org-id: Fix `org-id-locations' variable name in error message
* lisp/org-id.el (org-id-locations-load): Update error message.

Hi,

While doing some stuff with org-mode, I noticed the error message "Could
not read ‘org-id-values’ from ~/.emacs.d/whatever, setting it to nil".

I quicly understood it’s related to org-id, but the only occurence I
found for ‘org-id-values’ was in that exact error message.

I wonder if this is not a little typo and the error message should speak
of ‘ord-id-locations’ instead?

This patch fix that problem.

I’ve signed the GNU paper to make patch to GNU project if it matters. I can
send a copy of it to anyone if needed.

As this is my first contribution, I hope I do it well.

Have a nice day,

Étienne

Signed-off-by: Étienne Deparis <etienne@depar.is>
2022-08-03 18:00:10 +08:00
Ihor Radchenko fde93abb8c
org-mode: Prevent early fontification
* lisp/org.el (org-mode): Avoid triggering fontification when
`hack-local-variables' popup window is displayed.  Font-lock settings
are not configured yet at this point.

Fixes https://orgmode.org/list/87r120kodw.fsf@yandex.com
2022-08-03 17:33:31 +08:00
Daniel Fleischer 5a49cc5f4f ox-latex: comment on \date LaTeX macro
* lisp/ox-latex.el (org-latex-template): short comment about the `\date`
macro, its default and how to override the default date.

TINYCHANGE
2022-08-01 19:22:03 +03:00
Ihor Radchenko 0599ddfd41
Revert "lisp/ox-latex: Omit empty date"
This reverts commit a753d0dd26.

Omitting \date in the LaTeX source makes LaTeX print today's date by
default, which is not consistent with :with-date export option.

See https://list.orgmode.org/m2v8rdguil.fsf@gmail.com/T/#t
2022-08-01 06:47:37 +08:00
Ihor Radchenko e22b4eb7aa
org-mode: Make local variables effective during Org startup
* lisp/org.el (org-mode): Call `hack-local-variables' early during Org
mode startup.  This way, Org startup options will regard local
variable settings.

* testing/.dir-locals.el: Create a stub dir-locals file to prevent
tests from being affected by directory-local settings of the root Org
repo folder.

Fixes
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
2022-07-31 18:17:53 +08:00
Ihor Radchenko 4d0295b315
Avoid ignoring LaTeX export output errors
* lisp/org-macs.el (org-compile-file): When PROCESS is a list, keep
output of all the listed commands, not just the last one.
* lisp/ox-latex.el (org-latex-pdf-process): Clarify that the process
output is parsed to detect compilation errors/warnings.
2022-07-31 15:30:51 +08:00
Ihor Radchenko b4d7a24f07
Make org-shiftmetaleft/org-shiftmetaright honour shift-select on MacOS
* lisp/org.el (org-shiftmetaleft):
(org-shiftmetaright): Honour shift-select bound to meta-arrow on
MacOS when `org-support-shift-select' is non-nil.

Fixes https://orgmode.org/list/CAEOO5Tdg6sdjNfAg=J_DVQ50xx1oxaFaVyyYnda6O_-t3hG2jg@mail.gmail.com
2022-07-31 15:26:40 +08:00
Mikhail Skorzhinskii 31b3b164d1
ox-icalendar.el: create alarm at event time
* lisp/ox-icalendar.el (org-icalendar-force-alarm): Option to set alarm
even if alarm time is set to zero.
* lisp/ox-icalendar.el (org-icalendar--valarm): create VALARM at the
event start if the alarm time is set to zero and
`org-icalendar-force-alarm' is set to true.

TINYCHANGE
2022-07-31 14:52:19 +08:00
Ihor Radchenko 0435fea9a8
org-babel-expand-noweb-references: Cache block info
* lisp/ob-core.el (org-babel-expand-noweb-references--cache):
(org-babel-expand-noweb-references--cache-buffer): New variables
storing info cache.
(org-babel-expand-noweb-references): Make use of global info cache to
avoid extra parsing.  Use `cl-macrolet' instead of defining transient
lambda functions on every call.
2022-07-31 14:28:04 +08:00
Ihor Radchenko 0d3bf2ed49
org-babel-tangle-single-block: Do not create comment link when not requested
* lisp/ob-tangle.el (org-babel-tangle-single-block): Do not spend
extra time creating link to source block when :comments is set to
"no".
2022-07-31 14:22:11 +08:00
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
Ihor Radchenko f77800c68b
org-persist: Avoid overwriting / re-reading unchanged persisted data
* lisp/org-persist.el (org-persist--read-cache):
(org-persist--write-cache): New variables holding previously written /
read data.
(org-persist-read): Avoid re-reading data from FS when the writing has
been performed in the same Emacs session.
(org-persist-write): Do not overwrite unchanged data.
2022-06-21 09:46:59 +08:00
Ihor Radchenko d687aa1786
org-persist: Display read errors in echo area
* lisp/org-persist.el (org-persist--read-elisp-file): Do not silently
ignore "Invalid read syntax" error.  Report it via message.  Yet
making the error less intrusive compared to `warn'.
2022-06-21 09:46:58 +08:00
Ihor Radchenko 1c54d75cca
org-persist--gc-expired-p: Fix expiry check
* lisp/org-persist.el (org-persist--gc-expired-p): Fix comparison when
expiry date is set to number of days.  The old code flipped the check
and treated all the recent entries as expired.
2022-06-21 09:46:57 +08:00
Stefan Kangas 45174d62b9
Remove XEmacs and ancient Emacs compat code
* lisp/org-colview.el (org-columns-remove-overlays):
* lisp/org-ctags.el (org-ctags-find-tag-interactive):
* lisp/org-macs.el (org-fit-window-to-buffer):
* lisp/org-mouse.el (org-mouse-show-context-menu):
* lisp/org-table.el (org-table-fedit-lisp-indent):
* lisp/org.el (org-version, org-reload):
* lisp/ox-html.el (org-html-template, org-html--build-meta-info):
Remove Emacs 21 and 22 compat code.

* lisp/ol-eww.el (org-eww-copy-for-org-mode):
* lisp/ol-w3m.el (org-w3m-copy-for-org-mode):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-macs.el (org-fit-window-to-buffer):
* lisp/org-refile.el (org-refile):
* lisp/org.el (org-change-tag-in-region): Remove XEmacs compat code.

* lisp/org-goto.el (org-goto--set-map):
* lisp/org-macs.el (org-fit-window-to-buffer):
* lisp/org-table.el (orgtbl-mode):
* lisp/org.el (org-setup-filling): Remove XEmacs or Emacs 19 or 20
compat code.  (It is one of these; not clear which.)
2022-06-18 15:43:30 +08:00
Ihor Radchenko 9632401dc6
Auto-Upcase/downcase #+begin/#+end in structure templates
* lisp/org-tempo.el (org-tempo-add-block):
* lisp/org.el (org-insert-structure-template): When inserting
 #+begin_type/#+end_type, follow type's case.  TYPE will become
 #+BEGIN_TYPE and type will become #+bein_type.

(org-insert-structure-template): Make sure that we use
case-insensitive match even when user changes case-fold-search value.

(org-structure-template-alist): Clarify selection of #+BEGIN/END
vs. #+begin/end in the docstring.

* etc/ORG-NEWS (Structure templates now respect case used in
~org-structure-template-alist~): Document the change.
2022-06-18 14:25:53 +08:00
Ihor Radchenko 65e19a0812
org-table.el: Fix orgtbl-mode not remapping delete key
* lisp/org-table.el (orgtbl-setup): Remap `delete-forward-char' in
addition to `delete-char'.  The former is called in Emacs >26.

Partially fixes
https://orgmode.org/list/1AD1B9B7-5A15-4F86-9274-B04B83694C85@misasa.okayama-u.ac.jp
2022-06-18 14:18:00 +08:00
Allen Li bfd63cc4f2
org: Improve org-todo handling of negative prefix args
* lisp/org.el (org-todo): Handle -1 prefix args consistently and error
on other negative args.
2022-06-18 14:07:11 +08:00
Sébastien Miquel 9fb9a2bdfb
org.el (org-format-latex-header): Put DEFAULT-PACKAGES before PACKAGES
* lisp/org.el (org-format-latex-header): Put DEFAULT-PACKAGES before
PACKAGES, as per org-latex-packages-alist's documentation.

`org-format-latex-header' is mostly used to generate in-buffer images
from LaTeX fragments.  For LaTeX document export, the header is
generated by `org-splice-latex-header' ond `org-latex-classes' instead
and the default and documented behaviour is to insert DEFAULT-PACKAGES
before PACKAGES.

See also
https://list.orgmode.org/877d5gg5rt.fsf@localhost/T/#m2ad2f3b1509e1af72016e8e6fad3557ff3083046
2022-06-18 12:46:53 +08:00
Ihor Radchenko 811deae32d
Revert "org-export-data: Concatenate strings in temporary buffer for performance"
This reverts commit a158b263a6.
The commit actually makes not measurable performance difference.
2022-06-17 19:32:44 +08:00
Ihor Radchenko 9b00f4bf1d
org-persist: Fix expiry check
* lisp/org-persist.el (org-persist--gc-expired-p): Fix incorrect plist
key.
2022-06-17 19:23:28 +08:00
Robert Pluim e9da29b6fa
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-06-16 20:51:02 +08:00
Ihor Radchenko 707d3a093b
org-cycle-list-bullet: Preserve relative point position
* lisp/org-list.el (org-cycle-list-bullet): Keep point position
relative to bullet beginning/end when changing the list bullet.

* testing/lisp/test-org-list.el (test-org-list/cycle-bullet): Add
tests.

Fixes https://orgmode.org/list/m2wndjfi32.fsf@gmail.com
2022-06-16 20:08:49 +08:00
Ihor Radchenko 3bbbf77f36
org-babel-exp-process-buffer: Improve performance
* lisp/ob-exp.el (org-babel-exp-src-block): New optional argument
providing ELEMENT at point.
(org-babel-exp-code-template): Use lower-case #+begin/#+end lines to
avoid triggering source code block changes when the blocks are
exported with :exports code and also contain lower-case
 #+begin/#+end.  We prefer lower-case default because other parts of
 Org, like `org-insert-structure-template' default to lower-case as
 well.
(org-babel-exp-process-buffer): Do no disable cache as changes are not
expected to be as frequent anymore.  Pass pre-calculated element at
point to inner function calls to `org-in-commented-heading-p',
`org-in-archived-heading-p', `org-element-context', and
`org-babel-exp-src-block'.  Do not force-replace source block contents
when no change is required.
* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
(ob-export/body-with-coderef):
(ob-exp/src-block-with-affiliated-keyword): Update tests according to
the new `org-babel-exp-code-template'.
2022-06-16 13:21:39 +08:00
Ihor Radchenko 8f59e8d93f
Fix native-comp warnings
* lisp/org-fold.el (org-fold-show-set-visibility--text-properties):
Resolve unused variable warning.

* lisp/ob-core.el (org-attach-dir):
* lisp/ob-latex.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/org.el (org-agenda-todo-yesterday):
* lisp/ox-ascii.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-html.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-icalendar.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-latex.el (engrave-faces-latex-gen-preamble-line):
(engrave-faces-get-theme):
(engrave-faces-latex-output-style):
(engrave-faces-current-preset-style):
(engrave-faces-latex-mathescape):
* lisp/ox-odt.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-publish.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading): Add declarations.
2022-06-16 13:19:10 +08:00
Ihor Radchenko e273fa96e5
Fix function declarations
* lisp/org-macro.el (org-file-contents):
* lisp/ob-exp.el (org-in-commented-heading-p):
(org-in-archived-heading-p): Add missing argument to function
declarations.
2022-06-16 12:35:52 +08:00
Ihor Radchenko b061e7b61c
org-cite-list-citations: Cache footnote-definition searches
* lisp/oc.el (org-cite-list-citations): Avoid quadratic complexity.
Pre-calculate list of all footnote definitions and cache the footnote
label search hits.  Do not make `org-element-map' accumulate unused
result.
2022-06-16 10:43:29 +08:00
Ihor Radchenko 37a447ae08
org-element-map: Avoid repetitive `plist-get' call
* lisp/org-element.el (org-element-map): Do not call `(plist-get info
:ignore-list)' on every iteration.
2022-06-16 09:28:27 +08:00
Ihor Radchenko a158b263a6
org-export-data: Concatenate strings in temporary buffer for performance
* lisp/ox.el (org-export-data): Use temporary buffer to collect export
data instead of `mapconcat'.  Using buffer puts less load on garbage
collector.
2022-06-16 08:32:25 +08:00