]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Update esy/org-fill-custom-ids-in-buffer
authorEshel Yaron <eshel@areionsec.com>
Sat, 7 May 2022 12:48:39 +0000 (15:48 +0300)
committerEshel Yaron <eshel@areionsec.com>
Sat, 7 May 2022 12:48:39 +0000 (15:48 +0300)
.emacs.d/esy.org

index 5633121c39157b18452716b5aaaf5f7e73d8117a..06df7c3d836c17e723b4e68d647c5f5efd387f85 100644 (file)
@@ -313,17 +313,23 @@ For further information about Elisp headers, see [[info:elisp#Library
     (interactive "d\nMCUSTOM_ID: ")
     (org-entry-put point "CUSTOM_ID" value))
 
+  (defun esy/org-maybe-prompt-custom-id ()
+    "Prompt for CUSTOM_ID if not set for the entry at POINT."
+    (unless (org-entry-get (point) "CUSTOM_ID")
+      (beacon-blink)
+      (org-cycle)
+      (call-interactively #'esy/org-fill-custom-id)
+      (org-global-cycle 1)))
+
   (defun esy/org-fill-custom-ids-in-buffer ()
     "Visit headers in the current buffer and set CUSTOM_ID for each."
     (interactive)
     (require 'beacon)
     (org-global-cycle 1)
-    (org-map-entries (lambda ()
-                       (unless (org-entry-get (point) "CUSTOM_ID")
-                         (beacon-blink)
-                         (org-cycle)
-                         (call-interactively #'esy/org-fill-custom-id)
-                         (org-global-cycle 1)))))
+    (message "Filled %d CUSTOM_ID properties."
+             (length (remove nil
+                             (org-map-entries
+                              #'esy/org-maybe-prompt-custom-id)))))
 #+end_src
 ** Export and publish
 :PROPERTIES: