More efficient org-clear-all

This commit is contained in:
2025-12-29 09:00:15 -08:00
parent 48feb223f1
commit ec4f355ac2

View File

@@ -772,12 +772,20 @@ EMACS-ALTERNATIVE is the Emacs equivalent (e.g., 'C-s')."
(defun my/org-clear-all ()
(interactive)
(goto-char 0)
(org-map-entries
(lambda ()
(org-todo "")))
;;(flush-lines "CLOSED")
(message "Entries cleared."))
(let ((ast (org-element-parse-buffer))
;; Temporarily disable org-save-all-org-buffers
(org-after-todo-state-change-hook
(remove #'org-save-all-org-buffers
org-after-todo-state-change-hook)))
;; Iterate over all headlines in the parsed AST
(org-element-map ast 'headline
(lambda (hl)
(when (org-element-property :todo-keyword hl)
;; Go to the headline and clear its TODO state
(goto-char (org-element-property :begin hl))
(org-todo ""))))
;; Save once at the end
(org-save-all-org-buffers)))
;;;; Screenshots for games
;; Steps to set up: