all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* quoting a block of text with ">"
@ 2010-09-29 18:59 Stever
  2010-09-30  8:33 ` Eli Zaretskii
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Stever @ 2010-09-29 18:59 UTC (permalink / raw)
  To: help-gnu-emacs

I can't seem to find this function in my version of emacs, but I assume
there is one. is there any function where I can highlight a block of text
and put a ">" in front of it. So something like:

The quick brown fox jumps over the lazy dog. The quick brown fox jumps
over the lazy dog. The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy
dog. The quick brown fox jumps over the lazy dog.

- gets converted to -

> The quick brown fox jumps over the lazy dog. The quick
> brown fox jumps over the lazy dog. The quick brown fox
> jumps over the lazy dog. The quick brown fox jumps over
> the lazy dog. The quick brown fox jumps over the lazy
> dog. The quick brown fox jumps over the lazy dog.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
       [not found] <mailman.8.1285802119.17330.help-gnu-emacs@gnu.org>
@ 2010-09-30  2:33 ` rustom
  2010-09-30  3:06 ` Teemu Likonen
  2010-09-30  8:10 ` David Kastrup
  2 siblings, 0 replies; 10+ messages in thread
From: rustom @ 2010-09-30  2:33 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 29, 11:59 pm, "Stever" <st...@tripperjones.com> wrote:
> I can't seem to find this function in my version of emacs, but I assume
> there is one. is there any function where I can highlight a block of text
> and put a ">" in front of it.

You want to look at column editing mode (part of cua mode) see

http://stateofflux.com/2008/06/14/column-editing-with-emacs/


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
       [not found] <mailman.8.1285802119.17330.help-gnu-emacs@gnu.org>
  2010-09-30  2:33 ` rustom
@ 2010-09-30  3:06 ` Teemu Likonen
  2010-09-30  8:10 ` David Kastrup
  2 siblings, 0 replies; 10+ messages in thread
From: Teemu Likonen @ 2010-09-30  3:06 UTC (permalink / raw)
  To: help-gnu-emacs

* 2010-09-29 11:59 (-0700), Stever wrote:

> I can't seem to find this function in my version of emacs, but I
> assume there is one. is there any function where I can highlight a
> block of text and put a ">" in front of it.

I'm not sure if you mean this but you can use M-; command to comment a
region. Major modes should define the comment style for the language.
For example, message-mode uses "> " as comment characters. If you want
to change the default then I think this will do:

    (set (make-local-variable 'comment-start) "> ")
    (set (make-local-variable 'comment-start-skip) ">+[ \t]*")


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
       [not found] <mailman.8.1285802119.17330.help-gnu-emacs@gnu.org>
  2010-09-30  2:33 ` rustom
  2010-09-30  3:06 ` Teemu Likonen
@ 2010-09-30  8:10 ` David Kastrup
  2 siblings, 0 replies; 10+ messages in thread
From: David Kastrup @ 2010-09-30  8:10 UTC (permalink / raw)
  To: help-gnu-emacs

"Stever" <steve@tripperjones.com> writes:

> I can't seem to find this function in my version of emacs, but I assume
> there is one. is there any function where I can highlight a block of text
> and put a ">" in front of it. So something like:
>
> The quick brown fox jumps over the lazy dog. The quick brown fox jumps
> over the lazy dog. The quick brown fox jumps over the lazy dog. The quick
> brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy
> dog. The quick brown fox jumps over the lazy dog.
>
> - gets converted to -
>
>> The quick brown fox jumps over the lazy dog. The quick
>> brown fox jumps over the lazy dog. The quick brown fox
>> jumps over the lazy dog. The quick brown fox jumps over
>> the lazy dog. The quick brown fox jumps over the lazy
>> dog. The quick brown fox jumps over the lazy dog.

After setting the region, try

C-x r t >   RET

-- 
David Kastrup


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
  2010-09-29 18:59 quoting a block of text with ">" Stever
@ 2010-09-30  8:33 ` Eli Zaretskii
  2010-09-30  8:44 ` Sergei Organov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2010-09-30  8:33 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 29 Sep 2010 11:59:19 -0700
> From: "Stever" <steve@tripperjones.com>
> 
> I can't seem to find this function in my version of emacs, but I assume
> there is one. is there any function where I can highlight a block of text
> and put a ">" in front of it.

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.

This assumes you have the block of text marked as region.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
  2010-09-29 18:59 quoting a block of text with ">" Stever
  2010-09-30  8:33 ` Eli Zaretskii
@ 2010-09-30  8:44 ` Sergei Organov
  2010-09-30  9:54 ` Arnaldo Mandel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Sergei Organov @ 2010-09-30  8:44 UTC (permalink / raw)
  To: help-gnu-emacs

"Stever" <steve@tripperjones.com> writes:
> I can't seem to find this function in my version of emacs, but I assume
> there is one. is there any function where I can highlight a block of text
> and put a ">" in front of it.

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 ">").

-- Sergei.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
  2010-09-29 18:59 quoting a block of text with ">" Stever
  2010-09-30  8:33 ` Eli Zaretskii
  2010-09-30  8:44 ` Sergei Organov
@ 2010-09-30  9:54 ` Arnaldo Mandel
  2010-09-30 13:16 ` Tom Roche
       [not found] ` <mailman.1.1285852603.7851.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 10+ messages in thread
