help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing duplicated lines


From: Jambunathan K
Subject: Re: Removing duplicated lines
Date: Thu, 29 Nov 2012 17:42:25 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Dani Moncayo <address@hidden> writes:

> Hi,
>
> Does (vanilla) Emacs have some command for removing duplicated lines
> in a given region?
>
> This is a command I'm missing for some time.
>
> I've done a quick search, but didn't found anything.
>
> If there isn't such command, I think I'd file a feature request.

Something like this ...

    (defun delete-duplicate-lines (beg end)
      (interactive "r")
      (let ((lines (split-string (buffer-substring beg end) "\n")))
        (delete-region beg end)
        (insert
         (mapconcat #'identity (delete-dups lines) "\n"))))

> TIA.

-- 



reply via email to

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