[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/workroom 9974fb58a9 41/74: Add new command workroom-bookma
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/workroom 9974fb58a9 41/74: Add new command workroom-bookmark-multiple |
Date: |
Sun, 27 Nov 2022 16:03:28 -0500 (EST) |
branch: elpa/workroom
commit 9974fb58a949eac1e91e7fcb8daec503dd265771
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Add new command workroom-bookmark-multiple
---
README.org | 1 +
workroom.el | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
workroom.texi | 10 +++++++
3 files changed, 97 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index c8a8f54468..0891224858 100644
--- a/README.org
+++ b/README.org
@@ -55,6 +55,7 @@ All the useful commands can be called with following key
sequences:
| ~C-x c c~ | ~workroom-clone~ |
| ~C-x c C~ | ~workroom-clone-view~ |
| ~C-x c m~ | ~workroom-bookmark~ |
+| ~C-x c M~ | ~workroom-bookmark-multiple~ |
| ~C-x c b~ | ~workroom-switch-to-buffer~ |
| ~C-x c a~ | ~workroom-add-buffer~ |
| ~C-x c k~ | ~workroom-kill-buffer~ |
diff --git a/workroom.el b/workroom.el
index d4c7241d4c..e392e3018f 100644
--- a/workroom.el
+++ b/workroom.el
@@ -62,6 +62,7 @@
;; `C-x c c' `workroom-clone'
;; `C-x c C' `workroom-clone-view'
;; `C-x c m' `workroom-bookmark'
+;; `C-x c M' `workroom-bookmark-multiple'
;; `C-x c b' `workroom-switch-to-buffer'
;; `C-x c a' `workroom-add-buffer'
;; `C-x c k' `workroom-kill-buffer'
@@ -196,7 +197,7 @@ The value is a mode line terminal like `mode-line-format'."
(defvar workroom-command-map
(let ((keymap (make-sparse-keymap)))
- ;; NOTE: Be sure to keep commentary and README up to date.
+ ;; NOTE: Be sure to keep the commentary and README up to date.
(define-key keymap (kbd "s") #'workroom-switch)
(define-key keymap (kbd "S") #'workroom-switch-view)
(define-key keymap (kbd "d") #'workroom-kill)
@@ -207,6 +208,7 @@ The value is a mode line terminal like `mode-line-format'."
(define-key keymap (kbd "c") #'workroom-clone)
(define-key keymap (kbd "C") #'workroom-clone-view)
(define-key keymap (kbd "m") #'workroom-bookmark)
+ (define-key keymap (kbd "M") #'workroom-bookmark-multiple)
(define-key keymap (kbd "b") #'workroom-switch-to-buffer)
(define-key keymap (kbd "a") #'workroom-add-buffer)
(define-key keymap (kbd "k") #'workroom-kill-buffer)
@@ -562,6 +564,21 @@ See `workroom--read' for PROMPT, DEF, REQUIRE-MATCH and
PREDICATE."
(if (consp cand) (car cand) cand)))
(or (not predicate) (funcall predicate cand))))))
+(defun workroom--read-multiple ( prompt &optional def require-match
+ predicate)
+ "Read the name of some workrooms and return it as a list of strings.
+
+Prompt with PROMPT, where PROMPT should be a string without trailing
+colon and/or space.
+
+Return DEF when input is empty, where DEF is either a string or nil.
+
+REQUIRE-MATCH and PREDICATE is same as in `completing-read-multiple'."
+ (completing-read-multiple
+ (concat prompt (when def (format " (default %s)" def)) ": ")
+ (mapcar #'workroom-name workroom--rooms) predicate require-match
+ nil 'workroom-room-history def))
+
(defun workroom--read-view ( room prompt &optional def require-match
predicate)
"Read the name of a view of ROOM and return it as a string.
@@ -1580,14 +1597,12 @@ when ROOM was encoded."
(defun workroom-bookmark (room name no-overwrite)
"Save workroom ROOM to a bookmark named NAME.
+ROOM can be a workroom, or a name of a workroom.
+
If NO-OVERWRITE is nil or prefix argument is given, don't overwrite
any previous bookmark with the same name."
(interactive
- (list (workroom--read
- "Bookmark workroom" nil t
- (lambda (cand)
- (not (equal (workroom-name (workroom-get-default))
- (if (consp cand) (car cand) cand)))))
+ (list (workroom--read "Bookmark workroom" nil t)
(workroom--read-bookmark "Save to bookmark: ")
current-prefix-arg))
(workroom--barf-unless-enabled)
@@ -1607,6 +1622,71 @@ any previous bookmark with the same name."
(handler . workroom-bookmark-jump-to-room))
no-overwrite))
+;;;###autoload
+(defun workroom-bookmark-jump-to-room-set (bookmark)
+ "Restore the workroom set in bookmark BOOKMARK."
+ (workroom--barf-unless-enabled)
+ (let ((data (cdr (alist-get 'data (bookmark-get-bookmark-record
+ bookmark)))))
+ (pcase (plist-get data :version)
+ (1
+ (let* ((buffers (cl-delete-if
+ #'null
+ (workroom--decode-buffers
+ (plist-get data :buffers)))))
+ (dolist (wr (plist-get data :rooms))
+ (let ((buffer-list (cl-delete-if
+ #'null
+ (mapcar (lambda (name)
+ (alist-get name buffers))
+ (plist-get wr :buffers)))))
+ (push (workroom--decode-room-1 (plist-get wr :room)
+ buffer-list)
+ workroom--rooms)))))
+ (version
+ (error "Unsuppported bookmark version %i" version))))
+ (set-buffer (window-buffer)))
+
+(defun workroom-bookmark-multiple (rooms name no-overwrite)
+ "Save the workrooms ROOMS to a bookmark named NAME.
+
+If NO-OVERWRITE is nil or prefix argument is given, don't overwrite
+any previous bookmark with the same name."
+ (interactive
+ (list (workroom--read-multiple "Bookmark workrooms" nil t)
+ (workroom--read-bookmark "Save to bookmark: ")
+ current-prefix-arg))
+ (workroom--barf-unless-enabled)
+ (let ((wrs rooms))
+ (while wrs
+ (setf (car wrs)
+ (if (stringp (car wrs))
+ (or (workroom-get (car wrs))
+ (signal 'wrong-type-argument
+ `(workroom-live-p . ,(car wrs))))
+ (car wrs)))
+ (unless (workroom-live-p (car wrs))
+ (signal 'wrong-type-argument `(workroom-live-p . ,(car wrs))))
+ (pop wrs)))
+ (bookmark-store
+ name
+ `((data . (workroom-set
+ :version 1
+ :rooms ,(mapcar
+ (lambda (wr)
+ `( :room ,(workroom--encode-room-1 wr)
+ :buffers ,(mapcar
+ #'buffer-name
+ (workroom-buffer-list wr))))
+ rooms)
+ :buffers ,(workroom--encode-buffers
+ (cl-remove-duplicates
+ (apply #'append
+ (mapcar #'workroom-buffer-list
+ rooms))))))
+ (handler . workroom-bookmark-jump-to-room-set))
+ no-overwrite))
+
;;;; Desktop Integration.
diff --git a/workroom.texi b/workroom.texi
index b35cc4c11d..c97487663b 100644
--- a/workroom.texi
+++ b/workroom.texi
@@ -545,6 +545,16 @@ workroom to bookmark, then you'll prompted for the name of
the
bookmark. Then you can just use the standard bookmark commands to
with the bookmark to restore the bookmark.
+@findex workroom-bookmark-multiple
+@kindex C-x c m
+@kindex m (command map)
+@kindex command map, m
+You can also bookmark multiple workroom together in a single bookmark.
+You can use the command @command{workroom-bookmark-multiple} to
+bookmark several workrooms. It is bound to @kbd{C-x c M} by default.
+It is similar to @command{workroom-bookmark}, but it'll ask you for a
+comma separated workroom list instead.
+
@node Project Integration
@cindex project integration
@cindex integration, project
- [nongnu] elpa/workroom 31eabf2547 21/74: Add some comments for explaining the code, (continued)
- [nongnu] elpa/workroom 31eabf2547 21/74: Add some comments for explaining the code, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 64b465093e 20/74: Make line no more wide than 75 characters, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 6d159a5566 24/74: Use `string=' to compare workroom and view names, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom a4845ad57f 44/74: Don't switch room in workroom-switch if ROOM is current, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 4c4fd7830c 34/74: Add Winner integration, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom e7dc14236e 42/74: Fix out of sync documentation, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 3144324e33 39/74: Add an user manual, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 40acb8c7b8 45/74: O(n) switch-to-buffer instead of O(n^2) in project workrooms, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 13e648f3db 74/74: Add .dir-locals.el, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom add6fb080d 61/74: Bump version to 2.1.1, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 9974fb58a9 41/74: Add new command workroom-bookmark-multiple,
ELPA Syncer <=
- [nongnu] elpa/workroom a87110f435 56/74: Clone views correctly, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom f9d88f211c 68/74: Bump version to 2.2.2, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom eef13afbbf 66/74: Bump version to 2.2.1, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 1d4c134d60 26/74: Add new command workroom-switch-room, some refactoring, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 497c04d666 15/74: Make lighter customizable, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom b28aae7a13 40/74: Add chapter "Project Integration" to manual, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 98d1158ef0 36/74: Fix key binding of "C-d" in command map, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 8e805c716e 51/74: Bump version to 2.0.2, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom 64da63c1a9 67/74: Add Compat dependency, ELPA Syncer, 2022/11/27
- [nongnu] elpa/workroom bb74cce814 60/74: Fix error when a frame is killed, ELPA Syncer, 2022/11/27