[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/blist 2aa25e2dcc 16/31: blist: deal with empty annotati
From: |
ELPA Syncer |
Subject: |
[elpa] externals/blist 2aa25e2dcc 16/31: blist: deal with empty annotations |
Date: |
Tue, 28 Dec 2021 16:57:37 -0500 (EST) |
branch: externals/blist
commit 2aa25e2dcc6f5352bf55f775b6be82eb8190aab8
Author: JSDurand <mmemmew@gmail.com>
Commit: JSDurand <mmemmew@gmail.com>
blist: deal with empty annotations
* blist.el (blist-show-annotation, blist-show-all-annotations): Only
show non-empty annotations.
(blist-send-edit-annotation): If the buffer is empty, set the
annotation to nil instead of an empty string.
(blist-is-annotated-p): Determine whether the point is at a bookmark
with non-empty annotations.
---
blist.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 54 insertions(+), 13 deletions(-)
diff --git a/blist.el b/blist.el
index 112f013c74..6fc2baa6a9 100644
--- a/blist.el
+++ b/blist.el
@@ -833,6 +833,9 @@ Otherwise, if point is at a bookmark, relocate that
bookmark."
;;;###autoload
(defun blist-show-annotation ()
"Show the annotation of the bookmark(s) in another window.
+Only the annotations of bookmarks with annotations will be shown.
+So empty annotations are ignored.
+
If there are marked bookmarks, show the annotations of the marked
bookmarks; otherwise show the annotations of the bookmark at
point. If there is no bookmark at point, use `completing-read'
@@ -845,7 +848,9 @@ to choose one."
(bookmark-name-from-full-record
(nth index bookmark-alist)))
(ilist-map-lines
- #'ilist-get-index #'ilist-is-marked)))
+ #'ilist-get-index
+ (lambda ()
+ (and (ilist-is-marked) (blist-is-annotated-p))))))
(targets
(cond
(marked-items)
@@ -853,12 +858,23 @@ to choose one."
(lambda (index)
(bookmark-name-from-full-record
(nth index bookmark-alist)))
- (delq nil (list (ilist-get-index)))))
- ((let ((items (mapcar
- (lambda (index)
- (bookmark-name-from-full-record
- (nth index bookmark-alist)))
- (blist-all-bookmarks))))
+ (delq nil (list (cond ((blist-is-annotated-p)
+ (ilist-get-index)))))))
+ ((let ((items (delq
+ nil
+ (mapcar
+ (lambda (index)
+ (cond
+ ((let* ((bookmark
+ (nth index bookmark-alist))
+ (annotation
+ (bookmark-get-annotation
+ bookmark)))
+ (and (stringp annotation)
+ (not (string= annotation ""))))
+ (bookmark-name-from-full-record
+ (nth index bookmark-alist)))))
+ (blist-all-bookmarks)))))
(list
(completing-read
"Choose a bookmark to show annotation: "
@@ -874,12 +890,23 @@ to choose one."
;;;###autoload
(defun blist-show-all-annotations (targets)
"Show the annotation of all bookmarks of TARGETS in another \
-window."
- (interactive (list (mapcar
- (lambda (index)
- (bookmark-name-from-full-record
- (nth index bookmark-alist)))
- (blist-all-bookmarks))))
+window.
+
+If called interactively, show all annotations of bookmarks with
+annotations."
+ (interactive
+ (list
+ (delq
+ nil
+ (mapcar
+ (lambda (index)
+ (cond
+ ((let* ((bookmark (nth index bookmark-alist))
+ (annotation (bookmark-get-annotation bookmark)))
+ (and (stringp annotation) (not (string= annotation ""))))
+ (bookmark-name-from-full-record
+ (nth index bookmark-alist)))))
+ (blist-all-bookmarks)))))
(blist-assert-mode)
(save-selected-window
(pop-to-buffer (get-buffer-create "*Bookmark Annotation*"))
@@ -949,6 +976,8 @@ Lines beginning with `#' are ignored."
(let ((annotation (buffer-substring-no-properties
(point-min) (point-max)))
(bookmark-name bookmark-annotation-name))
+ ;; an empty annotation is nihil
+ (cond ((string= annotation "") (setq annotation nil)))
(bookmark-set-annotation bookmark-name annotation)
(setq bookmark-alist-modification-count
(1+ bookmark-alist-modification-count))
@@ -970,6 +999,18 @@ This only does something if the major mode is derived from
(user-error "Not in blist-edit-annotation-mode")))
(quit-window t))
+;;;;; Is it annotated?
+
+(defun blist-is-annotated-p ()
+ "Return non-nil if the bookmark at point has non-empty annotations."
+ (let* ((index (ilist-get-index))
+ (bookmark (cond (index (nth index bookmark-alist))))
+ annotation)
+ (and bookmark
+ (setq annotation (bookmark-get-annotation bookmark))
+ (stringp annotation)
+ (not (string= annotation "")))))
+
;;;;; Edit function
;;;###autoload
- [elpa] externals/blist 0f0ceddf53 26/31: Refine the ChangeLog., (continued)
- [elpa] externals/blist 0f0ceddf53 26/31: Refine the ChangeLog., ELPA Syncer, 2021/12/28
- [elpa] externals/blist 81d5a0fe71 19/31: blist: refine functions to display annotations, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 65ff602eee 30/31: blist: Add a variable to choose features, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 5fd8b00d72 22/31: implement hiding groups by buffer-invisibility-spec, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 6f484744e7 23/31: * ChangeLog: Now this repository has a ChangeLog file., ELPA Syncer, 2021/12/28
- [elpa] externals/blist d0072ea8e8 21/31: * blist.el (blist-open): Use the name of bookmark instead., ELPA Syncer, 2021/12/28
- [elpa] externals/blist 3c2bf28ad8 15/31: update README, ELPA Syncer, 2021/12/28
- [elpa] externals/blist e7d56657eb 31/31: blist: add key indices, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 8956fae651 29/31: Update docs, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 5192131cdb 17/31: Add Info and PDF manuals, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 2aa25e2dcc 16/31: blist: deal with empty annotations,
ELPA Syncer <=
- [elpa] externals/blist 889389eb89 11/31: new: edit annotations, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 3970156e79 10/31: add loading functionality, ELPA Syncer, 2021/12/28