Commit Graph

5377 Commits

Author SHA1 Message Date
Ihor Radchenko 70970dff8d
org-before-first-heading-p: Use cache and clarify docstring 2022-01-25 22:53:08 +08:00
Ihor Radchenko 5ac2b2291b
Make sure that 'inherited text property in tags does not propagate to cache
* lisp/org.el (org--get-local-tags, org-get-tags): Explicitly copy
cached tag strings to make sure that modifications are not propagated
to cached tag values.

Fixes
https://list.orgmode.org/CAFyQvY2HkE5p00wQ1QycQCdtwy3drRB_naK8wenrKwVT-cbH7g@mail.gmail.com/T/#t
2022-01-21 19:47:18 +08:00
Ihor Radchenko 37edef8bbd
org-mode: Initialise cache before initialising file-local regexps
* lisp/org.el (org-mode): Initialise cache earlier, allowing the
file-local settings to be taken from persistent cache when
possible.  Also, bind `org-mode-loading' while org-mode is loading.
* lisp/ol.el (org-update-radio-target-regexp): Do not try to refresh
cache when we are loading file for the first time.
2022-01-19 11:58:17 +08:00
Marco Wahl 0725237eed org: Small simplification
* lisp/org.el (org-metaup, org-metadown): Remove unnecessary min/max computation.
2022-01-18 09:47:53 +01:00
Ihor Radchenko a9b2e262cd
Merge branch 'bugfix' 2022-01-12 21:11:33 +08:00
Ihor Radchenko 34b0d95327
org-in-src-block-p: Do not rely on fontification
* lisp/org.el (org-in-src-block-p): New optional argument ELEMENT.
The code now relies on org-element API to check if we are inside
src-block.

Partially fixes https://list.orgmode.org/20220101200103.GB29829@itccanarias.org/T/#t
2022-01-12 21:08:41 +08:00
Kyle Meyer aae2ac3a68 Merge branch 'bugfix' 2022-01-01 15:21:37 -05:00
Kyle Meyer 5a229cbc44 Update copyright year to 2022 2022-01-01 15:17:08 -05:00
Ihor Radchenko 06f58e4759
org-element-cache-map: Fix when FUNC deletes current element
* lisp/org-element.el (org-element-cache-map-continue-from): New
variable forcing `org-element-cache-map' to continue from a custom
point in buffer.
(org-element-cache-map): Add support for
`org-element-cache-map-continue-from'.  Update docstring accordingly.
Also, make sure that mapping terminates correctly when FUNC deletes
all elements in buffer.
* testing/lisp/test-org.el (test-org/map-entries): Add test.

Fixes https://orgmode.org/list/CADywB5KOJ1p0NpvA=iX-ybHsO=huGA8qL3xMpUTETmS2qp7_ng@mail.gmail.com
2022-01-01 14:13:26 +08:00
Bastien fbff082f73 Update to version 9.5.2
* lisp/org.el: Update to version 9.5.2.
2021-12-24 21:01:49 +01:00
Ihor Radchenko 410afd6f37
Revert "org-do-emphasis-faces: Never treat closing marker as next opening marker"
This reverts commit fa315986a1.

The commit broke fontification of nested emphasis like
/italic *bold* more italic/.
2021-12-22 23:51:51 +08:00
Ihor Radchenko de022ed654
Merge branch 'bugfix' 2021-12-16 21:43:56 +08:00
Ihor Radchenko 7ec9e37117
org-tree-to-indirect-buffer: Fix when last headline is empty at point-max
* lisp/org.el (org-tree-to-indirect-buffer): Consider scenario when
`org-end-of-subtree' with 't second arg moves to `point-max' at the
end of an empty headline.  We do not need to move back the point then.

Fixes https://orgmode.org/list/CA+AFVDUF3RzA-mnoAp8yFv-bppoYJfJo=Wa8qmNQhV-tfHHB+w@mail.gmail.com
2021-12-16 21:39:24 +08:00
Kyle Meyer 0c9b30e961 Merge branch 'bugfix' 2021-12-11 12:40:39 -05:00
Stefan Kangas 9ca3bc3730 Backport commit 26fb4168b from Emacs
; Prefer HTTPS in more URLs
26fb4168b884eeb910580c42e87efb73399019c9
Stefan Kangas
Thu Dec 9 16:26:04 2021 +0100
2021-12-11 12:26:28 -05:00
Ihor Radchenko 0350c7dd71
org.el: Avoid excessive memory usage by effort text properties
* lisp/org.el (org-set-effort):
(org-property-next-allowed-value): Do not use text properties cache
for `effort' and `effort-minutes' when org-element-cache is active.
These text properties are superceded by element cache and their only
effect (when cache is active) is extra load on Emacs garbage collector
leading to overall Emacs slowdown.
* lisp/org-clock.el (org-clock-in): Use `org-element-use-cache'
instead of `org-element--cache-active-p' to check if element cache is
active. The latter is too precise and may trigger
`org-refresh-effort-properties' when cache is temporarily disabled by
internal calls.
2021-12-11 10:08:39 +08:00
Kyle Meyer f1929afc66 Merge branch 'bugfix' 2021-12-09 22:45:02 -05:00
Kyle Meyer 4aca51fcbe org-priority: Fix SPC handling for numeric priorities (bug#52341)
* lisp/org.el (org-priority): When reading numeric priorities, provide
special handling of SPC so that it clears the priority, as advertised.

If the user has configured numeric priorities and tries to clear a
priority by inputting SPC at the prompt, org-priority feeds " " to
string-to-number and ends up with 0 instead of the ?\s (32) that's
used downstream to signal "remove".  Explicitly check for " " and
translate it to ?\s.

Reported-by: "Bruce E. Robertson" <brucer42@gmail.com>
Link: https://list.orgmode.org/877dch89s1.fsf@kyleam.com/
2021-12-09 22:42:56 -05:00
Nicolas Goaziou 2dc4a4da94 Do not require `oc-basic'
Org will take care of loading it when appropriate.
2021-12-05 19:05:49 +01:00
Nicolas Goaziou eaa7817b31 org: Try loading activate processor when initializing fontification
* lisp/org.el (org-set-font-lock-defaults): Try registering activate
processor if appropriate.
2021-12-05 19:04:34 +01:00
TEC bb6f328847
org-src: Implement native inline src fontification
* lisp/org-src.el (org-fontify-inline-src-blocks,
org-fontify-inline-src-blocks-1): Create a function to search the buffer
up to a limit for inline src blocks.  Light fontification is applied to
matched inline src blocks.  When `org-src-fontify-natively' is
set, `org-src-font-lock-fontify-block' is applied to the content.

* lisp/org.el (org-set-font-lock-defaults): Add
`org-fontify-inline-src-blocks' to `org-font-lock-extra-keywords', which
is locally bound inside `org-set-font-lock-defaults'.

* lisp/org-faces.el: Introduce a new face `org-inline-src-block' which
inherits from `org-block' by default.
2021-11-30 12:14:11 +08:00
Stefan Kangas 36086a4f49 Backport commit 1fffe9a21 from Emacs
; * lisp/org/org.el: Fix version header.
1fffe9a210d328559da2af8facbb75286a31c74e
Stefan Kangas
Sun Nov 28 14:54:24 2021 +0100
2021-11-28 10:46:50 -05:00
Ihor Radchenko dd173bf451
org-get-buffer-tags: Use cache 2021-11-23 21:14:43 +08:00
Matt Huszagh 912cf21494
org.el: Fix missing arg in string-match-p call
* lisp/org.el (org-display-inline-image--width): `string-match-p'
requires two arguments, but the second one was missing.
2021-11-23 13:40:40 +08:00
Kyle Meyer 27f26f7829 org-display-inline-image--width: Fix syntax error from last commit
* lisp/org.el (org-display-inline-image--width): Fix unbalanced
parentheses and reference to free variable introduced in last commit.
2021-11-22 23:44:15 -05:00
TEC 4514a324c8
org: More carefully interpret image width attrs
* lisp/org.el (org-display-inline-image--width): Before attempting to
interpret a :width attribute numerically, check that it indeed starts
with a digit and use the default value given by `org-image-actual-width'
if not.  However, if a value of "t" is given, treat this as if
`org-image-actual-width' were "t" and just use the image's pixel width.

