Commit 1c1d1431 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Move the default editor to a constant.

Two possible future improvements regarding editor selection:

* configure editor through configuration file
* set editor through a flag, e.g. topydo edit -p gedit
parent b514379f
...@@ -28,6 +28,9 @@ from topydo.lib.TodoListBase import InvalidTodoException ...@@ -28,6 +28,9 @@ from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
# the true and only editor
DEFAULT_EDITOR = 'vi'
# Access the base class of the TodoList instance kept inside EditCommand. We # Access the base class of the TodoList instance kept inside EditCommand. We
# cannot use super() inside the class itself # cannot use super() inside the class itself
BASE_TODOLIST = lambda tl: super(TodoList, tl) BASE_TODOLIST = lambda tl: super(TodoList, tl)
...@@ -98,9 +101,9 @@ class EditCommand(MultiCommand, ExpressionCommand): ...@@ -98,9 +101,9 @@ class EditCommand(MultiCommand, ExpressionCommand):
self.printer.add_filter(PrettyPrinterNumbers(self.todolist)) self.printer.add_filter(PrettyPrinterNumbers(self.todolist))
try: try:
editor = os.environ['EDITOR'] or 'vi' editor = os.environ['EDITOR'] or DEFAULT_EDITOR
except(KeyError): except(KeyError):
editor = 'vi' editor = DEFAULT_EDITOR
try: try:
if len(self.args) < 1: if len(self.args) < 1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment