bugGNU Octave - Bugs: bug #44695, edit() doesn't open editor when...

 
 

bug #44695: edit() doesn't open editor when --no-gui used

Submitter:  Rik <rik5>
Submitted:  Wed 01 Apr 2015 11:27:42 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  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

Thu 02 Apr 2015 05:36:26 PM UTC, comment #6: 

Pushed the cset here (http://hg.savannah.gnu.org/hgweb/octave/rev/002576bbba10).  Closing report.

Rik <rik5>
Group administrator
Thu 02 Apr 2015 04:51:17 PM UTC, comment #5: 

I think this is OK for now.  Longer term I will try to look at a better way to handle communication between the GUI and the interpreter, or at least do the right thing in the octave_link functions.

John W. Eaton <jwe>
Group administrator
Thu 02 Apr 2015 03:50:40 PM UTC, comment #4: 

Attached is a cset that works for me.  I did use isguirunning() because it was the smallest quantum change necessary to fix the bug.  Recoding _octave_link_edit_file_ seems okay, but I didn't feel like tackling it and finding the other instances where we have used this construct.

Just as second example, in doc.m


## if GUI is running, let it display the function
if (isguirunning ())
  __octave_link_show_doc__ (fname);
else




(file #33511)

Rik <rik5>
Group administrator
Thu 02 Apr 2015 01:52:30 PM UTC, comment #3: 

Instead of checking isguirunning, I think it should be the responsibility of the _octave_link_edit_file_ function to return false if it can't do the job.

John W. Eaton <jwe>
Group administrator
Thu 02 Apr 2015 01:48:44 PM UTC, comment #2: 

The code in question is the do_edit function


function do_edit (editor, file, mode)

  ## Give the hook function a chance.
  ## If that fails, fall back on running an editor with the system function.

  status = __octave_link_edit_file__ (file);

  if (! status)
    system (sprintf (undo_string_escapes (editor), ['"' file '"']), [], mode);
  endif

endfunction


It seems that somewhere in this function isguirunning() should be checked before invoking _octave_link_edit_file_.

Rik <rik5>
Group administrator
Thu 02 Apr 2015 07:23:31 AM UTC, comment #1: 

If you'd like to change the meaning of the return value (i.e., zero for success), go ahead.

Specific to this bug report, the _octave_link_edit_file_() script shouldn't even be run.  In my version of the code is:


    ## If editing a new file, prompt for creation if gui is running
    if (isguirunning ())
      if (! __octave_link_edit_file__ (file, "prompt"));
        return;
      endif
    endif


Has something changed regarding this code?  Or perhaps in isguirunning()?  Here is the isguirunning() definition as I have:


// Return int instead of bool because this function is declared extern "C".

int
octave_starting_gui (void)
{
  start_gui = check_starting_gui ();
  return start_gui;
}

DEFUN (isguirunning, args, ,
       "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} isguirunning ()\n\
Return true if Octave is running in GUI mode and false otherwise.\n\
@seealso{have_window_system}\n\
@end deftypefn")
{
  octave_value retval;

  if (args.length () == 0)
    retval = start_gui;
  else
    print_usage ();

  return retval;
}


Dan Sebald <sebald>
Wed 01 Apr 2015 11:27:42 PM UTC, original submission:  

I have the environment variable EDITOR set to 'gvim -f'.  When running the Octave CLI it used to be that "edit filename" would open the file in the external editor.  Now this only works if I run octave with the '--no-gui-libs' option rather than just '--no-gui'.

The problem seems to be this line in edit.m:


status = __octave_link_edit_file__ (file);


This returns 1 and so the next lines are not executed


if (! status)
  system (sprintf (undo_string_escapes (editor), ['"' file '"']), [], mode);
endif


First, shouldn't Octave be using the C/UNIX convention that 0 means OK and any non-zero value indicates an error code?

Second, _octave_link_edit_file_ returns 1 both when running the GUI and when running the CLI, but there is no editor to switch to in the CLI.

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #33511:  edit_ext.cset added by rik5 (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by rik5 (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-02 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2015-04-02 rik5 Attached File- Added edit_ext.cset, #33511

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code