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."
(interactive)
(let ((total 0)
(failed 0))
(save-excursion
(goto-char (point-min))
(let (current-tags current-deck)
(while (not (= (point) (point-max)))
(when (org-at-heading-p)
(setq current-tags (org-get-tags))
(failed 0)
current-deck)
(org-map-entries
(lambda ()
(let ((current-tags (org-get-tags)))
(cond
((member anki-editor-deck-tag current-tags) (setq current-deck (nth 4 (org-heading-components))))
((member anki-editor-note-tag current-tags) (progn
((member anki-editor-deck-tag current-tags)
(setq current-deck (nth 4 (org-heading-components))))
((member anki-editor-note-tag current-tags)
(progn
(setq total (1+ total))
(anki-editor--clear-failure-reason)
(condition-case err
(anki-editor--process-note-heading current-deck)
(error (progn
(setq failed (1+ failed))
(anki-editor--set-failure-reason (error-message-string err)))))))))
(org-next-visible-heading 1))))
(anki-editor--set-failure-reason (error-message-string err))))))))))
(mapconcat 'identity `(,anki-editor-deck-tag ,anki-editor-note-tag) "|"))
(message (with-output-to-string
(princ (format "Submitted %d notes, with %d failed." total failed))
(when (> failed 0)