emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 7b83168 08/29: org.el/org--property-local-values: S


From: ELPA Syncer
Subject: [elpa] externals/org 7b83168 08/29: org.el/org--property-local-values: Support cache and passing element arg
Date: Sun, 17 Oct 2021 02:57:26 -0400 (EDT)

branch: externals/org
commit 7b83168295b948993e07a2663995eab361faf906
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org.el/org--property-local-values: Support cache and passing element arg
---
 lisp/org.el | 50 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index b76d83f..4ecb300 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13038,30 +13038,40 @@ strings."
          ;; Return value.
          props)))))
 
-(defun org--property-local-values (property literal-nil)
-  "Return value for PROPERTY in current entry.
+(defun org--property-local-values (property literal-nil &optional element)
+  "Return value for PROPERTY in current entry or ELEMENT.
 Value is a list whose car is the base value for PROPERTY and cdr
 a list of accumulated values.  Return nil if neither is found in
 the entry.  Also return nil when PROPERTY is set to \"nil\",
 unless LITERAL-NIL is non-nil."
-  (let ((range (org-get-property-block)))
-    (when range
-      (goto-char (car range))
-      (let* ((case-fold-search t)
-            (end (cdr range))
-            (value
-             ;; Base value.
-             (save-excursion
-               (let ((v (and (re-search-forward
-                              (org-re-property property nil t) end t)
-                             (match-string-no-properties 3))))
-                 (list (if literal-nil v (org-not-nil v)))))))
-       ;; Find additional values.
-       (let* ((property+ (org-re-property (concat property "+") nil t)))
-         (while (re-search-forward property+ end t)
-           (push (match-string-no-properties 3) value)))
-       ;; Return final values.
-       (and (not (equal value '(nil))) (nreverse value))))))
+  (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))
+             (base-value (org-element-property (intern (concat ":" (upcase 
property))) element))
+             (base-value (if literal-nil base-value (org-not-nil base-value)))
+             (extra-value (org-element-property (intern (concat ":" (upcase 
property) "+")) element))
+             (extra-value (if (listp extra-value) extra-value (list 
extra-value)))
+             (value (cons base-value extra-value)))
+        (and (not (equal value '(nil))) value))
+    (let ((range (org-get-property-block)))
+      (when range
+        (goto-char (car range))
+        (let* ((case-fold-search t)
+              (end (cdr range))
+              (value
+               ;; Base value.
+               (save-excursion
+                 (let ((v (and (re-search-forward
+                                (org-re-property property nil t) end t)
+                               (match-string-no-properties 3))))
+                   (list (if literal-nil v (org-not-nil v)))))))
+         ;; Find additional values.
+         (let* ((property+ (org-re-property (concat property "+") nil t)))
+           (while (re-search-forward property+ end t)
+             (push (match-string-no-properties 3) value)))
+         ;; Return final values.
+         (and (not (equal value '(nil))) (nreverse value)))))))
 
 (defun org--property-global-or-keyword-value (property literal-nil)
   "Return value for PROPERTY as defined by global properties or by keyword.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]