I wrote a command to remove duplicate subheadings, which I use to remove duplicate captured links among other things. Would this be a useful addition to Org mode?
I have included it below for reference. I will clean it up a bit if it's a worthy feature. (defun mir-org-uniq () "Remove duplicate subheadings, preserving order." (interactive) (let ((seen (make-hash-table :test 'equal)) (removed 0)) (save-excursion (org-map-entries (lambda () (let ((heading (org-get-heading t t t t))) (if (not (gethash heading seen)) (puthash heading t seen) (org-cut-subtree) (org-backward-heading-same-level 1) (setq removed (1+ removed))))) (format "LEVEL=%s" (1+ (org-current-level))) 'tree)) (message "Removed %d duplicates" removed)))