From 6219c38d9c2bd6a8eeaf320ed0f1fa4bdf1b1fba Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Mon, 16 Jul 2007 13:33:06 -0400 Subject: [PATCH] Add support for VISUAL --- .../508ea95e-7bc6-4b9b-9e36-a3a87014423d/values | 2 +- becommands/comment.py | 3 ++- libbe/utility.py | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.be/bugs/508ea95e-7bc6-4b9b-9e36-a3a87014423d/values b/.be/bugs/508ea95e-7bc6-4b9b-9e36-a3a87014423d/values index a45d40e..f530d63 100644 --- a/.be/bugs/508ea95e-7bc6-4b9b-9e36-a3a87014423d/values +++ b/.be/bugs/508ea95e-7bc6-4b9b-9e36-a3a87014423d/values @@ -15,7 +15,7 @@ severity=minor -status=open +status=closed diff --git a/becommands/comment.py b/becommands/comment.py index 5f7128d..b211cf6 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -33,7 +33,8 @@ def execute(args): True >>> comment.in_reply_to is None True - >>> del os.environ["EDITOR"] + >>> if 'EDITOR' in os.environ: + ... del os.environ["EDITOR"] >>> execute(["b"]) Traceback (most recent call last): UserError: No comment supplied, and EDITOR not specified. diff --git a/libbe/utility.py b/libbe/utility.py index a8c3e24..1fd83da 100644 --- a/libbe/utility.py +++ b/libbe/utility.py @@ -104,16 +104,27 @@ def editor_string(comment=None): >>> if "EDITOR" in os.environ: ... del os.environ["EDITOR"] + >>> if "VISUAL" in os.environ: + ... del os.environ["VISUAL"] >>> editor_string() Traceback (most recent call last): CantFindEditor: Can't find editor to get string from >>> os.environ["EDITOR"] = "echo bar > " >>> editor_string() 'bar\\n' + >>> os.environ["VISUAL"] = "echo baz > " + >>> editor_string() + 'baz\\n' + >>> del os.environ["EDITOR"] + >>> del os.environ["VISUAL"] """ - try: - editor = os.environ["EDITOR"] - except KeyError: + for name in ('VISUAL', 'EDITOR'): + try: + editor = os.environ[name] + break + except KeyError: + pass + else: raise CantFindEditor() fhandle, fname = tempfile.mkstemp() try: -- 2.26.2