[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/popper 9a6af01f00 064/102: Dispatch keymap added to pop
From: |
ELPA Syncer |
Subject: |
[elpa] externals/popper 9a6af01f00 064/102: Dispatch keymap added to popper-echo-names |
Date: |
Fri, 8 Sep 2023 15:58:54 -0400 (EDT) |
branch: externals/popper
commit 9a6af01f00c54ce98047e09d9b0c14bb7120c3ab
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Dispatch keymap added to popper-echo-names
Customize popper-dispatch-keys to configure.
You can also kill popups by prepending the dispatch key with k.
---
popper.el | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 84 insertions(+), 8 deletions(-)
diff --git a/popper.el b/popper.el
index 70570f0379..68d15c3b4e 100644
--- a/popper.el
+++ b/popper.el
@@ -224,6 +224,10 @@ This function should accept a
'((t :inherit shadow))
"Echo area face for buried popups.")
+(defface popper-dispatch-hint
+ '((t :inherit highlight))
+ "Echo area face for popper dispatch key hints.")
+
(defvar popper--reference-names nil
"List of buffer names whose windows are treated as popups.")
@@ -254,6 +258,19 @@ should be considered a popup")
If `popper-group-function' is non-nil, these are
grouped by the predicate `popper-group-function'.")
+(defvar popper-dispatch-keys nil
+ "List of keys used for dispatching to popup buffers.
+
+Each entry in the list can be a character or a string suitable
+for the kbd macro.
+
+Examples:
+'(?q ?w ?e ?r ?t ?y ?u ?i ?o ?p)
+'(\"M-1\" \"M-2\" \"M-3\" \"M-4\" \"M-5\")
+
+This variable has no effect when echo-area display of
+popups (using popper-echo-names) is turned off.")
+
(defvar-local popper-popup-status nil
"Identifies a buffer as a popup by its buffer-local value.
Valid values are 'popup, 'raised, 'user-popup or nil.
@@ -661,13 +678,18 @@ If BUFFER is not specified act on the current buffer
instead."
;; Notify in echo area:
(defun popper-echo-names ()
"Show popup list in echo area when cycling popups."
- (let* ((group (when popper-group-function
+ (let* ((message-log-max nil) ;No logging of these messages
+ (group (when popper-group-function
(funcall popper-group-function)))
(buried-popups (thread-last (alist-get group
popper-buried-popup-alist nil nil 'equal)
(mapcar #'cdr)
(cl-remove-if-not #'buffer-live-p)
(mapcar #'buffer-name)))
(open-popup (buffer-name))
+ (dispatch-keys-extended (append popper-dispatch-keys
+ (make-list (max 0 (- (length
buried-popups)
+ (length
popper-dispatch-keys)))
+ nil)))
(popup-strings
(cl-reduce #'concat
(cons
@@ -675,15 +697,69 @@ If BUFFER is not specified act on the current buffer
instead."
(funcall (or popper-message-transform-function
#'identity)
open-popup)
'face 'popper-echo-area)
- (mapcar (lambda (b) (propertize
- (concat ", " (funcall (or
popper-message-transform-function
- #'identity)
- b))
- 'face 'popper-echo-area-buried))
- buried-popups)))))
+ (cl-mapcar (lambda (key buf)
+ (concat
+ (propertize ", " 'face
'popper-echo-area-buried)
+ (when key
+ (concat
+ (propertize "[" 'face
'popper-echo-area-buried)
+ (propertize (if (characterp key)
+ (char-to-string key)
+ key)
+ 'face 'popper-dispatch-hint)
+ (propertize "]" 'face
'popper-echo-area-buried)))
+ (propertize (funcall (or
popper-message-transform-function
+ #'identity)
+ buf)
+ 'face
'popper-echo-area-buried)))
+ dispatch-keys-extended
+ buried-popups)))))
(if group
(message "Group (%s): %s" group popup-strings)
- (message "Popups: %s" popup-strings))))
+ (message "Popups: %s" popup-strings))
+ (set-transient-map (let ((map (make-sparse-keymap))
+ (i 0))
+ (dolist (keybind popper-dispatch-keys map)
+ (define-key map (cond
+ ((characterp keybind)
+ (make-vector 1 keybind))
+ ((stringp keybind)
+ (kbd keybind)))
+ (popper--dispatch-toggle i buried-popups))
+
+ (define-key map
+ (kbd
+ (concat "k " (cond
+ ((characterp keybind)
+ (char-to-string keybind))
+ ((stringp keybind)
+ keybind))))
+ (popper--dispatch-kill i buried-popups))
+ (setq i (1+ i))))
+ t)))
+
+(defun popper--dispatch-toggle (i buf-list)
+ "Returns a function to switch to buffer I in list BUF-LIST.
+
+This is used to create functions for switching between popups
+quickly."
+ (lambda ()
+ (interactive)
+ (popper-close-latest)
+ (display-buffer (nth i buf-list))
+ (popper--update-popups)
+ (popper-echo-names)))
+
+(defun popper--dispatch-kill (i buf-list)
+ "Kill buffer I in list BUF-LIST."
+ (lambda ()
+ (interactive)
+ (let* ((buf (nth i buf-list))
+ (win (get-buffer-window buf)))
+ (kill-buffer buf)
+ (popper--delete-popup win))
+ (popper--update-popups)
+ (popper-echo-names)))
;;;###autoload
(define-minor-mode popper-mode
- [elpa] externals/popper a85a343c99 027/102: Merge branch 'popup-groups', (continued)
- [elpa] externals/popper a85a343c99 027/102: Merge branch 'popup-groups', ELPA Syncer, 2023/09/08
- [elpa] externals/popper 31dc52c313 036/102: Prettifying README, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 89ed8ab2da 038/102: Documentation update + kill-latest-popup kills frames now, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 268ac30047 046/102: More comprehensive delete-popup function + see, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 4c51182f5f 051/102: Fix error in `popper-group-by-project` (#10), ELPA Syncer, 2023/09/08
- [elpa] externals/popper 8dd55742d8 054/102: Updated Readme for readability + handle project-current when nil, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 8bd65b4267 057/102: Changed popup-delete functionality to use quit-window, ELPA Syncer, 2023/09/08
- [elpa] externals/popper a604447f65 058/102: Merge branch 'feature': Add popup hiding, ELPA Syncer, 2023/09/08
- [elpa] externals/popper cc7336c4e3 060/102: Checkdoc fixes, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 8c50bb3254 062/102: Added TODO in delete-popup for later, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 9a6af01f00 064/102: Dispatch keymap added to popper-echo-names,
ELPA Syncer <=
- [elpa] externals/popper 918306c2af 066/102: Updated README with popper-echo demo and new vids, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 8592573f33 070/102: Fixed popper-echo display when groups are symbols, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 7b02960025 082/102: Revert "Fix pcase clause for native-comp", ELPA Syncer, 2023/09/08
- [elpa] externals/popper 60297066e3 085/102: pcase 'otherwise' clause should be _ not 'T (#28), ELPA Syncer, 2023/09/08
- [elpa] externals/popper 6599c9b5a1 086/102: eliminate all warnings generated during byte-compilation (#33), ELPA Syncer, 2023/09/08
- [elpa] externals/popper 7ea13618c8 087/102: Remove needless quote (#37), ELPA Syncer, 2023/09/08
- [elpa] externals/popper d7560f1835 089/102: Fix for #35: alist argument ignored by default popper display func, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 47bf592c89 081/102: Fix pcase clause for native-comp, ELPA Syncer, 2023/09/08
- [elpa] externals/popper da70c8296a 092/102: popper-echo.el: Tweak popper echo display format, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 76b1a1f1bc 094/102: popper-echo: Tweak popper group display, ELPA Syncer, 2023/09/08