More efficient org-clear-all
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user