unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Arnaldo Mandel <amandel@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: quoting a block of text with ">"
Date: Thu, 30 Sep 2010 06:54:07 -0300	[thread overview]
Message-ID: <AANLkTinf9MEyhASf424S0ZBKuCRfF+TxEcAGk7=aR=WZ@mail.gmail.com> (raw)
In-Reply-To: <77ccee74e9578ebd4936450a706a61fa.squirrel@webmail.tripperjones.com>

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



  parent reply	other threads:[~2010-09-30  9:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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='AANLkTinf9MEyhASf424S0ZBKuCRfF+TxEcAGk7=aR=WZ@mail.gmail.com' \
    --to=amandel@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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).