[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 5bf5fdb 09/29: org.el/org-entry-get-with-inheritanc
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 5bf5fdb 09/29: org.el/org-entry-get-with-inheritance: Support cache and passing element arg |
Date: |
Sun, 17 Oct 2021 02:57:26 -0400 (EDT) |
branch: externals/org
commit 5bf5fdbc28c004164f6b0ec8d53f886a01bb28b7
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org.el/org-entry-get-with-inheritance: Support cache and passing element arg
* lisp/org.el (org-entry-get-with-inheritance): Add cache support.
Add new optional argument---an element to get properties from. Fix
getting top-level properties when a headline is located at BOB.
---
lisp/org.el | 76 ++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 55 insertions(+), 21 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 4ecb300..dafdb31 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13209,7 +13209,7 @@ no match, the marker will point nowhere.
Note that also `org-entry-get' calls this function, if the INHERIT flag
is set.")
-(defun org-entry-get-with-inheritance (property &optional literal-nil)
+(defun org-entry-get-with-inheritance (property &optional literal-nil element)
"Get PROPERTY of entry or content at point, search higher levels if needed.
The search will stop at the first ancestor which has the property defined.
If the value found is \"nil\", return nil to show that the property
@@ -13217,27 +13217,61 @@ should be considered as undefined (this is the
meaning of nil here).
However, if LITERAL-NIL is set, return the string value \"nil\" instead."
(move-marker org-entry-property-inherited-from nil)
(org-with-wide-buffer
- (let (value)
+ (let (value at-bob-no-heading)
(catch 'exit
- (while t
- (let ((v (org--property-local-values property literal-nil)))
- (when v
- (setq value
- (concat (mapconcat #'identity (delq nil v) " ")
- (and value " ")
- value)))
- (cond
- ((car v)
- (org-back-to-heading-or-point-min t)
- (move-marker org-entry-property-inherited-from (point))
- (throw 'exit nil))
- ((org-up-heading-or-point-min))
- (t
- (let ((global (org--property-global-or-keyword-value property
literal-nil)))
- (cond ((not global))
- (value (setq value (concat global " " value)))
- (t (setq value global))))
- (throw 'exit nil))))))
+ (if-let ((element (or element
+ (and (org-element--cache-active-p)
+ (org-element-at-point nil 'cached)))))
+ (let ((element (org-element-lineage element '(headline org-data
inlinetask) 'with-self)))
+ (while t
+ (let* ((v (org--property-local-values property literal-nil
element))
+ (v (if (listp v) v (list v))))
+ (when v
+ (setq value
+ (concat (mapconcat #'identity (delq nil v) " ")
+ (and value " ")
+ value)))
+ (cond
+ ((car v)
+ (move-marker org-entry-property-inherited-from
(org-element-property :begin element))
+ (throw 'exit nil))
+ ((org-element-property :parent element)
+ (setq element (org-element-property :parent element)))
+ (t
+ (let ((global (org--property-global-or-keyword-value
property literal-nil)))
+ (cond ((not global))
+ (value (setq value (concat global " " value)))
+ (t (setq value global))))
+ (throw 'exit nil))))))
+ (while t
+ (let ((v (org--property-local-values property literal-nil)))
+ (when v
+ (setq value
+ (concat (mapconcat #'identity (delq nil v) " ")
+ (and value " ")
+ value)))
+ (cond
+ ((car v)
+ (org-back-to-heading-or-point-min t)
+ (move-marker org-entry-property-inherited-from (point))
+ (throw 'exit nil))
+ ((or (org-up-heading-safe)
+ (and (not (bobp))
+ (goto-char (point-min))
+ nil)
+ ;; `org-up-heading-safe' returned nil. We are at low
+ ;; level heading or bob. If there is headline
+ ;; there, do not try to fetch its properties.
+ (and (bobp)
+ (not at-bob-no-heading)
+ (not (org-at-heading-p))
+ (setq at-bob-no-heading t))))
+ (t
+ (let ((global (org--property-global-or-keyword-value property
literal-nil)))
+ (cond ((not global))
+ (value (setq value (concat global " " value)))
+ (t (setq value global))))
+ (throw 'exit nil)))))))
(if literal-nil value (org-not-nil value)))))
(defvar org-property-changed-functions nil
- [elpa] externals/org updated (9475993 -> f4bcc0c), ELPA Syncer, 2021/10/17
- [elpa] externals/org 6933c1a 01/29: lisp/org-persist.el: New library to store data across sessions, ELPA Syncer, 2021/10/17
- [elpa] externals/org fc80d05 02/29: Re-implement org-element-cache and add headline support, ELPA Syncer, 2021/10/17
- [elpa] externals/org bc52c4d 03/29: Fix compatibility for older Emacs versions, ELPA Syncer, 2021/10/17
- [elpa] externals/org 68a44ea 04/29: org.el/org-narrow-to-subtree: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 7159ec0 05/29: org.el/org-at-planning-p: Add cache support, ELPA Syncer, 2021/10/17
- [elpa] externals/org 38b632d 06/29: org.el/org--get-local-tags: Add cache support, ELPA Syncer, 2021/10/17
- [elpa] externals/org 78abbcd 07/29: org.el/org-get-tags: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 5bf5fdb 09/29: org.el/org-entry-get-with-inheritance: Support cache and passing element arg,
ELPA Syncer <=
- [elpa] externals/org 5d162b7 10/29: org.el/org-back-to-heading: Handle inlinetasks correctly, ELPA Syncer, 2021/10/17
- [elpa] externals/org f4bcc0c 29/29: Merge branch 'main' into feature/org-element-cache-new, ELPA Syncer, 2021/10/17
- [elpa] externals/org fede258 15/29: org.el/org-in-archived-heading-p: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 07ca988 24/29: Fix compatibility with Emacs 27, ELPA Syncer, 2021/10/17
- [elpa] externals/org eeb0450 26/29: Use XDG cache dir as default dir for cache persistance, ELPA Syncer, 2021/10/17
- [elpa] externals/org 8ceb9e7 27/29: Add NEWS entry for new element cache, ELPA Syncer, 2021/10/17
- [elpa] externals/org 85e0a69 20/29: Avoid frequent cache updates in some functions, ELPA Syncer, 2021/10/17
- [elpa] externals/org 7b83168 08/29: org.el/org--property-local-values: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org ec73755 12/29: org.el/org-end-of-subtree: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org fe6cefd 16/29: ox.el: Support cache during export, ELPA Syncer, 2021/10/17