help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Edit region in different mode


From: Pascal Bourguignon
Subject: Re: Edit region in different mode
Date: 22 Dec 2004 20:51:07 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Albert Reiner <areiner@tph.tuwien.ac.at> writes:

> ["V. L. Simpson" <vls@freeshell.org>, 22 Dec 2004 10:25:42 -0600]:
> > >>>>> "Albert" == Albert Reiner <areiner@tph.tuwien.ac.at> writes:
> > 
> >     > Hi, is there a way of editing the current region in a
> >     > different mode?  OK,
> > 
> > Try http://mmm-mode.sourceforge.net/
> 
> Thanks, but I am well aware of mmm mode, and it does not seem to be a
> solution to my problem: although the documentation seems hard to find,
> I believe that mmm mode still requires me to put tags into the file
> that indicate where to switch between modes.  This is not what I want;
> in fact, it is what I already have but is giving me trouble in some
> cases.  I really only want to edit in a different mode for a short
> period of time, without leaving any mode-related traces in the file.

I'd do narrow-to-region and xyz-mode
then widden and original-mode

> Maybe I should explain in more detail: I am using noweb mode with
> noweb-code-mode set to lisp-mode (which is in fact slime mode).
> Unfortunately the lisp-mode indentation and filling functions do not
> work very well in lisp doc strings, and all the more so when the
> quotes are not part of the same code chunk.  Part of the problem is
> that noweb-mode overrides any M-x outline-mode RET in what it knows is
> a code chunk.

Yes, I have the same problem. Here's what I have in my ~/.emacs:

(global-set-key [f5]       'set-justification-left)

(global-set-key [3 f5]    (lambda (start end) (interactive "r") 
                              (let ((mode major-mode))
                                (text-mode)
                                (set-justification-left start end)
                                (funcall mode))))

So F5 does the justification of the region in the current mode, which
is wrong in lisp mode.

C-c F5 does the justification in the text mode and then reverts to the
saved major-mode.


> So whenever I write a long documentation string I copy the old text
> to *scratch*, change to outline-mode, write / edit there, copy the
> edited text back.  Or sometimes I remove the chunk-starting line,
> edit (effectively in LaTeX mode, which may be sufficient), and add
> back the chunk-starting line.  I have also tried M-: (setq
> noweb-code-mode 'outline-mode) RET and M-x normal-mode RET later,
> but none of these are very convenient.

I guess it should be possible to write commands to _push_ and _pop_
modes...
 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein


reply via email to

[Prev in Thread] Current Thread [Next in Thread]