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

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

How to create new buffer with t-m-m active region?


From: Dan Davison
Subject: How to create new buffer with t-m-m active region?
Date: Sat, 04 Sep 2010 14:38:48 -0400
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

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 via email to

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