Edit last record in EDITOR (option -w) if id=-1.

This is a convenience feature. If the user is using a keyboard shortcut to add
a selected link as bookmark from the DE, he may want to edit it shortly. The -1
index enables him to open the last bookmark added without using option `-p -1`.
This commit is contained in:
Arun Prakash Jana 2017-10-09 01:21:13 +05:30
parent df5bdc1921
commit f72f8af3d8
No known key found for this signature in database
GPG Key ID: A75979F35C080412
3 changed files with 13 additions and 3 deletions

View File

@ -160,7 +160,8 @@ GENERAL OPTIONS:
- otherwise refresh all titles
-w, --write [editor|index]
open editor to edit a fresh bookmark
to update by index, EDITOR must be set
edit last bookmark, if index=-1
to specify index, EDITOR must be set
-d, --delete [...] remove bookmarks from DB
accepts indices or a single range
if no arguments:

2
buku.1
View File

@ -105,7 +105,7 @@ Edit a bookmark in
.I editor
before adding it. To edit and update an existing bookmark, the
.I index
should be passed. However, in this case the environment variable EDITOR must be set.
should be passed. However, in this case the environment variable EDITOR must be set. The last record is opened in EDITOR if index=-1.
.TP
.BI \-d " " \--delete " [...]"
Delete bookmarks. Accepts space-separated list of indices (e.g. 5 6 23 4 110 45) or a single hyphenated range (e.g. 100-200). Note that range and list don't work together. Deletes search results when combined with search options, if no arguments.

11
buku.py
View File

@ -1160,6 +1160,7 @@ class BukuDb:
----------
index : int
DB index of the record.
Last record, if index is -1.
immutable : int, optional
Diable title fetch from web if 1. Default is -1.
@ -1174,6 +1175,13 @@ class BukuDb:
logerr('EDITOR must be set to use index with -w')
return False
if (index == -1):
# Edit the last records
index = self.get_max_id()
if index == -1:
logerr('Empty database')
return False
rec = self.get_rec_by_id(index)
if not rec:
logerr('No matching index %d', index)
@ -3846,7 +3854,8 @@ POSITIONAL ARGUMENTS:
- otherwise refresh all titles
-w, --write [editor|index]
open editor to edit a fresh bookmark
to update by index, EDITOR must be set
edit last bookmark, if index=-1
to specify index, EDITOR must be set
-d, --delete [...] remove bookmarks from DB
accepts indices or a single range
if no arguments: