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 () (defun my/org-clear-all ()
(interactive) (interactive)
(goto-char 0) (let ((ast (org-element-parse-buffer))
(org-map-entries ;; Temporarily disable org-save-all-org-buffers
(lambda () (org-after-todo-state-change-hook
(org-todo ""))) (remove #'org-save-all-org-buffers
;;(flush-lines "CLOSED") org-after-todo-state-change-hook)))
(message "Entries cleared.")) ;; 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 ;;;; Screenshots for games
;; Steps to set up: ;; Steps to set up: