From mboxrd@z Thu Jan 1 00:00:00 1970 From: Allen Li Subject: New feature? Remove duplicate subheadings, preserving order Date: Sun, 31 Dec 2017 18:42:59 -0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVq46-0007To-Aq for emacs-orgmode@gnu.org; Sun, 31 Dec 2017 21:43:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eVq45-0003oS-MG for emacs-orgmode@gnu.org; Sun, 31 Dec 2017 21:43:02 -0500 Received: from mail-qt0-x22c.google.com ([2607:f8b0:400d:c0d::22c]:43691) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eVq45-0003oD-Gw for emacs-orgmode@gnu.org; Sun, 31 Dec 2017 21:43:01 -0500 Received: by mail-qt0-x22c.google.com with SMTP id w10so59518775qtb.10 for ; Sun, 31 Dec 2017 18:43:01 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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)))