Fix #115: Support editor args with Buku.

This commit is contained in:
Arun Prakash Jana 2017-02-05 12:28:50 +05:30
parent bb4854126c
commit 74e63357a2
3 changed files with 12 additions and 6 deletions

View File

@ -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

4
buku.1
View File

@ -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

10
buku.py
View File

@ -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)