emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Best way to check if a subtree with a property exists?


From: Kaushal Modi
Subject: [O] Best way to check if a subtree with a property exists?
Date: Fri, 01 Dec 2017 14:00:43 +0000

Hello,

I'd like to check if the current Org file has at least one subtree with a specific property (EXPORT_FILE_NAME in my case).

What's the most efficient way to do that?

Below works.. but I can see that it's not efficient.. it maps through the whole Org file:

(let ((total-valid-subtrees
       (let ((valid-subtrees (org-map-entries
                              (lambda ()
                                t) ;Return value does not matter here
                              ;; Only map through subtrees where
                              ;; EXPORT_FILE_NAME property is not
                              ;; empty.
                              "EXPORT_FILE_NAME<>\"\"")))
         (safe-length valid-subtrees))))
  (if (= 0 total-valid-subtrees)
      (message "invalid")
    (message "valid")))

So,

- How can I quit out of org-map-entries as soon as the first matching entry is found?
- What's a better way to do the same?

Thanks.
--

Kaushal Modi


reply via email to

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