octave-maintainers
[Top][All Lists]
Advanced

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

Re: edit.m and EDITOR


From: Michael Goffioul
Subject: Re: edit.m and EDITOR
Date: Wed, 11 Apr 2012 14:08:48 +0100

On Wed, Apr 11, 2012 at 1:31 PM, John W. Eaton <address@hidden> wrote:
> On 11-Apr-2012, Mike Miller wrote:
>
> | Maybe I'm way off here, but I'll throw in anyway.  I do see a difference
> | between EDITOR and edit's FUNCTION.EDITOR.  In the context of the edit
> | command, people seem to want to fork an editor in the background, edit
> | code while you still have access to the Octave shell.  Indeed, as I
> | recently learned, the default edit "mode" is now "async".
> |
> | For edit_history, the EDITOR is called synchronously a la Unix "fc".  It
> | must be that way for the results to be useful.  For me, that means I
> | want it to happen in the same terminal.
> |
> | Maybe these are still the same for most people, but for me:
> |
> |   octave:1> getenv("EDITOR"), EDITOR, edit get EDITOR
> |   ans = vim
> |   ans = vim
> |   ans = gvim %s
> |
> | If these do collapse to one setting, I'm sure I'll be ok :)
>
> OK, I didn't realize that the value of EDITOR in the edit function was
> not just the name of the editor program, but also could contain some
> format specification.  Ugh.  I don't see a good solution that won't
> break backward compatibility in some way.

Well, remember that the initial confusion comes from the fact that the
edit.m help says it's using EDITOR by default. But that's not entirely
true, because of FUNCTION.EDITOR being persistent. So whenever edit.m
is loaded by octave (whatever the reason), FUNCTION.EDITOR is "fixed"
to "[EDITOR, ' %s']" and any later change of EDITOR variable is
ignored by edit.m.

I suggested to solve that confusion by leaving FUNCTION.EDITOR empty
instead of initializing it to "[EDITOR, ' %s']". Then in the rest of
edit.m, if FUNCTION.EDITOR is not empty, use it, otherwise use
"[EDITOR, ' %s']". That way, EDITOR variable will always be honored by
edit.m, except if the editor has been explicitly overridden by calling
"edit('EDITOR', ...)".

Michael.


reply via email to

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