diff --git a/emacs/init.el b/emacs/init.el index cc8c525..4a00955 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -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: