[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/blist 81d5a0fe71 19/31: blist: refine functions to disp
From: |
ELPA Syncer |
Subject: |
[elpa] externals/blist 81d5a0fe71 19/31: blist: refine functions to display annotations |
Date: |
Tue, 28 Dec 2021 16:57:39 -0500 (EST) |
branch: externals/blist
commit 81d5a0fe7181d9bc6cc535bebbead534e29b6d85
Author: JSDurand <mmemmew@gmail.com>
Commit: JSDurand <mmemmew@gmail.com>
blist: refine functions to display annotations
* blist.el (blist-show-annotation): Now only ask to choose a bookmark
if the user invokes the command with a universal argument.
(blist-show-all-annotations): If the given list is empty, throw an
error.
---
blist.el | 87 +++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 48 insertions(+), 39 deletions(-)
diff --git a/blist.el b/blist.el
index 4925ec5ead..fc6503af64 100644
--- a/blist.el
+++ b/blist.el
@@ -831,16 +831,16 @@ Otherwise, if point is at a bookmark, relocate that
bookmark."
;;;; show annotations
;;;###autoload
-(defun blist-show-annotation ()
+(defun blist-show-annotation (&optional arg)
"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'
-to choose one."
- (interactive)
+point. If called with \\[universal-argument] and if there is no
+bookmark at point, use `completing-read' to choose one."
+ (interactive "P")
(blist-assert-mode)
(let* ((marked-items
(mapcar
@@ -860,7 +860,8 @@ to choose one."
(nth index bookmark-alist)))
(delq nil (list (cond ((blist-is-annotated-p)
(ilist-get-index)))))))
- ((let ((items (delq
+ (arg
+ (let ((items (delq
nil
(mapcar
(lambda (index)
@@ -875,14 +876,19 @@ to choose one."
(bookmark-name-from-full-record
(nth index bookmark-alist)))))
(blist-all-bookmarks)))))
- (list
- (completing-read
- "Choose a bookmark to show annotation: "
- (lambda (str pred action)
- (if (eq action 'metadata)
- '(metadata (category . bookmark))
- (complete-with-action
- action items str pred))))))))))
+ (cond
+ (items
+ (list
+ (completing-read
+ "Choose a bookmark to show annotation: "
+ (lambda (str pred action)
+ (if (eq action 'metadata)
+ '(metadata (category . bookmark))
+ (complete-with-action
+ action items str pred)))
+ nil t)))
+ ((user-error "No bookmarks to show")))))
+ ((user-error "No bookmarks to show")))))
(blist-show-all-annotations targets)))
;;;; show all annotations
@@ -908,32 +914,35 @@ annotations."
(nth index bookmark-alist)))))
(blist-all-bookmarks)))))
(blist-assert-mode)
- (save-selected-window
- (pop-to-buffer (get-buffer-create "*Bookmark Annotation*"))
- (let ((inhibit-read-only t))
- (erase-buffer)
- (mapc
- (lambda (bookmark)
- ;; make sure we are dealing with records
- (let* ((bookmark (bookmark-get-bookmark bookmark))
- (name (bookmark-name-from-full-record
- bookmark))
- (anno (bookmark-get-annotation bookmark))
- (anno (cond ((and anno (stringp anno)
- (not (string= anno "")))
- (concat
- (mapconcat
- (lambda (str)
- (concat (make-string 4 #x20) str))
- (split-string (format "%s" anno)
- (string #xa #xd))
- (string #xa))
- "\n"))
- (""))))
- (insert (format "%s:\n%s" name anno))))
- targets))
- (goto-char (point-min))
- (special-mode)))
+ (cond
+ ((null targets)
+ (user-error "No annotations to show"))
+ ((save-selected-window
+ (pop-to-buffer (get-buffer-create "*Bookmark Annotation*"))
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (mapc
+ (lambda (bookmark)
+ ;; make sure we are dealing with records
+ (let* ((bookmark (bookmark-get-bookmark bookmark))
+ (name (bookmark-name-from-full-record
+ bookmark))
+ (anno (bookmark-get-annotation bookmark))
+ (anno (cond ((and anno (stringp anno)
+ (not (string= anno "")))
+ (concat
+ (mapconcat
+ (lambda (str)
+ (concat (make-string 4 #x20) str))
+ (split-string (format "%s" anno)
+ (string #xa))
+ (string #xa))
+ "\n"))
+ (""))))
+ (insert (format "%s:\n%s" name anno))))
+ targets))
+ (goto-char (point-min))
+ (special-mode)))))
;;;; edit annotations
- [elpa] externals/blist c868a2d8b3 24/31: * blist.el (blist-all-bookmarks): refactor, (continued)
- [elpa] externals/blist c868a2d8b3 24/31: * blist.el (blist-all-bookmarks): refactor, ELPA Syncer, 2021/12/28
- [elpa] externals/blist eddd17ce4d 14/31: try to fix image, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 4a4d94c09d 20/31: blist.el: QoL refinements, ELPA Syncer, 2021/12/28
- [elpa] externals/blist c2f4bc47d4 25/31: fix previous bugs caused by invisibility, ELPA Syncer, 2021/12/28
- [elpa] externals/blist f1b556af33 12/31: Add README, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 48510bdefa 05/31: preserve the original point in building the list, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 41735b2a03 08/31: Make `blist-list-bookmarks' interactive, ELPA Syncer, 2021/12/28
- [elpa] externals/blist 1bac76696c 09/31: fix a wrong function call, ELPA Syncer, 2021/12/28
- [elpa] externals/blist c5145aea0e 02/31: Fix documentations., ELPA Syncer, 2021/12/28
- [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 <=
- [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, 2021/12/28
- [elpa] externals/blist 889389eb89 11/31: new: edit annotations, ELPA Syncer, 2021/12/28