octave-maintainers
[Top][All Lists]
Advanced

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

Re: edit.m: patches to restore and fix old behavior for new files


From: Mike Miller
Subject: Re: edit.m: patches to restore and fix old behavior for new files
Date: Wed, 18 Apr 2012 16:55:15 -0400

On Wed, Apr 18, 2012 at 1:34 PM, Luke M <address@hidden> wrote:
>
> Mike Miller-2 wrote
>>
>> Hi, I have a series of patches for the edit function that restore some
>> behavior that hasn't worked since 3.0.x, and fix some quirks, all having
>> to do with editing new files.  Technically this is a regression against
>> 3.0.x, but no one's reported it, maybe I'm the only one who has noticed.
>>
>> (snip)
>>
>> Current dev:
>>
>>   octave:1> edit myfunc      | empty file          | ./myfunc
>>   octave:2> edit myfunc.m    | function "myfunc"   | ./myfunc.m
>>   octave:3> edit myfunc.cc   | C function "myfunc" | ./myfunc.cc
>>   octave:4> edit notes.txt   | empty file          | ./notes.txt
>>   octave:5> edit ./myfunc.m  | function "./myfunc" | ./myfunc.m
>>   octave:6> edit /tmp/myfunc | empty file          | /tmp/myfunc
>>
>> With my patches applied:
>>
>>   octave:1> edit myfunc      | function "myfunc"   | HOME/myfunc.m
>>   octave:2> edit myfunc.m    | function "myfunc"   | HOME/myfunc.m
>>   octave:3> edit myfunc.cc   | C function "myfunc" | HOME/myfunc.cc
>>   octave:4> edit notes.txt   | empty file          | HOME/notes.txt
>>   octave:5> edit ./myfunc.m  | function "myfunc"   | ./myfunc.m
>>   octave:6> edit /tmp/myfunc | empty file          | /tmp/myfunc
>>
>
> Matlab 2010b (SP1) and 2011b both act mostly like current dev.  Slight
> differences:

True, there are differences.  Both 3.6.x and default: edit a function
that already exists in Octave, say "corr", it copies the m-file to the
HOME directory before editing it (default behavior with
EDITINPLACE=false), Matlab edits the file in the system path.  I
started with the assumption that this difference from Matlab is
desired and I'm trying to make it work for new files also, the way it
used to.  Maybe that assumption is wrong :)

I would say my first patch makes the use of the HOME directory
consistent when editing a new file vs. a system function.

Note if you set HOME to "." and EDITINPLACE to true, you get Matlab
behavior.  Maybe these should be the defaults if compatibility is
important here.

> - Matlab automatically adds the .m extension in the first example (but
> creates the file in '.')

Ack.  This is the fix in the third cset I attached.

> - Matlab pops up a warning dialog asking if you want to create a new file
>
> I don't have Octave handy, so I'm not sure if this is a difference or not:
>
> - If you say yes to the dialog, Matlab creates the file first, then opens it
> for editing (I assume Octave just calls the external editor, which probably
> opens a temporary buffer and only creates the file on save)

If you edit a new file in Octave with a .m or .cc extension, it
creates the file for you, whether you save it or not, with some
boilerplate code for a new Octave function in the appropriate
language.  This is also different from Matlab, but, I am again
assuming, desired to keep it that way.  My second cset fixes a bug
where the function name inserted into the boilerplate is wrong if you
pass edit a filename with any path components in it (cmd #5 above).

> Perhaps the changes in current dev are intentional, but the documentation
> was not updated?

Could be, I believe this is the change that stopped creating new files
in HOME and just edits them in pwd:

http://hg.savannah.gnu.org/hgweb/octave/rev/2ce6b4258e96#l2.155

Ben, was this intentional?  If so, why was that changed but still copy
existing function files into HOME (line 184, same changeset)?

Thanks.

-- 
mike


reply via email to

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