Last active
October 4, 2020 16:54
-
-
Save heikkil/0e8e2342f0f3136ba0d1a4da174fc185 to your computer and use it in GitHub Desktop.
Report org headings with duplicate names in the *Messages* buffer. Reveal them and move to the last duplicate. Run after saving the buffer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'dash) | |
(defun org-duplicate-heading () | |
"Move to duplicate heading in the current org buffer." | |
(interactive) | |
(let ((header-list '())) | |
(org-element-map (org-element-parse-buffer) 'headline | |
(lambda (x) | |
(let ((header (org-element-property :raw-value x)) | |
(begin (org-element-property :begin x))) | |
(when (-contains? header-list header) | |
(message "Duplicate header: %s" header) | |
(goto-char begin) | |
(org-reveal) | |
(push header header-list)))))) | |
(add-hook 'org-mode-hook | |
(lambda () | |
(add-hook 'after-save-hook #'org-duplicate-heading))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment