[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] New feature? Remove duplicate subheadings, preserving order
From: |
Allen Li |
Subject: |
[O] New feature? Remove duplicate subheadings, preserving order |
Date: |
Sun, 31 Dec 2017 18:42:59 -0800 |
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)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [O] New feature? Remove duplicate subheadings, preserving order,
Allen Li <=