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

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

Re: quoting a block of text with ">"


From: Tom Roche
Subject: Re: quoting a block of text with ">"
Date: Thu, 30 Sep 2010 09:16:35 -0400
User-agent: GNU Emacs 23.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.18.0)

Stever Wed, 29 Sep 2010 11:59:19 -0700
>>> is there any function where I can highlight a block of text and
>>> put a ">" in front of it.

Or, for that matter, easily

* put an arbitrary number of ">" in front, i.e. quote to a level. 
* remove an arbitrary number of ">" in front, i.e. unquote

Fortunately, it seems that, in emacs as in perl, TMTOWTDI:

Eli Zaretskii Thu, 30 Sep 2010 10:33:30 +0200
>> It's part of mail-indent-citation (in sendmail.el):

>>     (save-excursion
>>       (let ((end (set-marker (make-marker) (region-end))))
>>         (goto-char (region-beginning))
>>         (while (< (point) end)
>>           (insert mail-yank-prefix)
>>           (forward-line 1))))

>> mail-yank-prefix is "> " in this case.

Sergei Organov Thu, 30 Sep 2010 12:44:42 +0400
> While not obvious, `string-rectangle' is your friend here:

>   string-rectangle is an interactive autoloaded Lisp function in
>   `rect.el'.
  
>   It is bound to C-x r t.
  
>   (string-rectangle START END STRING)
  
>   Replace rectangle contents with STRING on each line.
>   The length of STRING need not be the same as the rectangle width.

> Put cursor at the beginning of the first line of the region, set the
> mark, move cursor to the _beginning_  of the last line, then
> press

> C-x r t > <ENTER>

> (there is a space entered after ">").

The way I find more obvious is to set ">" to be the comment character in
the mode you're using for editing. You can do that various ways, e.g.
(I'm sure there are others)

* with the sequence [M-x set-variable, comment-start, ">"]. Note the
  need to enter the quotes literally.

* set as a local variable in a file, e.g. append the text

> Local Variables:
> Mode:text
> comment-start:">"

The advantage of this approach is, when one wants to quote a region,
one thinks of quoting as commenting, and just does comment-region
(bound, perhaps by default, to M-#). This means also that

* unquoting        == C-u M-#
* quote to level=n == C-u n M-#

HTH, Tom Roche <address@hidden>



reply via email to

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