From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Edit region in different mode
Date: Thu, 23 Dec 2004 10:01:01 -0700 [thread overview]
Message-ID: <330buiF3rjdoaU1@individual.net> (raw)
In-Reply-To: <87fz1x6usl.fsf@ID-87814.user.uni-berlin.de>
Oliver Scholz wrote:
> I use the following to write Emacs Lisp in my usenet postings:
>
> (defun egoge-write-elisp ()
> (interactive)
> (if (not (eq major-mode 'message-mode))
> (message "Not a message buffer.")
> (switch-to-buffer (make-indirect-buffer (current-buffer)
> "*emacs-lisp-message*"))
> (emacs-lisp-mode)))
>
>
> I guess, this could serve as a starter for you.
It's an excellent start. Here's what I've come up with, based on that:
(defun edit-region (&optional edit-mode)
"Edit the current region in a separate buffer.
With a prefix arg, change `major-mode' to EDIT-MODE."
(interactive (list (if current-prefix-arg
(intern (completing-read (format "Major mode
(%s): "
major-mode)
obarray
'major-mode-p
t nil nil
(symbol-name
major-mode))))))
(clone-indirect-buffer nil t)
(narrow-to-region (region-beginning) (region-end))
(shrink-window-if-larger-than-buffer)
(when edit-mode
(funcall edit-mode)))
(defun major-mode-p (symbol)
"Return non-nil if SYMBOL is a major mode."
(and (fboundp symbol)
(let ((function-name (symbol-name symbol)))
(and (string-match "-mode\\'" function-name)
(not (string-match "\\`turn-\\(on\\|off\\)-"
function-name))))
(not (assq symbol minor-mode-alist))))
--
Kevin Rodgers
prev parent reply other threads:[~2004-12-23 17:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-22 16:19 Edit region in different mode Albert Reiner
2004-12-22 16:25 ` V. L. Simpson
2004-12-22 17:05 ` Albert Reiner
2004-12-22 19:51 ` Pascal Bourguignon
2004-12-22 23:14 ` Kevin Rodgers
2004-12-23 1:03 ` Pascal Bourguignon
2004-12-23 17:42 ` Albert Reiner
2004-12-23 12:17 ` Mathias Dahl
2004-12-23 12:52 ` Oliver Scholz
2004-12-23 17:01 ` Kevin Rodgers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=330buiF3rjdoaU1@individual.net \
--to=ihs_4664@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.