From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Allen Li <vianchielfaura@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: New feature? Remove duplicate subheadings, preserving order
Date: Mon, 01 Jan 2018 11:04:42 +0100 [thread overview]
Message-ID: <87a7xxx5c5.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAJr1M6dOOLd52BNxywMwWVcp-YqcYTMSKaTD1PWaAPxTPWioAg@mail.gmail.com> (Allen Li's message of "Sun, 31 Dec 2017 18:42:59 -0800")
Hello,
Allen Li <vianchielfaura@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
next prev parent reply other threads:[~2018-01-01 10:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a7xxx5c5.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=vianchielfaura@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.