From 74e63357a285c0c36be69f2d7145e2eb81743f6e Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 5 Feb 2017 12:28:50 +0530 Subject: [PATCH] Fix #115: Support editor args with Buku. --- README.md | 4 ++-- buku.1 | 4 ++-- buku.py | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d923074..5eccc60 100644 --- a/README.md +++ b/README.md @@ -376,8 +376,8 @@ Note that URL must precede tags. 4. Edit a bookmark in **editor and add**: $ buku -w - $ buku -w vim -a https://ddg.gg search engine, privacy -The second command will open vim with the URL and tags populated. + $ buku -w 'macvim -f' -a https://ddg.gg search engine, privacy +The second command will open macvim with option -f and the URL and tags populated. 5. **Update** existing bookmark at index 15012014 with new URL, tags and comments, fetch title from the web: $ buku -u 15012014 --url http://ddg.gg/ --tag web search, utilities -c Alternative search engine diff --git a/buku.1 b/buku.1 index 37e62ce..19a7ab0 100644 --- a/buku.1 +++ b/buku.1 @@ -320,11 +320,11 @@ Edit a bookmark in \fBeditor and add\R: .EX .IP .B buku -w -.B buku -w vim -a https://ddg.gg search engine, privacy +.B buku -w 'macvim -f' -a https://ddg.gg search engine, privacy .EE .PP .IP "" 4 -The second command will open vim with the URL and tags populated. +The second command will open macvim with option -f and the URL and tags populated. .IP 5. 4 \fBUpdate\fR existing bookmark at index 15012014 with new URL, tags and comments, fetch title from the web: .PP diff --git a/buku.py b/buku.py index 3296412..240f6a6 100755 --- a/buku.py +++ b/buku.py @@ -2302,14 +2302,20 @@ def edit_rec(editor, url, title_in, tags_in, desc): fp.flush() logdbg('Edited content written to %s', tmpfile) - subprocess.call([editor, tmpfile]) + cmd = editor.split(' ') + cmd.append(tmpfile) + subprocess.call(cmd) with open(tmpfile, 'r', encoding='utf-8') as f: content = f.read() os.remove(tmpfile) except FileNotFoundError: - logerr('Error opening editor or tempfile') + if os.path.exists(tmpfile): + os.remove(tmpfile) + logerr('Cannot open editor') + else: + logerr('Cannot open tempfile') return None parsed_content = parse_temp_file_content(content)