From e13e7ed727fb5cf50e2b10d98e2a9b937e5153ab Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 4 Jan 2015 17:46:08 -0800 Subject: [PATCH] config -e: Parse arguments in $EDITOR (fix #1200) --- beets/ui/commands.py | 8 +++++++- docs/changelog.rst | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index c0fb699e9..4dfac11c8 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -23,6 +23,7 @@ import time import codecs import platform import re +import shlex import beets from beets import ui @@ -1503,7 +1504,12 @@ def config_edit(): if 'EDITOR' in os.environ: editor = os.environ['EDITOR'] - args = [editor, editor, path] + try: + editor = shlex.split(editor) + except ValueError: # Malformed shell tokens. + editor = [editor] + args = editor + [path] + args.insert(1, args[0]) elif platform.system() == 'Darwin': args = ['open', 'open', '-n', path] elif platform.system() == 'Windows': diff --git a/docs/changelog.rst b/docs/changelog.rst index 0446300cc..e9b6123ed 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -68,6 +68,8 @@ Fixed: twice in the artist string. Thanks to Marc Addeo. :bug:`1179` :bug:`1181` * :doc:`/plugins/lastgenre`: Match songs more robustly when they contain dashes. Thanks to :user:`djl`. :bug:`1156` +* The :ref:`config-cmd` command can now use ``$EDITOR`` variables with + arguments. .. _API changes: http://developer.echonest.com/forums/thread/3650 .. _Plex: https://plex.tv/