emacs-orgmode
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]