bugGNU Octave - Bugs: bug #41278, "edit myFunction.m" does...

 
 

bug #41278: "edit myFunction.m" does not work when it's read-only

Submitter:  None
Submitted:  Sun 19 Jan 2014 01:50:41 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 15 Mar 2019 02:34:21 AM UTC, comment #11: 

I pushed two further changes to fix the edit function when its HOME setting is empty or references a directory that doesn't exist, and then to change the default to be unset and require the user to opt in to it.


This should fix the remaining issues here and make the edit function behave much more intuitively by default.

I've thought for a long time that this "copy read-only files into ~/octave" feature was a little too magical to be the default, very glad that it isn't now.

I did not add a warning, but I did take a cue from Julien's comment #5, so now if "editinplace" is set to false but "home" is set to a directory that doesn't exist (e.g. if ~/octave doesn't exist), edit will edit in place anyway.

Mike Miller <mtmiller>
Group Member
Sat 09 Mar 2019 11:51:22 PM UTC, comment #10: 

I'm working on some further changes to make sure the edit HOME directory is defined and exists before trying to edit files in that directory.

The new defaults will be to edit files where they already exist, or in the current working directory if they don't exist. A user will have to explicitly opt in by setting 'edit editinplace false' and 'edit home /path/to/existing/dir'.

I'll try to clean up the doc string with this change and move all of the stuff about copying files to HOME to the end as a special case. And add it to NEWS as well.

Mike Miller <mtmiller>
Group Member
Sun 03 Mar 2019 09:25:41 PM UTC, comment #9: 

I changed the default and announced it in the NEWS file (https://hg.savannah.gnu.org/hgweb/octave/rev/0a24e478a5b8).

Rik <rik5>
Group administrator
Sun 03 Mar 2019 07:06:31 PM UTC, comment #8: 

Yeah I think now would be as good a time as any to deprecate all of the features of edit releated to copying files to ~/octave to edit a copy there.

Mike Miller <mtmiller>
Group Member
Sun 03 Mar 2019 07:01:23 PM UTC, comment #7: 

Should we change the default for the "editinplace" variable of edit.m to TRUE in Octave 6.0.0?

Rik <rik5>
Group administrator
Thu 15 Dec 2016 11:04:37 AM UTC, comment #6: 

In Octave 4.2.0 this behavior is still present.

The default setting for edit editinplace is still 'false'.

Hartmut <hardy>
Sat 04 Apr 2015 06:52:14 PM UTC, comment #5: 

(continuing discussion from duplicate bug report #44720)

I agree that setting editinplace to true would be a sensible default.

Also, when editinplace is false, I think that a warning should be issued if the "home" directory doesn't exist. Perhaps copying to /tmp in this case would make sense?

Finally, I find it rather disturbing that the documentation of edit first refers to a directory named HOME (upper case), and then to home (lower case). I first thought this "HOME" had something to do with the environment variabe $HOME. But it doesn't.

Julien Bect <jbect>
Sun 19 Jan 2014 06:00:16 PM UTC, comment #4: 

I think many people have set "edit home ." and "edit editinplace 1". Maybe this bug report would be a good place to make the argument to set those to the default, and deprecate or hide the old behavior of copying files to a home directory for local editing? This would more closely match the functionality of the Matlab editor I think.

Mike Miller <mtmiller>
Group Member
Sun 19 Jan 2014 05:53:33 PM UTC, comment #3: 

Mike, you are right. All three possibilities are working.
I had the octave folder some time ago but have installed the system on a new hardware where the folder is still missing.

Torsten Lilge <ttl>
Group Member
Sun 19 Jan 2014 05:41:23 PM UTC, comment #2: 

Torsten, do you get the error you are seeing if you create the directory /home/ttl/octave first?

The behavior here is that edit tries to open the file read-write. If that fails, it tries to copy the file into your "edit home" directory, which is ~/octave by default. The error you are seeing is the same error I see when that directory doesn't exist. If you set "edit home" to another existing directory, or mkdir ~/octave first, does it work?

Alternatively, set the "edit editinplace" option to true, then it will open read-only files without trying to copy them.

Mike Miller <mtmiller>
Group Member
Sun 19 Jan 2014 04:53:30 PM UTC, comment #1: 

Confirmed on Linux:


>> edit foo
cp: cannot create regular file `/home/ttl/octave/foo.m': No such file or directory
>>


when foo.m is readonly.

Torsten Lilge <ttl>
Group Member
Sun 19 Jan 2014 01:50:41 PM UTC, original submission:  

Suppose I have
C:\\Temp\\myFun.m
and make it read-only.
then I execute:

edit myFun.m

This will fail. Octave will ask me to create the file, but that will also fail. I looked around I think the reason is the following line 318-319 in edit.m:

          fileandpath = [FUNCTION.HOME, from(rindex(from, filesep):end)];
          [status, msg] = copyfile (from, fileandpath, 1);


At this point the variables are as follows:

from = C:Temp/myFun.m
D:\\Users\\myUserName\\octave\\Temp/myFun.m

However, the directory D:UsersmyUserNameoctaveTemp does not exist, and "cp.exe -r" does not seem to create the directory, and therefore fails.
The cp.exe is used, because it is located in the path under Octave-3.8.0bin/cp.exe (given my version of http://octave.osuv.de/3.8/windows/octave-3.8.0-1-installer.exe).

I also patched the copyfile.m to always use the xcopy command on windows, but then the GUI will freeze because in this case, xcopy waits for user input on question if destination is file or directory (this is not visible to the user).

As a result, I can't open read-only file in the GUI from the command prompt.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by jbect (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-28 mtmiller StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-03-15 mtmiller StatusIn Progress Ready For Test
    2019-03-09 mtmiller StatusNeed Info In Progress
    2019-03-03 mtmiller Carbon-CopyRemoved 80942 -
    2018-04-27 mtmiller Release3.8.0 dev
    2015-07-02 mtmiller Dependencies- bugs #45422 is dependent
    2015-04-04 rik5 Dependencies- bugs #44720 is dependent
    2014-01-19 mtmiller CategoryGUI Octave Function
    2014-01-19 mtmiller StatusConfirmed Need Info
    2014-01-19 ttl StatusNone Confirmed
        Operating SystemMicrosoft Windows Any

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code