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: How to create new buffer with t-m-m active region? Date: Sat, 04 Sep 2010 14:38:48 -0400 Message-ID: <87k4n11hhj.fsf@stats.ox.ac.uk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1283625566 12051 80.91.229.12 (4 Sep 2010 18:39:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 4 Sep 2010 18:39:26 +0000 (UTC) To: help-gnu-emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 04 20:39:25 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 1Orxe6-00086P-8v for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Sep 2010 20:39:22 +0200 Original-Received: from localhost ([127.0.0.1]:38580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Orxe5-0007Lf-C6 for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Sep 2010 14:39:21 -0400 Original-Received: from [140.186.70.92] (port=53429 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Orxde-0007JC-SL for help-gnu-emacs@gnu.org; Sat, 04 Sep 2010 14:38:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Orxdd-0008Do-Sn for help-gnu-emacs@gnu.org; Sat, 04 Sep 2010 14:38:54 -0400 Original-Received: from markov.stats.ox.ac.uk ([163.1.210.1]:61490) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Orxdd-0008De-Lt for help-gnu-emacs@gnu.org; Sat, 04 Sep 2010 14:38:53 -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 o84Icpa0004567 for ; Sat, 4 Sep 2010 19:38:52 +0100 (BST) Original-Received: by blackcap.stats.ox.ac.uk (Postfix, from userid 5158) id B5C7A203DA; Sat, 4 Sep 2010 19:38:51 +0100 (BST) 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:74881 Archived-At: 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