<<< Date Index >>>     <<< Thread Index >>>

Re: dynamically switching $editor [keybinding question]



On 2005-10-05, "Wilkinson, Alex" <alex.wilkinson@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi all,
> 
> Can someone tell me if it is possible to set a keybinding to
> dynamically switch between different $editors on the fly ?
> 
> e.g. I want to be able to set a keybinding that will switch between
>      the following 2 $editor:
> 
>      set editor="vim -c 'set filetype=mail' -c 'set textwidth=70' +:$ +:star!"
>      set editor="vim"
> 
> Is this possible ?

Yes.  The tricky part is handling three levels of nested quotes.  
This should work.

    macro index ,E 'set editor="vim -c \"set filetype=mail\" -c \"set 
textwidth=70\" +:$ +:star!"'
    macro index ,e 'set editor="vim"'

Those define keybindings for the index menu.  If you want to be able
to switch editors from some other mutt menu, you'll have to add
macros for them as well.

I chose ",E" and ",e" to invoke the macros, but you can use
single-letter keybindings instead if you prefer.

See the mutt manual, section 3.6, "Keyboard macros".

There is a way to toggle back and forth between editor settings
with one keybinding, but it's more involved.  Here's an example
Alain Bench posted in Sept. 2004 and attributed to David T-G:

| macro pager ,@r13on "<enter-command>set display_filter=/usr/local/bin/rot13 ;\
|       macro pager \\er ,@r13off 'Toggle ROT13 decoding'\
|       <Enter><exit><display-message>"
|
| macro pager ,@r13off "<enter-command>unset display_filter ;\
|       macro pager \\er ,@r13on 'Toggle ROT13 decoding'\
|       <Enter><exit><display-message>"
|
| macro pager \er ,@r13on 'Toggle ROT13 decoding'

HTH,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA