[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/blist 889389eb89 11/31: new: edit annotations
From: |
ELPA Syncer |
Subject: |
[elpa] externals/blist 889389eb89 11/31: new: edit annotations |
Date: |
Tue, 28 Dec 2021 16:57:31 -0500 (EST) |
branch: externals/blist
commit 889389eb8945a0f75fb993739fde855d0529fbf5
Author: JSDurand <mmemmew@gmail.com>
Commit: JSDurand <mmemmew@gmail.com>
new: edit annotations
* blist.el (blist-edit-annotation-buffer-name): Let the user have a
change to customize the buffer name.
(blist-show-all-annotations): Split on newline only.
(blist-edit-annotation-mode): Major mode for editing annotations.
(blist-send-edit-annotation): Send the edit and re-generate the list
of bookmarks.
(blist-abort-edit-annotation): Kill the buffer and quit the window.
(blist-edit-annotation): Edit the bookmark's annotation.
(blist-mode-map): Bind bookmark-save to more keys.
---
blist.el | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 96 insertions(+), 1 deletion(-)
diff --git a/blist.el b/blist.el
index 0e734a8ef0..112f013c74 100644
--- a/blist.el
+++ b/blist.el
@@ -207,6 +207,13 @@ list; they are simply ignored."
(const :tag "Towards Down" down)
(const :tag "In a new tab" tab))))
+;;;; Edit bookmark annotation buffer name
+
+(defcustom blist-edit-annotation-buffer-name "*Edit Bookmark Annotation*"
+ "The name of the buffer used for editing bookmark annotation."
+ :group 'blist
+ :type 'string)
+
;;; Variables
;;;; Sorter
@@ -443,6 +450,7 @@ used as a `revert-buffer-function'."
(define-key map (vector ?A) #'blist-show-all-annotations)
(define-key map (vector ?e) #'blist-edit-annotation)
(define-key map (vector ?s) #'bookmark-save)
+ (define-key map (vector ?\C-x ?\C-s) #'bookmark-save)
(define-key map (vector ?l) #'blist-load)
(define-key map (vector #x29) #'blist-next-marked)
(define-key map (vector #x28) #'blist-prev-marked)
@@ -890,7 +898,8 @@ window."
(mapconcat
(lambda (str)
(concat (make-string 4 #x20) str))
- (split-string (format "%s" anno))
+ (split-string (format "%s" anno)
+ (string #xa #xd))
(string #xa))
"\n"))
(""))))
@@ -901,6 +910,92 @@ window."
;;;; edit annotations
+;;;;; Edit mode
+
+(define-derived-mode blist-edit-annotation-mode
+ bookmark-edit-annotation-mode "BListea"
+ "The major mode for editing bookmark annotations.
+When editing is done, type \\[blist-send-edit-annotation].
+
+Simply delete the buffer if you want to cancel this edit. Or you
+can type \\[blist-abort-edit-annotation] to kill the buffer and
+quit the window at the same time.
+
+This differs from `bookmark-edit-annotation-mode' only in that it
+will always regenerate the list of bookmarks and go to the list
+of bookmarks after the edit is done, since this mode is not used
+for editing annotation in other situations."
+ :group 'blist)
+
+(let ((map blist-edit-annotation-mode-map))
+ (define-key map (vector 3 3) #'blist-send-edit-annotation)
+ (define-key map (vector 3 11) #'blist-abort-edit-annotation))
+
+;;;;;; Send edit
+
+;;;###autoload
+(defun blist-send-edit-annotation ()
+ "Use buffer contents as annotation for a bookmark.
+Lines beginning with `#' are ignored."
+ (interactive)
+ (cond
+ ((not (derived-mode-p 'blist-edit-annotation-mode))
+ (user-error "Not in blist-edit-annotation-mode")))
+ (goto-char (point-min))
+ (while (not (eobp))
+ (cond
+ ((= (following-char) ?#) (bookmark-kill-line t))
+ ((forward-line 1))))
+ (let ((annotation (buffer-substring-no-properties
+ (point-min) (point-max)))
+ (bookmark-name bookmark-annotation-name))
+ (bookmark-set-annotation bookmark-name annotation)
+ (setq bookmark-alist-modification-count
+ (1+ bookmark-alist-modification-count))
+ (cond ((bookmark-time-to-save-p) (bookmark-save)))
+ (message "Annotation updated for \"%s\"" bookmark-name)
+ (quit-window t)
+ (blist-list-bookmarks)))
+
+;;;;;; Abort edit
+
+;;;###autoload
+(defun blist-abort-edit-annotation ()
+ "Kill the current buffer and quit the window.
+This only does something if the major mode is derived from
+`blist-edit-annotation-mode'."
+ (interactive)
+ (cond
+ ((not (derived-mode-p 'blist-edit-annotation-mode))
+ (user-error "Not in blist-edit-annotation-mode")))
+ (quit-window t))
+
+;;;;; Edit function
+
+;;;###autoload
+(defun blist-edit-annotation (bookmark)
+ "Edit annotation for BOOKMARK.
+If called with \\[universal-argument], prompt for the bookmark to
+edit with completion."
+ (interactive
+ (list
+ (cond
+ (current-prefix-arg
+ (completing-read "Edit bookmark: "
+ (mapcar #'bookmark-name-from-full-record
+ bookmark-alist)
+ nil t))
+ ((ilist-get-index)
+ (nth (ilist-get-index) bookmark-alist))
+ ((user-error "No bookmark to edit")))))
+ (setq bookmark (bookmark-name-from-full-record
+ (bookmark-get-bookmark bookmark t)))
+ (pop-to-buffer
+ (generate-new-buffer blist-edit-annotation-buffer-name))
+ (bookmark-insert-annotation bookmark)
+ (blist-edit-annotation-mode)
+ (setq bookmark-annotation-name bookmark))
+
;;;; load
;;;;; Import
- [elpa] externals/blist 81d5a0fe71 19/31: blist: refine functions to display annotations, (continued)
- [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, 2021/12/28
- [elpa] externals/blist 889389eb89 11/31: new: edit annotations,
ELPA Syncer <=
- [elpa] externals/blist 3970156e79 10/31: add loading functionality, ELPA Syncer, 2021/12/28