Prefer VISUAL to EDITOR

Fix #2096
This commit is contained in:
toonn
2019-10-25 18:52:17 +02:00
parent 6634dc81fe
commit a64a0d64cb
3 changed files with 21 additions and 24 deletions
+6 -9
View File
@@ -415,15 +415,12 @@ def get_editor():
ans = getattr(get_editor, 'ans', False)
if ans is False:
import shlex
ans = os.environ.get('EDITOR')
if not ans or not exe_exists(shlex.split(ans)[0]):
for q in ('vim', 'nvim', 'vi', 'emacs', 'kak', 'micro', 'nano', 'vis'):
r = exe_exists(q)
if r:
ans = r
break
else:
ans = 'vim'
for ans in (os.environ.get('VISUAL'), os.environ.get('EDITOR'), 'vim',
'nvim', 'vi', 'emacs', 'kak', 'micro', 'nano', 'vis'):
if ans and exe_exists(shlex.split(ans)[0]):
break
else:
ans = 'vim'
ans = shlex.split(ans)
get_editor.ans = ans
return ans