Use org-map-entries to iterate headings

This commit is contained in:
louie 2018-01-20 22:10:00 +08:00
parent 5fb4b60026
commit 371db8de5c

View file

@ -142,24 +142,24 @@ If one fails, the failure reason will be set in property drawer
of that heading." of that heading."
(interactive) (interactive)
(let ((total 0) (let ((total 0)
(failed 0)) (failed 0)
(save-excursion current-deck)
(goto-char (point-min)) (org-map-entries
(let (current-tags current-deck) (lambda ()
(while (not (= (point) (point-max))) (let ((current-tags (org-get-tags)))
(when (org-at-heading-p)
(setq current-tags (org-get-tags))
(cond (cond
((member anki-editor-deck-tag current-tags) (setq current-deck (nth 4 (org-heading-components)))) ((member anki-editor-deck-tag current-tags)
((member anki-editor-note-tag current-tags) (progn (setq current-deck (nth 4 (org-heading-components))))
((member anki-editor-note-tag current-tags)
(progn
(setq total (1+ total)) (setq total (1+ total))
(anki-editor--clear-failure-reason) (anki-editor--clear-failure-reason)
(condition-case err (condition-case err
(anki-editor--process-note-heading current-deck) (anki-editor--process-note-heading current-deck)
(error (progn (error (progn
(setq failed (1+ failed)) (setq failed (1+ failed))
(anki-editor--set-failure-reason (error-message-string err))))))))) (anki-editor--set-failure-reason (error-message-string err))))))))))
(org-next-visible-heading 1)))) (mapconcat 'identity `(,anki-editor-deck-tag ,anki-editor-note-tag) "|"))
(message (with-output-to-string (message (with-output-to-string
(princ (format "Submitted %d notes, with %d failed." total failed)) (princ (format "Submitted %d notes, with %d failed." total failed))
(when (> failed 0) (when (> failed 0)