Commit Graph

17790 Commits

Author SHA1 Message Date
Ihor Radchenko 01d84f2e50
org-fold-initialize: Ensure back-compatibility when using overlays
* lisp/org-fold.el (org-fold-initialize): Use back-compatible property
values for overlays folds.
2022-08-13 15:02:48 +08:00
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