From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Mathias Dahl Newsgroups: gmane.emacs.help Subject: Re: Edit region in different mode Date: 23 Dec 2004 13:17:20 +0100 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1103804378 5681 80.91.229.6 (23 Dec 2004 12:19:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 23 Dec 2004 12:19:38 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 23 13:19:32 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ChRwJ-0004JH-00 for ; Thu, 23 Dec 2004 13:19:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1ChS6u-0003JZ-Qv for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Dec 2004 07:30:28 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-X-Trace: individual.net 82cEFAMCxGBf2vyLUl4UUwXC9suQSjVr/Ve4g3Jd/44o8QAQEg User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-Xref: shelby.stanford.edu gnu.emacs.help:127491 Original-To: help-gnu-emacs@gnu.org 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: main.gmane.org gmane.emacs.help:22948 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:22948 Albert Reiner writes: > ...I would like to get a new buffer with everything between point > and mark (or maybe some other positions found by searching), set a > different editing mode in that new buffer, and have the editing take > effect in the original buffer when I am done. I suspect this should > be possible by some combination of clone-indirect-buffer and > narrowing but I don't quite know how to go about this. You could create two macros that helps you out, one that copies the region and pastes it into a temporary buffer and enter some mode: M-w ;; kill-ring-save C-x b ;; iswitchb-buffer tempo ;; self-insert-command * 5 RET ;; newline C-y ;; yank M-x ;; execute-extended-command text ;; self-insert-command * 4 SPC ;; self-insert-command mode ;; self-insert-command * 4 RET ;; newline And a macro that copies all text in the temp buffer, kills the buffer, goes back to the previous buffer, deletes the region and pastes what was copied: ;; beginning-of-buffer C-SPC ;; set-mark-command ;; end-of-buffer M-w ;; kill-ring-save C-x k ;; kill-buffer RET ;; newline M-x ;; execute-extended-command delete ;; self-insert-command * 6 SPC ;; self-insert-command reg ;; self-insert-command * 3 TAB ;; indent-for-tab-command RET ;; newline C-y ;; yank For your convenience, should you decide to use them, here they are for pasting into your .emacs: (fset 'edit-region-in-tempo [?\M-w ?\C-x ?b ?t ?e ?m ?p ?o ?\C-m ?\C-y ?\M-x ?t ?e ?x ?t ? ?m ?o ?d ?e ?\C-m]) (fset 'edit-region-in-tempo-go-back [C-home ?\C- C-end ?\M-w ?\C-x ?k return ?\M-x ?d ?e ?l ?e ?t ?e ? ?r ?e ?g tab return ?\C-y]) Ah, the wonders of keyboard macros! Of course, neither of these macros are very hard to write in some lines of elisp. /Mathias