* delete double lines
@ 2006-08-11 10:41 C.Strobl
2006-08-11 10:56 ` Peter Dyballa
[not found] ` <mailman.5076.1155293829.9609.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: C.Strobl @ 2006-08-11 10:41 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 237 bytes --]
hello all,
is there any solution for delete double lines with emacs commands (or
macros)?
f.g.
line1
line1
line2
line1
line2
shall be processed to
line1
line2
thanks and greetings from munich
christian
[-- Attachment #1.2: Type: text/html, Size: 2145 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: delete double lines
2006-08-11 10:41 delete double lines C.Strobl
@ 2006-08-11 10:56 ` Peter Dyballa
2006-08-11 11:04 ` AW: " C.Strobl
[not found] ` <mailman.5076.1155293829.9609.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 7+ messages in thread
From: Peter Dyballa @ 2006-08-11 10:56 UTC (permalink / raw)
Cc: help-gnu-emacs
Am 11.08.2006 um 12:41 schrieb <C.Strobl@dlr.de>:
> is there any solution for delete double lines with emacs commands
> (or macros)?
>
What about shell-command-on-region? And the shell command is 'sort -u'.
--
Mit friedvollen Grüßen
Pete
“Computers are good at following instructions, but not at reading
your mind.”
- D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
^ permalink raw reply [flat|nested] 7+ messages in thread
* AW: delete double lines
2006-08-11 10:56 ` Peter Dyballa
@ 2006-08-11 11:04 ` C.Strobl
2006-08-11 12:59 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: C.Strobl @ 2006-08-11 11:04 UTC (permalink / raw)
Cc: help-gnu-emacs
i am working in an windows environment. i think the windows sort command has no comparable option to suppress double lines.
-----Ursprüngliche Nachricht-----
Von: Peter_Dyballa@Web.DE [mailto:Peter_Dyballa@Web.DE]
Gesendet: Freitag, 11. August 2006 12:57
An: Strobl, Christian
Cc: help-gnu-emacs@gnu.org
Betreff: Re: delete double lines
Am 11.08.2006 um 12:41 schrieb <C.Strobl@dlr.de>:
> is there any solution for delete double lines with emacs commands (or
> macros)?
>
What about shell-command-on-region? And the shell command is 'sort -u'.
--
Mit friedvollen Grüßen
Pete
"Computers are good at following instructions, but not at reading
your mind."
- D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.5076.1155293829.9609.help-gnu-emacs@gnu.org>]
* Re: delete double lines
[not found] ` <mailman.5076.1155293829.9609.help-gnu-emacs@gnu.org>
@ 2006-08-11 13:30 ` Chris McMahan
2006-08-11 13:34 ` Chris McMahan
0 siblings, 1 reply; 7+ messages in thread
From: Chris McMahan @ 2006-08-11 13:30 UTC (permalink / raw)
M-x sort-lines to get the same results.
If you only want to sort part of the buffer, just highlight the region
you want sorted and execute the same function.
I use this quite frequently!
- Chris
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 11.08.2006 um 12:41 schrieb <C.Strobl@dlr.de>:
>
>> is there any solution for delete double lines with emacs commands
>> (or macros)?
>>
>
> What about shell-command-on-region? And the shell command is 'sort -u'.
>
> --
> Mit friedvollen Grüßen
>
> Pete
>
> “Computers are good at following instructions, but not at reading
> your mind.”
> - D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
--
(. .)
=ooO=(_)=Ooo=====================================
Chris McMahan | first_initiallastname@one.dot.net
=================================================
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: delete double lines
2006-08-11 13:30 ` Chris McMahan
@ 2006-08-11 13:34 ` Chris McMahan
0 siblings, 0 replies; 7+ messages in thread
From: Chris McMahan @ 2006-08-11 13:34 UTC (permalink / raw)
Oops! sort-lines doesn't uniquify...
Cygwin has a sort function that handles the -u switch, but it means
installing the entire cygwin environment.
- Chris
Chris McMahan <first_initiallastname@one.dot.net> writes:
> M-x sort-lines to get the same results.
>
> If you only want to sort part of the buffer, just highlight the region
> you want sorted and execute the same function.
>
> I use this quite frequently!
>
> - Chris
>
> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>
>> Am 11.08.2006 um 12:41 schrieb <C.Strobl@dlr.de>:
>>
>>> is there any solution for delete double lines with emacs commands
>>> (or macros)?
>>>
>>
>> What about shell-command-on-region? And the shell command is 'sort -u'.
>>
>> --
>> Mit friedvollen Grüßen
>>
>> Pete
>>
>> “Computers are good at following instructions, but not at reading
>> your mind.”
>> - D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
--
(. .)
=ooO=(_)=Ooo=====================================
Chris McMahan | first_initiallastname@one.dot.net
=================================================
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.5075.1155292906.9609.help-gnu-emacs@gnu.org>]
* Re: delete double lines
[not found] <mailman.5075.1155292906.9609.help-gnu-emacs@gnu.org>
@ 2006-08-11 15:05 ` Pascal Bourguignon
0 siblings, 0 replies; 7+ messages in thread
From: Pascal Bourguignon @ 2006-08-11 15:05 UTC (permalink / raw)
<C.Strobl@dlr.de> writes:
> hello all,
>
>
>
> is there any solution for delete double lines with emacs commands (or macros)?
>
>
>
> f.g.
>
>
>
> line1
>
> line1
>
> line2
>
> line1
>
> line2
>
>
>
> shall be processed to
>
>
>
> line1
>
> line2
>
>
>
>
>
> thanks and greetings from munich
>From emacs, I would select the range of lines, then type:
C-u M-| sort -u | sed -n -e p -e 's/.*//p' RET
If you want a pure emacs solution:
(require 'cl)
(defun sort-unique-lines-with-double-spacing (start end)
(interactive "r")
(save-excursion
(goto-char start)
(let ((lines '()))
(while (and (< (point) end) (re-search-forward "^\\(.*\\)$" end t))
(push (buffer-substring (match-beginning 0) (match-end 0)) lines))
(message "%S" lines)
(delete-region start end)
(dolist (line (sort (delete-duplicates lines :test (function string=))
(function string-lessp)))
(insert (format "%s\n\n" line))))))
Then you can select the range of lines,
and type M-x sort-unique-lines-with-double-spacing RET
--
__Pascal Bourguignon__ http://www.informatimago.com/
HEALTH WARNING: Care should be taken when lifting this product,
since its mass, and thus its weight, is dependent on its velocity
relative to the user.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-08-11 15:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-11 10:41 delete double lines C.Strobl
2006-08-11 10:56 ` Peter Dyballa
2006-08-11 11:04 ` AW: " C.Strobl
2006-08-11 12:59 ` Eli Zaretskii
[not found] ` <mailman.5076.1155293829.9609.help-gnu-emacs@gnu.org>
2006-08-11 13:30 ` Chris McMahan
2006-08-11 13:34 ` Chris McMahan
[not found] <mailman.5075.1155292906.9609.help-gnu-emacs@gnu.org>
2006-08-11 15:05 ` Pascal Bourguignon
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).