octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: edit.m and EDITOR


From: Ben Abbott
Subject: Re: edit.m and EDITOR
Date: Tue, 10 Apr 2012 17:28:11 -0400

On Apr 10, 2012, at 5:04 PM, Jordi Gutiérrez Hermoso wrote:

> 2012/4/10 Ben Abbott <address@hidden>:
>> On Apr 10, 2012, at 4:26 PM, Jordi Gutiérrez Hermoso wrote:
> 
>>> The problem I'm trying to solve is that EDITOR and edit shouldn't be
>>> storing separate variables for the EDITOR command. How do you
>>> recommend to solve this instead?
>> 
>> 
>> I'd forgotten about this conflict.
>> 
>> Should we be using preferences instead ?
>> 
>> i.e. addpref, ispref, setpref, getpref, rmpref
> 
> I don't see how those solve this problem... we already have a way to
> set the preference, the EDITOR function-variable does this. The
> problem is that I don't know how to fix the two copies of the EDITOR
> variable in EDITOR and edit.m without breaking part of edit.m's
> interface.
> 
> - Jordi G. H.

I was thinking we should have one solution for all preferences.

It just seems kludgy to create a built-in each time we need a preference.

In any event, I don't see why edit.m can't be modified to reconcile EDITOR with 
FUNCTION.EDITOR. Does the diff below work for you ?

$ hg diff
diff --git a/scripts/miscellaneous/edit.m b/scripts/miscellaneous/edit.m
--- a/scripts/miscellaneous/edit.m
+++ b/scripts/miscellaneous/edit.m
@@ -163,7 +163,8 @@
   if (nargin == 2)
     switch (toupper (file))
     case "EDITOR"
-      FUNCTION.EDITOR = state;
+      words = strsplit (state, " ");
+      EDITOR (words{1});
     case "HOME"
       if (! isempty (state) && state(1) == "~")
         state = [ default_home, state(2:end) ];
@@ -204,6 +205,10 @@
     return
   endif
 
+  if (! strncmp (FUNCTION.EDITOR, EDITOR (), numel (EDITOR ())))
+    FUNCTION.EDITOR = cstrcat (EDITOR (), " %s");
+  endif
+
   ## Start the editor without a file if no file is given.
   if (nargin < 1)
     if (exist (FUNCTION.HOME, "dir") == 7 && (isunix () || ! ispc ()))

Ben

Attachment: edit.diff
Description: Binary data



reply via email to

[Prev in Thread] Current Thread [Next in Thread]