From: Dani Moncayo <dmoncayo@gmail.com>
To: Jambunathan K <kjambunathan@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Removing duplicated lines
Date: Thu, 29 Nov 2012 13:18:34 +0100 [thread overview]
Message-ID: <CAH8Pv0iG9Eww6_Roxg3ooEOcJajZ7MjV75gzXxUKktY3dEpCzQ@mail.gmail.com> (raw)
In-Reply-To: <87vcco38wm.fsf@gmail.com>
> 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"))))
Seem to do the job, indeed. Thanks!
It could be improved by accepting a prefix argument to control an
optional reordering of the region (as side effect):
* If the argument is > 0 --> Region sorted in ascending order.
* If the argument is < 0 --> Region sorted in descending order.
* If the argument is 0 or nil --> Region is left unsorted.
--
Dani Moncayo
next prev parent reply other threads:[~2012-11-29 12:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 10:50 Removing duplicated lines Dani Moncayo
2012-11-29 12:12 ` Jambunathan K
2012-11-29 12:18 ` Dani Moncayo [this message]
[not found] <mailman.14043.1354186273.855.help-gnu-emacs@gnu.org>
2012-11-29 11:06 ` Sebastien Vauban
2012-11-29 11:25 ` Dani Moncayo
2012-11-29 11:57 ` Yuri Khan
2012-11-29 12:07 ` Dani Moncayo
[not found] ` <mailman.14047.1354190273.855.help-gnu-emacs@gnu.org>
2013-07-03 12:13 ` naisanza
2012-11-29 11:31 ` Yuri Khan
2013-07-03 12:14 ` naisanza
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH8Pv0iG9Eww6_Roxg3ooEOcJajZ7MjV75gzXxUKktY3dEpCzQ@mail.gmail.com \
--to=dmoncayo@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=kjambunathan@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).