diff --git a/scripts/miscellaneous/edit.m b/scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -150,8 +150,7 @@ ## Pick up globals or default them. - persistent FUNCTION = struct ("EDITOR", cstrcat (EDITOR (), " %s"), - "HOME", fullfile (default_home, "octave"), + persistent FUNCTION = struct ("HOME", fullfile (default_home, "octave"), "AUTHOR", default_user(1), "EMAIL", [], "LICENSE", "GPL", @@ -163,7 +162,7 @@ if (nargin == 2) switch (toupper (file)) case "EDITOR" - FUNCTION.EDITOR = state; + EDITOR (state); case "HOME" if (! isempty (state) && state(1) == "~") state = [ default_home, state(2:end) ]; @@ -195,6 +194,8 @@ case "GET" if (isfield (FUNCTION, toupper(state))) ret = FUNCTION.(toupper (state)); + elseif (strcmpi (state, "editor")) + ret = EDITOR; else ret = FUNCTION; endif @@ -207,11 +208,10 @@ ## Start the editor without a file if no file is given. if (nargin < 1) if (exist (FUNCTION.HOME, "dir") == 7 && (isunix () || ! ispc ())) - system (cstrcat ("cd \"", FUNCTION.HOME, "\" ; ", - sprintf (FUNCTION.EDITOR, "")), + system (cstrcat ("cd \"", FUNCTION.HOME, "\" ; ", EDITOR), [], FUNCTION.MODE); else - system (sprintf (FUNCTION.EDITOR,""), [], FUNCTION.MODE); + system (EDITOR, [], FUNCTION.MODE); endif return; endif @@ -281,7 +281,7 @@ ## If the file exists, then edit it. if (FUNCTION.EDITINPLACE) ## Edit in place even if it is protected. - system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), + system (sprintf ("%s %s", EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); return; else @@ -298,7 +298,7 @@ else fclose (fid); endif - system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), + system (sprintf ("%s %s", EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); return; endif @@ -314,7 +314,7 @@ case {"cc", "m"} 0; otherwise - system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), + system (sprintf ("%s %s", EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); return; endswitch @@ -461,7 +461,7 @@ fclose (fid); ## Finally we are ready to edit it! - system (sprintf (FUNCTION.EDITOR, cstrcat ("\"", fileandpath, "\"")), + system (sprintf ("%s %s", EDITOR, cstrcat ("\"", fileandpath, "\"")), [], FUNCTION.MODE); endfunction