From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Davison Newsgroups: gmane.emacs.help Subject: Re: How to create new buffer with t-m-m active region? Date: Sat, 04 Sep 2010 23:47:33 -0400 Message-ID: <87vd6kyhpm.fsf@stats.ox.ac.uk> References: <87k4n11hhj.fsf@stats.ox.ac.uk> <076A3A212B3F4180869BBBCA325A60F7@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1283658490 19702 80.91.229.12 (5 Sep 2010 03:48:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 5 Sep 2010 03:48:10 +0000 (UTC) Cc: 'help-gnu-emacs mailing list' To: "Drew Adams" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 05 05:48:09 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Os6D5-00088F-Hj for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Sep 2010 05:48:03 +0200 Original-Received: from localhost ([127.0.0.1]:42864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Os6D5-0003nl-0V for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Sep 2010 23:48:03 -0400 Original-Received: from [140.186.70.92] (port=55404 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Os6Ch-0003mh-Lg for help-gnu-emacs@gnu.org; Sat, 04 Sep 2010 23:47:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Os6Cg-0005WW-7E for help-gnu-emacs@gnu.org; Sat, 04 Sep 2010 23:47:39 -0400 Original-Received: from markov.stats.ox.ac.uk ([163.1.210.1]:51223) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Os6Cf-0005WF-VA for help-gnu-emacs@gnu.org; Sat, 04 Sep 2010 23:47:38 -0400 Original-Received: from blackcap.stats.ox.ac.uk (blackcap.stats [163.1.210.5]) by markov.stats.ox.ac.uk (8.13.6/8.13.6) with ESMTP id o853laGB025684; Sun, 5 Sep 2010 04:47:36 +0100 (BST) Original-Received: by blackcap.stats.ox.ac.uk (Postfix, from userid 5158) id 0DFBD203DA; Sun, 5 Sep 2010 04:47:36 +0100 (BST) In-Reply-To: <076A3A212B3F4180869BBBCA325A60F7@us.oracle.com> (Drew Adams's message of "Sat, 4 Sep 2010 17:25:52 -0700") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Solaris 8 (1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74888 Archived-At: "Drew Adams" writes: >> 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-; > > Yes, this is a common gotcha that you just have to learn once if you do this > kind of thing: Add this sexp at the end of your command: > > (setq deactivate-mark nil) Thanks for that Drew. Dan