[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Edit region in different mode
From: |
Mathias Dahl |
Subject: |
Re: Edit region in different mode |
Date: |
23 Dec 2004 13:17:20 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Albert Reiner <areiner@tph.tuwien.ac.at> 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:
<C-home> ;; beginning-of-buffer
C-SPC ;; set-mark-command
<C-end> ;; 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
Re: Edit region in different mode,
Mathias Dahl <=
Re: Edit region in different mode, Oliver Scholz, 2004/12/23