From: Arnaldo Mandel @ 2010-09-30  9:54 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, Sep 29, 2010 at 3:59 PM, Stever <steve@tripperjones.com> wrote:
> I can't seem to find this function in my version of emacs, but I assume
> there is one. is there any function where I can highlight a block of text
> and put a ">" in front of it. So something like:

I also like this functionality, and have had the command below bound
to a function key for two decades.
The comments are included for a correct attribution of authorship.

;From: erlkonig@walt.cc.utexas.edu (Christopher North-Keys)
;Newsgroups: comp.emacs
;Message-ID: <16516@ut-emx.UUCP>
;Date: 3 Aug 89 00:57:14 GMT

;; Prefix region (for rmail, in particular) -- simple & robust.
;; Christopher North-Keys, 1989
(defun prefix-region (start end string)
  "Insert STRING, default '> ', at the start of each line
in or intersecting region while preserving indentation.
Called from a program, takes three arguments,START, END and STRING."
  (interactive "r\nsString:  ")
  (if (or (equal string "") (equal string nil))
      (setq string "> "))
  ;; Adjust start and end to extremes of
  ;; lines so lines don't get broken.
  (goto-char end)
  (end-of-line)
  (setq end (point))
  (goto-char start)
  (beginning-of-line)
  (setq start (point))
  ;; There is another command, replace-regexp, that did not work well.
  ;; If you narrowed as one would expect, you could not widen to the
  ;; previous narrow.  Saving the old narrow extremes failed, as this
  ;; routine expands the region.  Sadmaking.
  (let (line)
    (setq lines (count-lines start end))
    (while (> lines 0)
      (insert string)
      (search-forward "\n")
      (setq lines (- lines 1))
      )))

Arnaldo



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
  2010-09-29 18:59 quoting a block of text with ">" Stever
                   ` (2 preceding siblings ...)
  2010-09-30  9:54 ` Arnaldo Mandel
@ 2010-09-30 13:16 ` Tom Roche
  2010-09-30 14:25   ` ken
       [not found] ` <mailman.1.1285852603.7851.help-gnu-emacs@gnu.org>
  4 siblings, 1 reply; 10+ messages in thread
From: Tom Roche @ 2010-09-30 13:16 UTC (permalink / raw)
  To: help-gnu-emacs


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 <Tom_Roche@pobox.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
  2010-09-30 13:16 ` Tom Roche
@ 2010-09-30 14:25   ` ken
  0 siblings, 0 replies; 10+ messages in thread
From: ken @ 2010-09-30 14:25 UTC (permalink / raw)
  To: help-gnu-emacs, Tom Roche


On 09/30/2010 09:16 AM Tom Roche wrote:
> 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.

Here's how I do it:

Put a '>' in the first column of the first and second lines of the block
of text,  The hit C-q.

==================

As an alternative, I have this in ~/.emacs

(fset 'mailind "\C-a> \C-n\C-a")
(global-set-key [C-f8] 'mailind)

Then I can hold down C-F8 for as long as I need to prepend those '>' chars.


hth,
ken




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: quoting a block of text with ">"
       [not found] ` <mailman.1.1285852603.7851.help-gnu-emacs@gnu.org>
@ 2010-09-30 18:32   ` Sean McAfee
  0 siblings, 0 replies; 10+ messages in thread
From: Sean McAfee @ 2010-09-30 18:32 UTC (permalink / raw)
  To: help-gnu-emacs

Tom Roche <Tom_Roche@pobox.com> writes:

> 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:
<snip>

Another way I'm surprised no one has mentioned is just to select the
text using the region and then replace the regexp "^" with ">".

I used to do that kind of thing all the time when I mainly used vim.
Emacs's comment-region has made it much less necessary.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-09-30 18:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-29 18:59 quoting a block of text with ">" Stever
2010-09-30  8:33 ` Eli Zaretskii
2010-09-30  8:44 ` Sergei Organov
2010-09-30  9:54 ` Arnaldo Mandel
2010-09-30 13:16 ` Tom Roche
2010-09-30 14:25   ` ken
     [not found] ` <mailman.1.1285852603.7851.help-gnu-emacs@gnu.org>
2010-09-30 18:32   ` Sean McAfee
     [not found] <mailman.8.1285802119.17330.help-gnu-emacs@gnu.org>
2010-09-30  2:33 ` rustom
2010-09-30  3:06 ` Teemu Likonen
2010-09-30  8:10 ` David Kastrup

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.