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.
This commit is contained in:
parent
aa521576f5
commit
854702488c
@ -32,9 +32,7 @@ def bibentry_from_editor(conf, ui, rp):
|
|||||||
bibstr = templates.add_bib
|
bibstr = templates.add_bib
|
||||||
while again:
|
while again:
|
||||||
try:
|
try:
|
||||||
bibstr = content.editor_input(conf['main']['edit_cmd'],
|
bibstr = ui.editor_input(initial=bibstr, suffix='.bib')
|
||||||
bibstr,
|
|
||||||
suffix='.bib')
|
|
||||||
if bibstr == templates.add_bib:
|
if bibstr == templates.add_bib:
|
||||||
again = ui.input_yn(
|
again = ui.input_yn(
|
||||||
question='Bibfile not edited. Edit again ?',
|
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.:
|
# if using a graphical editor, use the --wait or --block option, i.e.:
|
||||||
# "atom --wait"
|
# "atom --wait"
|
||||||
# "kate --block"
|
# "kate --block"
|
||||||
edit_cmd = string(default=None)
|
edit_cmd = string(default='')
|
||||||
|
|
||||||
|
|
||||||
[formating]
|
[formating]
|
||||||
|
11
pubs/uis.py
11
pubs/uis.py
@ -1,5 +1,6 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import locale
|
import locale
|
||||||
import codecs
|
import codecs
|
||||||
@ -29,6 +30,14 @@ def _get_encoding(conf):
|
|||||||
return conf.get('terminal-encoding', enc or 'utf-8')
|
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():
|
def get_ui():
|
||||||
if _ui is None:
|
if _ui is None:
|
||||||
return PrintUI(config.load_default_conf()) # no editor support. (#FIXME?)
|
return PrintUI(config.load_default_conf()) # no editor support. (#FIXME?)
|
||||||
@ -80,7 +89,7 @@ class InputUI(PrintUI):
|
|||||||
|
|
||||||
def __init__(self, conf):
|
def __init__(self, conf):
|
||||||
super(InputUI, self).__init__(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):
|
def input(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user