Hello, Allen Li <vianchielfa...@gmail.com> writes:
> 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))) Duplicates headings are not necessarily wrong. I think this is too specific to be integrated in Org proper. Maybe we could add a check for duplicates headings in Org Lint instead, and add this to Worg, in a "tools" page. Or we could check for duplicate headings _including contents_, which are more likely to be an error. WDYT? Regards, -- Nicolas Goaziou