[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] New feature? Remove duplicate subheadings, preserving order
From: |
Nicolas Goaziou |
Subject: |
Re: [O] New feature? Remove duplicate subheadings, preserving order |
Date: |
Mon, 01 Jan 2018 11:04:42 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Hello,
Allen Li <address@hidden> 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
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Marcin Borkowski, 2018/01/01
- Re: [O] New feature? Remove duplicate subheadings, preserving order,
Nicolas Goaziou <=
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Allen Li, 2018/01/01
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Nicolas Goaziou, 2018/01/01
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Allen Li, 2018/01/01
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Adam Porter, 2018/01/01
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Allen Li, 2018/01/02
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Robert Horn, 2018/01/02
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Allen Li, 2018/01/02
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Nick Dokos, 2018/01/02
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Allen Li, 2018/01/02
- Re: [O] New feature? Remove duplicate subheadings, preserving order, Adam Porter, 2018/01/03