[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/popper 851d838821 065/102: Extracted popper-echo into a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/popper 851d838821 065/102: Extracted popper-echo into a separate library |
Date: |
Fri, 8 Sep 2023 15:58:54 -0400 (EDT) |
branch: externals/popper
commit 851d83882192ac9599ac5b053614a42d683b3fab
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Extracted popper-echo into a separate library
---
popper-echo.el | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
popper.el | 129 ++-------------------------------
2 files changed, 227 insertions(+), 123 deletions(-)
diff --git a/popper-echo.el b/popper-echo.el
new file mode 100644
index 0000000000..468f9ac763
--- /dev/null
+++ b/popper-echo.el
@@ -0,0 +1,221 @@
+;;; popper-echo.el --- Show a popup list in the echo area when cycling them
-*- lexical-binding: t -*-
+
+;; Copyright (C) 2021 Karthik Chikmagalur
+
+;; Author: Karthik Chikmagalur <karthik.chikmagalur@gmail.com>
+;; Version: 0.45
+;; Package-Requires: ((emacs "26.1"))
+;; Keywords: convenience
+;; URL: https://github.com/karthink/popper
+
+;; This file is NOT part of GNU Emacs.
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; For a full copy of the GNU General Public License
+;; see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Popper-echo is a minor-mode to display a list of popup names in the echo
area
+;; when toggling or cycling popups. These popups can be accessed directly using
+;; dispatch keybinds. See Popper for how to classify a buffer as a popup.
+
+;; COMMANDS:
+
+;; popper-echo-mode : Turn on the echo area display
+
+;; CUSTOMIZATION:
+
+;; `popper-echo-lines': The number of echo area/minibuffer lines to use when
+;; showing a list of popups
+;;
+;; `popper-echo-dispatch-keys': A list of strings or characters representing
the
+;; keybindings to access popups shown in the echo area.
+;;
+;; `popper-echo-dispatch-persist': A boolean to control whether the dispatch
+;; menu stays open after choosing a popup.
+;;
+;; `popper-echo-transform-function': A function to transform the display of
+;; these popups, such as by truncating buffer names, etc.
+
+;;; Code:
+
+(require 'popper)
+
+(defcustom popper-echo-transform-function nil
+ "Function to transform buffer names.
+
+This is called on buffer-names displayed by `popper-echo'.
+
+This function should accept a
+ string (the buffer name) and return a transformed string."
+ :type 'function
+ :group 'popper)
+
+(defcustom popper-echo-lines 1
+ "Number of minibuffer lines used to show popup buffer names by `popper-echo'.
+
+This has no effect when popper-echo-mode is turned off."
+ :type 'integer
+ :group 'popper)
+
+(defcustom popper-echo-dispatch-persist t
+ "Controls whether the `popper-echo' dispatch menu is persistent."
+ :type 'boolean
+ :group 'popper)
+
+(defcustom popper-echo-dispatch-keys '("M-1" "M-2" "M-3" "M-4" "M-5")
+ "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. These keys are available when using
+popper-echo-mode.
+
+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 popper-echo-mode is turned
+off."
+ :type '(group character string)
+ :group 'popper)
+
+(defface popper-echo-area-buried
+ '((t :inherit shadow))
+ "Echo area face for buried popups."
+ :group 'popper)
+
+(defface popper-echo-area
+ '((t :inverse-video t
+ :weight bold))
+ "Echo area face for opened popup."
+ :group 'popper)
+
+(defface popper-echo-dispatch-hint
+ '((t :inherit highlight))
+ "Echo area face for popper dispatch key hints."
+ :group 'popper)
+
+;; Notify in echo area:
+(defun popper-echo ()
+ "Show popup list in the echo area when cycling popups."
+ (let* ((message-log-max nil)
+ (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)
+ (delete-dups)))
+ (open-popup (buffer-name))
+ (dispatch-keys-extended (append popper-echo-dispatch-keys
+ (make-list (max 0 (- (length
buried-popups)
+ (length
popper-echo-dispatch-keys)))
+ nil)))
+ (popup-strings
+ (cl-reduce #'concat
+ (cons
+ (propertize
+ (funcall (or popper-echo-transform-function #'identity)
+ open-popup)
+ 'face 'popper-echo-area)
+ (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-echo-dispatch-hint)
+ (propertize "]" 'face
'popper-echo-area-buried)))
+ (propertize (funcall (or
popper-echo-transform-function
+ #'identity)
+ buf)
+ 'face
'popper-echo-area-buried)))
+ dispatch-keys-extended
+ buried-popups)))))
+ (let* ((max-width (- (* popper-echo-lines (frame-width))
+ (if group (+ 13 (length group)) 11)))
+ (plen (length popup-strings))
+ (space-p (> max-width plen)))
+ (message "%s"
+ (concat
+ (if group (format "Group (%s): " group) "Popups: ")
+ (substring popup-strings 0 (if space-p plen max-width))
+ (unless space-p
+ (propertize "..." 'face 'popper-echo-area-buried)))))
+ (set-transient-map (let ((map (make-sparse-keymap))
+ (i 0))
+ (dolist (keybind popper-echo-dispatch-keys map)
+ (define-key map (cond
+ ((characterp keybind)
+ (make-vector 1 keybind))
+ ((stringp keybind)
+ (kbd keybind)))
+ (popper-echo--dispatch-toggle i buried-popups))
+
+ (define-key map
+ (kbd
+ (concat "k " (cond
+ ((characterp keybind)
+ (char-to-string keybind))
+ ((stringp keybind)
+ keybind))))
+ (popper-echo--dispatch-kill i buried-popups))
+ (setq i (1+ i)))))))
+
+
+(defun popper-echo--dispatch-toggle (i buf-list)
+ "Return a function to switch to buffer I in list BUF-LIST.
+
+This is used to create functions for switching between popups
+quickly."
+ (lambda (&optional arg)
+ (interactive "P")
+ (unless arg (popper-close-latest))
+ (display-buffer (nth i buf-list))
+ (popper--update-popups)
+ (when popper-echo-dispatch-persist (popper-echo))))
+
+(defun popper-echo--dispatch-kill (i buf-list)
+ "Return a function to 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)
+ (when popper-echo-dispatch-persist (popper-echo))))
+
+;;;###autoload
+(define-minor-mode popper-echo-mode
+ "Show popup names in cycling order in the echo area when
+ performing an action that involves showing a popup. These
+ popups can be accessed directly or acted upon by using quick
+ keys (see `popper-echo-dispatch-keys').
+
+To define buffers as popups and customize popup display, see
+`popper-mode'."
+ :global t
+ :lighter ""
+ :group 'popper
+ (if popper-echo-mode
+ (progn
+ (add-hook 'popper-open-popup-hook 'popper-echo)
+ (unless popper-mode (popper-mode 1)))
+ (remove-hook 'popper-open-popup-hook 'popper-echo)))
+
+(provide 'popper-echo)
+;;; popper-echo.el ends here
diff --git a/popper.el b/popper.el
index 68d15c3b4e..08369b44b0 100644
--- a/popper.el
+++ b/popper.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2021 Karthik Chikmagalur
;; Author: Karthik Chikmagalur <karthik.chikmagalur@gmail.com>
-;; Version: 0.30
+;; Version: 0.45
;; Package-Requires: ((emacs "26.1"))
;; Keywords: convenience
;; URL: https://github.com/karthink/popper
@@ -38,6 +38,7 @@
;;
;; COMMANDS:
;;
+;; popper-mode : Turn on popup management
;; popper-toggle-latest : Toggle latest popup
;; popper-cycle : Cycle through all popups, or close all open popups
;; popper-toggle-type : Turn a regular window into a popup or vice-versa
@@ -65,6 +66,10 @@
;; `display-buffer-alist' (or through a package like Shackle), set this
;; variable to nil.
;;
+;; There are other customization options, such as the ability to suppress
+;; certain popups and keep them from showing. Please customize the popper group
+;; for details.
+
;;; Code:
(require 'cl-lib)
@@ -205,29 +210,6 @@ as current."
:type 'hook
:group 'popper)
-(defcustom popper-message-transform-function nil
- "Function to transform buffer names.
-
-This is called on buffer-names displayed by `popper-echo-names'.
-
-This function should accept a
- string (the buffer name) and return a transformed string."
- :type 'function
- :group 'popper)
-
-(defface popper-echo-area
- '((t :inverse-video t
- :weight bold))
- "Echo area face for opened popup.")
-
-(defface popper-echo-area-buried
- '((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.")
@@ -258,19 +240,6 @@ 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.
@@ -675,92 +644,6 @@ If BUFFER is not specified act on the current buffer
instead."
(dolist (entry popper-reference-buffers nil)
(popper--insert-type entry)))
-;; Notify in echo area:
-(defun popper-echo-names ()
- "Show popup list in echo area when cycling popups."
- (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
- (propertize
- (funcall (or popper-message-transform-function
#'identity)
- open-popup)
- 'face 'popper-echo-area)
- (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))
- (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
"Toggle Popper mode. When enabled, treat certain buffer
- [elpa] externals/popper 1a059a5973 009/102: Reduced surface area of package, (continued)
- [elpa] externals/popper 1a059a5973 009/102: Reduced surface area of package, ELPA Syncer, 2023/09/08
- [elpa] externals/popper a27500408c 023/102: Enhancements, see details, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 3584603390 013/102: Setting up project awareness, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 9eb1a8cbd8 006/102: Merge pull request #1 from syohex/fix-minimum-version, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 35e266d984 031/102: Add support for fullscreen popups, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 598571f025 041/102: Started work on buffer-hiding feature, ELPA Syncer, 2023/09/08
- [elpa] externals/popper b120c6836c 042/102: extract window height determining function, ELPA Syncer, 2023/09/08
- [elpa] externals/popper c96915cb77 043/102: Merge commit 'b120c68' into feature, ELPA Syncer, 2023/09/08
- [elpa] externals/popper cd975ac5b8 047/102: Updated README with new features, popups by predicate, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 1312c0f0f6 053/102: Added video demo of buffer hiding, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 851d838821 065/102: Extracted popper-echo into a separate library,
ELPA Syncer <=
- [elpa] externals/popper 7afd502b3b 068/102: Fixed popper-echo display when the group is a symbol, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 667dcdd063 069/102: Added badge, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 4d58a6dbba 076/102: Handle unbound dispatch keys in popper-echo, ELPA Syncer, 2023/09/08
- [elpa] externals/popper d5ab9b2c41 077/102: Popup without selecting (#17), ELPA Syncer, 2023/09/08
- [elpa] externals/popper a93ff38ab6 098/102: popper: Assign copyright to FSF, ELPA Syncer, 2023/09/08
- [elpa] externals/popper fd39948875 024/102: Removed redundant info from documentation, ELPA Syncer, 2023/09/08
- [elpa] externals/popper b32abcba49 030/102: Fixed popup display of newly created popup buffers, ELPA Syncer, 2023/09/08
- [elpa] externals/popper c465e0de24 007/102: Added technical notes to README, ELPA Syncer, 2023/09/08
- [elpa] externals/popper 7f61e916ce 037/102: Child frame support for popper (ongoing), ELPA Syncer, 2023/09/08
- [elpa] externals/popper 767d4ffd0e 039/102: Modified README for clarity, ELPA Syncer, 2023/09/08