Fixes #46: editor command behaviors with the new config.

- Fix the previous default to 'None' (the string 'None', not None)
in the config.
- Adds support for using the $EDITOR when none is defined in the condif.
- Use ui.editor instead of content.editor in the add commnand.
main
Olivier Mangin 9 years ago
parent aa521576f5
commit 854702488c

@ -32,9 +32,7 @@ def bibentry_from_editor(conf, ui, rp):
bibstr = templates.add_bib
while again:
try:
bibstr = content.editor_input(conf['main']['edit_cmd'],
bibstr,
suffix='.bib')
bibstr = ui.editor_input(initial=bibstr, suffix='.bib')
if bibstr == templates.add_bib:
again = ui.input_yn(
question='Bibfile not edited. Edit again ?',

@ -20,7 +20,7 @@ open_cmd = string(default=None)
# if using a graphical editor, use the --wait or --block option, i.e.:
# "atom --wait"
# "kate --block"
edit_cmd = string(default=None)
edit_cmd = string(default='')
[formating]

@ -1,5 +1,6 @@
from __future__ import print_function
import os
import sys
import locale
import codecs
@ -29,6 +30,14 @@ def _get_encoding(conf):
return conf.get('terminal-encoding', enc or 'utf-8')
def _get_local_editor():
"""Get the editor from environment variables.
Use vi as a default.
"""
return os.environ.get('EDITOR', 'vi')
def get_ui():
if _ui is None:
return PrintUI(config.load_default_conf()) # no editor support. (#FIXME?)
@ -80,7 +89,7 @@ class InputUI(PrintUI):
def __init__(self, conf):
super(InputUI, self).__init__(conf)
self.editor = conf['main']['edit_cmd']
self.editor = conf['main']['edit_cmd'] or _get_local_editor()
def input(self):
try:

Loading…
Cancel
Save