This change fixes a strange behaviour where a non-numeric width would
previously display the image with zero width.
2021-11-23 01:52:19 +08:00
Ihor Radchenko 7a14d6035c
Fix element property queries for inlinetasks
* lisp/org.el (org-get-tags): Do not ignore local tags in inlinetasks.
(org-in-commented-heading-p): Do not ignore commented inlinetasks.
* testing/lisp/test-org.el (test-org/get-tags): Add tests for
inlinetasks.

Fixes https://list.orgmode.org/CAKJdtO8-KkVvhcviTqhi+DMZmSK=o37jn1jJPM9qxcuXZPnGgw@mail.gmail.com/T/#u
2021-11-22 19:34:21 +08:00
Matt Huszagh cd3e138ee5
org.el: Improve inline image width calculation
* lisp/org.el (org-display-inline-image--width): When
display-line-numbers-width is nil, the width is computed dynamically.
This does not mean that the line number width is necessarily 0.
2021-11-22 03:13:04 +08:00
Kyle Meyer 58cc9efd7d Update customize-package-emacs-version-alist
* lisp/org.el (customize-package-emacs-version-alist): Map Org 9.6 to
Emacs 29.1.

Emacs 28.1 is nearing release.  The earliest Emacs version that Org
9.6 would be synced with is 29.1.
2021-11-20 14:36:10 -05:00
Sébastien Miquel 975462e653 Small fix to image width computation
org.el (org-display-inline-image--width): The variable
display-line-numbers-width is nil by default.
2021-11-03 17:23:56 +01:00
Ihor Radchenko 91523479fb
org-scan-tags: Fix `org-agenda-change-all-lines' when prefix has effort
* lisp/org.el (org-scan-tags): Add `effort' and `effort-minutes' to
full agenda line, not just its heading string part.
`org-agenda-change-all-lines' expects the properties to be at BOL.
2021-10-27 23:44:41 +08:00
Ihor Radchenko cc3df3af2a
org--backward-paragraph-once: Fix infinite loop at first element in section
* lisp/org.el (org--backward-paragraph-once): Do not consider section
parent as greater element.  section elements starts at the same point
with its first child and we do not want to "move" from beginning of
child to the beginning of the section.

Fixes https://list.orgmode.org/87cznsnql6.fsf@localhost/T/#t
2021-10-27 23:09:02 +08:00
Ihor Radchenko 52cdf53328
Revert "org-do-emphasis-faces: Never treat closing marker as next opening marker"
This reverts commit fa315986a1.

The commit broke fontification of nested emphasis like
/italic *bold* more italic/.
2021-10-27 14:51:29 +08:00
Ihor Radchenko f2b52f411c
org.el/org-scan-tags: Fix effort in tags agenda views
* lisp/org.el (org-scan-tags): Manually add effort and effort-minutes
properties to be used by agenda.
2021-10-27 11:11:03 +08:00
TEC 9dc08c9093
org: Don't change image size based on font size
* lisp/org.el (org--create-inline-image): Set :scale parameter to 1 to
prevent font-size based rescaling.

When `create-image' is called without the :scale parameter, the image
size is expanded based on the default font size (if it is larger than
10px).  When displaying images with a specified width in Org buffers,
either in pixels or proportional to the text width, this width should
not be modified according the to font size.  Giving a :scale parameter
of 1 prevents this font-size based rescaling.
2021-10-25 21:48:04 +08:00
Ihor Radchenko 4c6595d2b4
org-in-archived-heading-p: Use ELEMENT arg more optimally
* lisp/org.el (org-in-archived-heading-p): Do not check for point
position when ELEMENT is provided and use ELEMENT when checking
archive status of ancestors.
2021-10-25 19:15:14 +08:00
Ihor Radchenko 5f4fd0880a
org--get-expected-indentation: Consider section parent type
* lisp/org.el (org--get-expected-indentation): Consider new :parent
structure when `org-element-at-point' returns parent section and
headline elements.

* testing/lisp/test-org.el (test-org/indent-region): Add test.

Fixes https://list.orgmode.org/87pmrupu0s.fsf@gmail.com/T/#t
2021-10-24 19:46:00 +08:00
Nicolas Goaziou d3143feaf7 Fix sloppiness when collecting keywords
* lisp/org.el (org--collect-keywords-1): Use an accurate
function instead of an approximation. Accuracy trumps speed when parsing.
* testing/lisp/test-org.el (test-org/collect-keywords): New test.
2021-10-23 11:18:10 +02:00
Ihor Radchenko f4bcc0cc56
Merge branch 'main' into feature/org-element-cache-new 2021-10-17 14:49:59 +08:00
Ihor Radchenko 004ac14a5b
Fix compatibility with Emacs 26
* lisp/org-compat.el (org-file-name-concat): Do not use
`string-empty-p'.
(combine-change-calls): Create a stub when `combine-change-calls' were
not yet available.
(org-replace-buffer-contents): Add compatibility function for
`replace-buffer-contents'.

* lisp/org-element.el (org-element--current-element): Do not use
`if-let'.
* lisp/org-persist.el (org-persist-gc): Do not use `when-let'.
* lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'.
* lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use
`org-replace-buffer-contents'.

* lisp/org.el (org-narrow-to-subtree, org--property-local-values,
org-entry-get-with-inheritance, org-in-commented-heading-p,
org-up-heading-safe, org-goto-first-child): Do not use
`if-let'/`when-let'.

* testing/org-test.el (org-test-at-time): Fallback to old
`decode-time' specification in older Emacs.
2021-10-17 14:34:10 +08:00
Ihor Radchenko abe7222ed8
Add declares to suppress compiler warnings 2021-10-17 00:01:56 +08:00
Ihor Radchenko 3c4290e668
org.el/org-scan-tags: Make use of fast `org-element-cache-map' 2021-10-17 00:00:01 +08:00
Ihor Radchenko 85e0a69567
Avoid frequent cache updates in some functions
* lisp/org.el (org-promote-subtree, org-demote-subtree,
org-paste-subtree, org--align-node-property): Group buffer changes
together and call after-change-functions once to avoid performance
degradation during cache updates.
2021-10-16 23:58:40 +08:00
Ihor Radchenko 5aeeb4f739
Use `org-element-at-point-no-context' in performance-critical places
* lisp/org-compat.el (org-mode-flyspell-verify, org-indent-line,
org-indent-region, org-indent-drawer, org-indent-block): Use
`org-element-at-point-no-context' in place of `org-element-at-point'
when we are doing changes.
* lisp/org.el (org-collect-keywords): Use direct parsing in place of
`org-elemnt-at-point'
2021-10-16 23:56:29 +08:00
Ihor Radchenko e70a8aac59
Use org-element-cache in place of text property cache in agenda
* lisp/org-agenda.el (org-agenda-skip): Use
`org-in-archived-heading-p' and `org-in-commented-heading-p' in place
of text property cache.

(org-agenda-get-todos, org-agenda-get-timestamps,
org-agenda-get-sexps, org-agenda-get-progress,
org-agenda-get-deadlines, org-agenda-get-scheduled,
org-agenda-get-blocks): Do not use text property cache in favour of
Org API functions.  The API functions use cache now.

* lisp/org-clock.el (org-element--cache-active-p): Declare function to
suppress compiler warning.

(org-clock-in): Do not use text property cache when element cache is
active.

* lisp/org-duration.el (org-duration-to-minutes): Do not change match
data.  It is needed to not break agenda---agenda relies on match data
not being altered.

* lisp/org.el (org-run-like-in-org-mode): Use element cache.
(org-refresh-category-properties): Use element cache.
(org-make-tags-matcher, org-agenda-prepare-buffers): Do not rely on
text property cache.

* testing/lisp/test-org.el (test-org/refresh-category-properties): Do
not use text property cache.
2021-10-16 23:50:21 +08:00
Ihor Radchenko fede2588e4
org.el/org-in-archived-heading-p: Support cache and passing element arg 2021-10-16 23:40:28 +08:00
Ihor Radchenko 86345df9ab
org.el/org-in-commented-heading-p: Support cache and passing element arg 2021-10-16 23:40:14 +08:00
Ihor Radchenko 399a29c4f4
org.el/org-up-heading-safe: Add cache support 2021-10-16 23:39:43 +08:00
Ihor Radchenko ec737554d0
org.el/org-end-of-subtree: Support cache and passing element arg 2021-10-16 23:39:11 +08:00
Ihor Radchenko d43781707b
org.el/org-goto-first-child: Support cache and passing element arg 2021-10-16 23:38:46 +08:00