diff --git a/README.md b/README.md index d7a4da5..363295c 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/buku.1 b/buku.1 index a6117e5..a3dd98e 100644 --- a/buku.1 +++ b/buku.1 @@ -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. diff --git a/buku.py b/buku.py index eebb6d4..5dab119 100755 --- a/buku.py +++ b/buku.py @@ -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: