all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: help-gnu-emacs mailing list  <help-gnu-emacs@gnu.org>
Subject: How to create new buffer with t-m-m active region?
Date: Sat, 04 Sep 2010 14:38:48 -0400	[thread overview]
Message-ID: <87k4n11hhj.fsf@stats.ox.ac.uk> (raw)

How would I generate a new buffer containing an active region such that
the next command issued in the new buffer will act on the region? (And
so that the region is highlighted)

For example, this function doesn't do what it wants to do:

(defun new-buffer-w-active-region ()
  (interactive)
  (let ((transient-mark-mode t))
    (switch-to-buffer (get-buffer-create "region-test"))
    (delete-region (point-min) (point-max))
    (insert "I want these lines\n")
    (insert "to be in an active region with t-m-m on\n")
    (insert "such that comment-region comments them out\n")
    (emacs-lisp-mode)
    (push-mark (point-min) nil 'activate)))


With that function, the following doesn't do what is intended:

M-x new-buffer-w-active-region
M-;

Thanks,

Dan



             reply	other threads:[~2010-09-04 18:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-04 18:38 Dan Davison [this message]
2010-09-05  0:25 ` How to create new buffer with t-m-m active region? Drew Adams
2010-09-05  3:47   ` Dan Davison
     [not found] <mailman.7.1283625538.1782.help-gnu-emacs@gnu.org>
2010-09-04 23:01 ` Stefan Monnier

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k4n11hhj.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --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.
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.