# HG changeset patch # User Carnë Draug # Date 1385247673 0 # Node ID 22187db555cf0533efed9cfaff68bd6a52749bd1 # Parent a40156e8b6a7096b0aa6840fbf91d0bcbd57b20f Remove editor option from edit() and use only EDITOR() (bug #40600) * edit.m: remove the option to specify a text editor for this function only to remove confusion about the 3 default text editors in Octave. Instead, check the value of EDITOR() everytime. * defaults.cc (FEDITOR): correct documentation since it is no longer only used by edit_history(). diff -r a40156e8b6a7 -r 22187db555cf libinterp/corefcn/defaults.cc --- a/libinterp/corefcn/defaults.cc Sat Nov 23 23:43:51 2013 +0000 +++ b/libinterp/corefcn/defaults.cc Sat Nov 23 23:01:13 2013 +0000 @@ -471,9 +471,10 @@ @deftypefn {Built-in Function} {@var{val} =} EDITOR ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} EDITOR (@var{new_val})\n\ @deftypefnx {Built-in Function} {} EDITOR (@var{new_val}, \"local\")\n\ -Query or set the internal variable that specifies the editor to\n\ -use with the @code{edit_history} command. The default value is taken from\n\ -the environment variable @w{@env{EDITOR}} when Octave starts. If the\n\ +Query or set the internal variable that specifies the default text editor.\n\ +\n\ +The default value is taken from the environment variable @w{@env{EDITOR}}\n\ +when Octave starts. If the\n\ environment variable is not initialized, @w{@env{EDITOR}} will be set to\n\ @qcode{\"emacs\"}.\n\ \n\ @@ -481,7 +482,7 @@ variable is changed locally for the function and any subroutines it calls. \n\ The original variable value is restored when exiting the function.\n\ \n\ -@seealso{edit_history}\n\ +@seealso{edit, edit_history}\n\ @end deftypefn") { return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EDITOR); diff -r a40156e8b6a7 -r 22187db555cf scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m Sat Nov 23 23:43:51 2013 +0000 +++ b/scripts/miscellaneous/edit.m Sat Nov 23 23:01:13 2013 +0000 @@ -23,7 +23,7 @@ ## Edit the named function, or change editor settings. ## ## If @code{edit} is called with the name of a file or function as -## its argument it will be opened in a text editor. +## its argument it will be opened in the text editor defined by @code{EDITOR}. ## ## @itemize @bullet ## @item @@ -70,34 +70,6 @@ ## The following control fields are used: ## ## @table @samp -## @item editor -## This is the editor to use to modify the functions. By default it uses -## Octave's @env{EDITOR} built-in function, which comes from -## @code{getenv ("EDITOR")} and defaults to @code{emacs}. Use @code{%s} -## In place of the function name. For example, -## -## @table @asis -## @item @code{[EDITOR, " %s"]} -## Use the editor which Octave uses for @code{edit_history}. -## -## @item @nospell{"xedit %s &"} -## pop up simple X11 editor in a separate window -## -## @item @nospell{"gnudoit -q \"(find-file \\\"%s\\\")\""} -## Send it to current Emacs; must have @code{(gnuserv-start)} in @file{.emacs}. -## @end table -## -## See also field @qcode{"mode"}, which controls how the editor is run by -## Octave. -## -## On Cygwin, you will need to convert the Cygwin path to a Windows -## path if you are using a native Windows editor. For example: -## @c Set example in small font to prevent overfull line in TeX -## -## @smallexample -## @exdent '"C:/Program Files/Good Editor/Editor.exe" "$(cygpath -wa %s)"' -## @end smallexample -## ## @item home ## This is the location of user local m-files. Be sure it is in your ## path. The default is @file{~/octave}. @@ -153,8 +125,7 @@ ## Pick up globals or default them. - persistent FUNCTION = struct ("EDITOR", [EDITOR() " %s"], - "HOME", fullfile (default_home, "octave"), + persistent FUNCTION = struct ("HOME", fullfile (default_home, "octave"), "AUTHOR", default_user(1), "EMAIL", [], "LICENSE", "GPL", @@ -163,6 +134,9 @@ ## Make sure the stateval variables survive "clear functions". mlock; + ## Get default editor every time in case the user has changed it + FUNCTION.EDITOR = [EDITOR() " %s"]; + if (nargin == 1) ## User has supplied one arg, this can be a single file name ## or a cell array of strings containing multiple files to be opened @@ -185,7 +159,8 @@ stateval = varargin{2}; switch (toupper (statevar)) case "EDITOR" - FUNCTION.EDITOR = stateval; + error ("Octave:deprecated-function", + "The EDITOR option of edit has been removed. Use EDITOR() directly.") return; case "HOME" if (! isempty (stateval) && stateval(1) == "~") @@ -587,14 +562,12 @@ %!test -%! s.editor = edit ("get", "editor"); %! s.home = edit ("get", "home"); %! s.author = edit ("get", "author"); %! s.email = edit ("get", "email"); %! s.license = edit ("get", "license"); %! s.editinplace = edit ("get", "editinplace"); %! s.mode = edit ("get", "mode"); -%! edit editor none %! edit home none %! edit author none %! edit email none @@ -605,14 +578,12 @@ %! else %! edit mode async %! endif -%! edit ("editor", s.editor); %! edit ("home", s.home); %! edit ("author", s.author); %! edit ("email", s.email); %! edit ("license", s.license); %! edit ("editinplace", s.editinplace); %! edit ("mode", s.mode); -%! assert (edit ("get", "editor"), s.editor); %! assert (edit ("get", "home"), s.home); %! assert (edit ("get", "author"), s.author); %! assert (edit ("get", "email"), s.email);