emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* New feature? Remove duplicate subheadings, preserving order
@ 2018-01-01  2:42 Allen Li
  2018-01-01  5:55 ` Marcin Borkowski
  2018-01-01 10:04 ` Nicolas Goaziou
  0 siblings, 2 replies; 18+ messages in thread
From: Allen Li @ 2018-01-01  2:42 UTC (permalink / raw)
  To: emacs-orgmode

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)))

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-01-03  9:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-01  2:42 New feature? Remove duplicate subheadings, preserving order Allen Li
2018-01-01  5:55 ` Marcin Borkowski
2018-01-01 10:04 ` Nicolas Goaziou
2018-01-01 11:59   ` Allen Li
2018-01-01 18:26     ` Nicolas Goaziou
2018-01-01 23:04       ` Allen Li
2018-01-02  4:07         ` Adam Porter
2018-01-02  7:40           ` Allen Li
2018-01-02 14:36             ` Robert Horn
2018-01-02 21:34               ` Allen Li
2018-01-02 16:36             ` Nick Dokos
2018-01-02 21:22               ` Allen Li
2018-01-03  7:24                 ` Adam Porter
2018-01-03  7:40               ` Adam Porter
2018-01-03  8:19                 ` Ihor Radchenko
2018-01-03  9:39                   ` Adam Porter
2018-01-02 15:28       ` Florian Beck
2018-01-02 21:28         ` Allen Li

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).