bugGNU Octave - Bugs: bug #40450, edit new.m file behaviour

 
 

bug #40450: edit new.m file behaviour

Submitter:  John Donoghue <lostbard>
Submitted:  Sat 02 Nov 2013 12:17:00 AM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  John Donoghue 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

Sat 09 Nov 2013 08:07:11 AM UTC, comment #18: 

Rik, thanks for pushing the cset. If I knew you are pushing the patch right away I would have prepared a complete patch with comment.

Torsten Lilge <ttl>
Group Member
Fri 08 Nov 2013 04:14:14 PM UTC, comment #17: 

Works for me as well.

Ben Abbott <bpabbott>
Group Member
Fri 08 Nov 2013 03:44:34 PM UTC, comment #16: 

Works for me.  I added a check-in note and then committed the change under your name here (http://hg.savannah.gnu.org/hgweb/octave/rev/766ad9be2966).  Closing report.

Rik <rik5>
Group administrator
Fri 08 Nov 2013 07:45:49 AM UTC, comment #15: 

The attached patch uses octave-qt-link for the dialog prompting for file creation. The editor's preference "always create new files" is respected.
The behavior of "edit" in cli-mode has not changed.

(file #29568)

Torsten Lilge <ttl>
Group Member
Thu 07 Nov 2013 08:50:21 PM UTC, comment #14: 

Okay, if I need more time to get the octave-qt-link version I will push the edit.m patch (with the issues mentioned by John fixed).

I also  thought about using "edit" for creating a new script in the gui. But AFAIK "edit" needs the new file name whereas the "new" menu creates an empty editor tab without an existing file on disk. A possible solution could be that "new" opens a file dialog in order to chose the file location and name (like "save as") and then "edit file_name" is called.

Torsten Lilge <ttl>
Group Member
Thu 07 Nov 2013 08:30:19 PM UTC, comment #13: 

Behavior generally seems right.  It would be nice to use octave-qt-link, but as a first step you might commit this fix.  That way if you don't get enough time to implement the octave-qt-link before the release the behavior will still be better.

On a second note, if edit is changed to behave like the GUI would fixing bug #40502 become trivial?  It seems like there is the possibility to get the code right in edit.m and octave-qt-link and then when someone does File->New->Function the GUI would actually just call edit.m with a filename like "new_function.m"

Rik <rik5>
Group administrator
Thu 07 Nov 2013 07:51:40 PM UTC, comment #12: 

works for me - there is a typo in the question dialog text and it prints out 'create_file'

If it is changed to use the octave-qt-link, it should be able to use the preferences setting  again to determinate whether to prompt ?(for those who don't like the prompt)

John Donoghue <lostbard>
Group Member
Thu 07 Nov 2013 07:37:09 PM UTC, comment #11: 

Attached a patch that makes edit.m prompting before creating a new file regardless the extension but only if in gui-mode. The drawback is that questdlg is used and therefore the strings of the dialog are not translated by the qt-translator and the settings can not be accessed for the "always create new files"-option.
If the behavior is as desired I would try to use octave-qt-link to overcome this.

(file #29564)

Torsten Lilge <ttl>
Group Member
Thu 07 Nov 2013 01:41:40 PM UTC, comment #10: 

In the event that my last comment was misunderstood, it is Matlab that prompts for the creation of all non-existing files.  There is no difference in behavior between files with different suffixes.

Personally, I find the prompt annoying, and would prefer the file just be created.  But if the consensus is to prompt, then I'd favor consistent behavior across all file-types. And have the default behavior of the prompt be to create the file.

From the CLI, I'd prefer the edit command just go with the default behavior and skip the prompt/warning.

Ben Abbott <bpabbott>
Group Member
Thu 07 Nov 2013 01:08:52 PM UTC, comment #9: 

.cc and .m files don't prompt for creation for me either, just the ones that aren't handled explicitly by edit.m.

I would  prefer that the GUI (when available) prompts to create all files as I have the same issue that Philip has in comment 7. (Matlab prompts on all files, and is what I what I would expect a GUI application to do)

Perhaps another bug report here is that if I type 'edit' without a file name I get differing results:
GUI: edit doesn't appear to do anything
CLI: attempt to open EDITOR with the current directory as a file name.
Matlab: opens a new edit window.

John Donoghue <lostbard>
Group Member
Thu 07 Nov 2013 05:48:02 AM UTC, comment #8: 

edit foo.m or foo.cc does not show the creation dialog for me. The file has already been created by edit.m when the editor is called, so no need for a dialog (from the editor's point of view). Only other file types are not automatically created by edit.

This behavior does not differ from the case where an external editor is used (.m and .cc are created and the editor is called, other file names are passed to the editor leaving it up to it how to handle new files).


Torsten Lilge <ttl>
Group Member
Wed 06 Nov 2013 09:36:01 PM UTC, comment #7: 

I often hit this issue when using the CLI, of creating unwanted .m files because I overlooked that I was in the wrong subdir.
So I'd be in favor of a warning, before actually creating the requested non-existing file, in the CLI as well.

(I usually have data in the working directory and m-files in another subdir (often called "m-files" :-) ).  As you'd guess many m-files inadvertently end up in the data subdir.)

Just my 2 $c

Philip Nienhuis <philipnienhuis>
Group Member
Wed 06 Nov 2013 06:45:13 PM UTC, comment #6: 

Is this an area where we would like to copy Matlab's behavior?

For non-existent files, "edit foo" results in a dialog asking if foo.m should be created.  Using "foo.m", "foo.c", "foo.cc", "foo.txt", etc gives the same behavior (with the ".m" suffix replaced the the suffix used).

I think it reasonable for the CLI version to default to creating the file asked for, but am uncertain what "edit foo" should do for the CLI.  Should the CLI treat "edit foo" as "edit foo.m" or just create the file "foo" with no suffix?

Ben Abbott <bpabbott>
Group Member
Wed 06 Nov 2013 06:40:13 PM UTC, comment #5: 

Personally, I like the prompt option in the GUI.
In gui mode can we prompt for any editor file creation (based on setting), and in cli, display a warning or something so its obvious that a file has been created?

John Donoghue <lostbard>
Group Member
Wed 06 Nov 2013 06:30:46 PM UTC, comment #4: 

Torsten put in an option and GUI code to deal with the case of calling edit on a non-existent file.  If we want the same behavior between GUI and CLI we could remove the option and fall back on having edit always create a blank file if one does not exist.  I don't know if consistency is that valuable, but it would be easy to do.

Rik <rik5>
Group administrator
Sat 02 Nov 2013 10:14:31 AM UTC, comment #3: 

I guessed that was the case, it just doesn't seem consistent (ie confusing).

John Donoghue <lostbard>
Group Member
Sat 02 Nov 2013 07:30:08 AM UTC, comment #2: 

This is the behavior of edit.m. Files with extensions .m or .cc are created by edit.m with the usual comments at the beginning. The request to open other files (including .c) are directly passed to the editor.
The option in the settings just controls the behavior of the gui's editor not that of edit.m.


Torsten Lilge <ttl>
Group Member
Sat 02 Nov 2013 02:14:17 AM UTC, comment #1: 

This is related to bug # 40312

https://savannah.gnu.org/bugs/?40312

I'll cc Torsten

Ben Abbott <bpabbott>
Group Member
Sat 02 Nov 2013 12:17:00 AM UTC, original submission:  

I dont think its been mentioned:

If I run the command edit x.c (x.m is does not exist) and I dont have set the create without prompting option, then I get a dialog box asking to create.
If I run edit x.m (x.m does not exist) it just silently makes the new file - no matter on the settings.

To be consistent it should prompt to create the m-file as well.

John Donoghue <lostbard>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #29564:  prompt_new_file.diff added by ttl (2KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by bpabbott (cc: Torsten)
  • -email is unavailable- added by lostbard (Submitted the item)
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-08 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2013-11-08 ttl Attached File- Added prompt_new_file_20131108-1.diff, #29568
        StatusConfirmed Ready For Test
    2013-11-07 ttl Attached File- Added prompt_new_file.diff, #29564
    2013-11-02 bpabbott StatusNone Confirmed
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code