Re: [StGit PATCH 4/5] Simplify editor selection logic

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

 



Subject: [PATCH] use the same search order for picking a editor as git

Signed-off-by: Peter Oberndorfer <kumbayo84@xxxxxxxx>
---
On Dienstag 29 Januar 2008, Karl Hasselström wrote:
> Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>
> 
> ---
> 
> There are a few other env variables we might like to look at, like
> VISUAL. And isn't there a git-specific variable too?
> 
>  stgit/utils.py |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> 
> diff --git a/stgit/utils.py b/stgit/utils.py
> index 00776b0..43366c9 100644
> --- a/stgit/utils.py
> +++ b/stgit/utils.py
> @@ -175,12 +175,8 @@ def call_editor(filename):
>  
>      # the editor
>      editor = config.get('stgit.editor')
> -    if editor:
> -        pass
> -    elif 'EDITOR' in os.environ:
> -        editor = os.environ['EDITOR']
> -    else:
> -        editor = 'vi'
> +    if not editor:
> +        editor = os.environ.get('EDITOR', 'vi')
>      editor += ' %s' % filename
>  
>      out.start('Invoking the editor: "%s"' % editor)

Since i personally dislike having a separate config for the editor in git/stgit
i locally use this patch.
unfortunately it makes the whole editor searching thing more complex :-(
But i am sure it is possible to rewrite the code to something easier
with some more python knowledge :-/
So it is not meant for direct applying, just for discussion...

TODO: update sample gitconfig?
TODO: do the same for pager?

 Documentation/stg-new.txt |    6 ++++++
 stgit/utils.py            |   10 +++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/Documentation/stg-new.txt b/Documentation/stg-new.txt
index fbf2f67..a728d8e 100644
--- a/Documentation/stg-new.txt
+++ b/Documentation/stg-new.txt
@@ -31,7 +31,10 @@ the patch, unless the '--message' flag already specified one.  The
 editor.  The editor to use is taken from the first of the following
 sources of information, and defaults to 'vi':
 
+. the 'GIT_EDITOR' environment variable
 . the 'stgit.editor' GIT configuration variable
+. the 'core.editor' GIT configuration variable
+. the 'VISUAL' environment variable
 . the 'EDITOR' environment variable
 
 The message and other GIT commit attributes can be modified later
@@ -101,13 +104,16 @@ ENVIRONMENT VARIABLES
 	GIT_AUTHOR_DATE
 	GIT_COMMITTER_NAME
 	GIT_COMMITTER_EMAIL
+	GIT_EDITOR
 	EDITOR
+	VISUAL
 
 GIT CONFIGURATION VARIABLES
 ---------------------------
 
 	user.name
 	user.email
+	core.editor
 	stgit.editor
 
 StGIT
diff --git a/stgit/utils.py b/stgit/utils.py
index 2ff1d74..6b1d196 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -174,9 +174,17 @@ def call_editor(filename):
     """Run the editor on the specified filename."""
 
     # the editor
-    editor = config.get('stgit.editor')
+    editor = None
+    if 'GIT_EDITOR' in os.environ:
+        editor = os.environ['GIT_EDITOR']
+    if not editor:
+        editor = config.get('stgit.editor')
+    if not editor:
+        editor = config.get('core.editor')
     if editor:
         pass
+    elif 'VISUAL' in os.environ:
+        editor = os.environ['VISUAL']
     elif 'EDITOR' in os.environ:
         editor = os.environ['EDITOR']
     else:
-- 
1.5.4.rc3


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux