bugGNU Octave - Bugs: bug #58931, Right-clicking on a function name...

 
 

bug #58931: Right-clicking on a function name defined as a command-line function to edit it leads to inconsistent behaviour

Submitter:  Tasos Papastylianou <tpapastylianou>
Submitted:  Mon 10 Aug 2020 05:04:42 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Confirmed Assigned to:  None
Originator Name:  Tasos Papastylianou Open/Closed:  * Open
Release:  * 5.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 19 May 2023 02:15:16 AM UTC, comment #3: 

it may be this is related to the error:

at the cli, if you try:

edit myfun

instead of

edit myfun.m

you get the dialog:


File
<path>\myfun
does not exist. Do you want to create it?


when you click Create, however, instead of just creating a myfun.m file and opening it in the editor, you get a Save As dialog, and after saving the file, it opens up a completely blank  myfun.m window in the editor.

it seems there is some odd difference in calling 'edit myfun.m' and 'edit myfun', and since the editor appears to be doing the latter, maybe that is related to why the odd error occurs?

Nicholas Jankowski <nrjank>
Group Member
Fri 19 May 2023 02:09:37 AM UTC, comment #2: 

regarding the comment #1 question:

in the help for edit, when someone tries to edit a function that has been defined at the command line, the expected behavior is:


If NAME is the name of a command-line function, then an m-file
will be created to contain that function along with its
current definition.


sure enough, creating a function at the command line:


>> function y = myfun(x), y = 2(x); endfunction

>> myfun(4)
ans = 8

>> edit myfun.m


brings up the 'file does not exist, do you want to create it' dialog. if you say yes, it creates a myfun.m file in the current working directory, and the editor opens it showing the current Octave copyright header, template docsctring, and:


myfun is the command-line function:

function a = myfun (b)
  a = 2 * b;
endfunction


however, if you make another function that calls myfun, open it in the editor, right click on it, and select Edit myfun you get the error:

"myfun is a built-in, compiled, or inline function and cannot be edited"

It seems that doing so should produce the same behavior as typing edit myfun from the cli.





Nicholas Jankowski <nrjank>
Group Member
Tue 11 Aug 2020 09:01:08 PM UTC, comment #1: 

Octave-7.0.0 (dev) on Windows does the same as Octave-5.1.0. So apparently it has been "fixed" or "restored".

Your other question, at least what I could make from it, seems logical at first sight. But then, how would you edit a command line function, which -as the name says- is defined using the command line?
Have you compared with Matlab?

Philip Nienhuis <philipnienhuis>
Group Member
Mon 10 Aug 2020 05:04:42 PM UTC, original submission:  

Prompted by this question on stackoverflow: https://stackoverflow.com/q/63325950/4183191

Steps to reproduce:
Step 1: Create the following script called myfunctiondefs.m


1;
function f1(); disp('hello from f1'); endfunction
function f2(); disp('hello from f2'); endfunction


Step 2: Create script myscript.m in the same directory


myfunctiondefs
f1()
f2()


Step 3: Open myscript.m in the octave GUI editor, run it once to generate the function definitions in the current session, and then highlight "f2" with the mouse, right-click, and select Edit f2 from the context menu.

Expected outcome: A generated f2.m file in the user's home folder, i.e. the same as what would have happened if one manually typed "edit f2.m" in the terminal.

Observed outcome:
 - In octave v5.1.0: A popup window saying "f2 is a built-in, compiled, or inline function and cannot be edited".

 - In octave v5.2.0: An empty, nameless m-file (in other words, a file called ".m" is created in the current directory).

Clearly there's a regression bug between v5.1.0 and v5.2.0.

However, the bigger question is, when a name in the GUI editor is a reference a command-line function, which doesn't right-clicking and selecting to edit it behave the same as the equivalent "edit" command?

Tasos Papastylianou <tpapastylianou>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by tpapastylianou (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-05-19 nrjank Carbon-Copy- Added ttl
    2023-05-19 nrjank StatusNone Confirmed

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code