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

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

[elpa] externals/org fede258 15/29: org.el/org-in-archived-heading-p: Su


From: ELPA Syncer
Subject: [elpa] externals/org fede258 15/29: org.el/org-in-archived-heading-p: Support cache and passing element arg
Date: Sun, 17 Oct 2021 02:57:28 -0400 (EDT)

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

    org.el/org-in-archived-heading-p: Support cache and passing element arg
---
 lisp/org.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index c17c24d..a3cb070 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20639,18 +20639,25 @@ Optional argument ELEMENT contains element at point."
        (t
         (save-excursion (and (org-up-heading-safe) 
(org-in-commented-heading-p))))))))
 
-(defun org-in-archived-heading-p (&optional no-inheritance)
+(defun org-in-archived-heading-p (&optional no-inheritance element)
   "Non-nil if point is under an archived heading.
 This function also checks ancestors of the current headline,
-unless optional argument NO-INHERITANCE is non-nil."
+unless optional argument NO-INHERITANCE is non-nil.
+
+Optional argument ELEMENT contains element at point."
   (cond
    ((org-before-first-heading-p) nil)
-   ((let ((tags (org-get-tags nil 'local)))
-      (and tags
-          (cl-some (apply-partially #'string= org-archive-tag) tags))))
+   ((if element
+        (org-element-property :archivedp element)
+      (let ((tags (org-get-tags element 'local)))
+        (and tags
+            (cl-some (apply-partially #'string= org-archive-tag) tags)))))
    (no-inheritance nil)
    (t
-    (save-excursion (and (org-up-heading-safe) (org-in-archived-heading-p))))))
+    (if (org-element--cache-active-p)
+        (cl-some (lambda (el) (org-element-property :archivedp el))
+                 (org-element-lineage (org-element-at-point) nil t))
+      (save-excursion (and (org-up-heading-safe) 
(org-in-archived-heading-p)))))))
 
 (defun org-at-comment-p nil
   "Return t if cursor is in a commented line."



reply via email to

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