From ff5e0c4de9d8216c2c9173fc52436dca1efbd92e Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Tue, 5 Sep 2023 13:09:26 -0700 Subject: [PATCH] popper.el, README: Release version 0.4.6 popper.el (popper-toggle): Rename `popper-toggle-latest' to `popper-toggle'. README.org: Update mentions of `popper-toggle-latest'. --- README.org | 10 ++++---- popper-echo.el | 67 +++++++++++++++++++++++++------------------------- popper.el | 63 +++++++++++++++++++++++++---------------------- 3 files changed, 72 insertions(+), 68 deletions(-) diff --git a/README.org b/README.org index 3d9d7fb..76b312f 100644 --- a/README.org +++ b/README.org @@ -81,7 +81,7 @@ Turn on =popper-mode=. There are two commands for displaying popups, you can bind them as convenient: -- =popper-toggle-latest=: Show/hide the latest popup. Does more with prefix args. +- =popper-toggle=: Show/hide the latest popup. Does more with prefix args. - =popper-cycle=: Cycle through your popups in sequence. To automatically designate buffers as popups, see the customization section. Additionally, you can kill an open popup buffer with =popper-kill-latest-popup=. @@ -95,7 +95,7 @@ If you want the echo-area hints, turn on =popper-echo-mode=. #+BEGIN_SRC emacs-lisp (use-package popper :ensure t ; or :straight t - :bind (("C-`" . popper-toggle-latest) + :bind (("C-`" . popper-toggle) ("M-`" . popper-cycle) ("C-M-`" . popper-toggle-type)) :init @@ -119,7 +119,7 @@ See the Customization section for details on specifying buffer types as popups. "\\*Async Shell Command\\*" help-mode compilation-mode)) - (global-set-key (kbd "C-`") 'popper-toggle-latest) + (global-set-key (kbd "C-`") 'popper-toggle) (global-set-key (kbd "M-`") 'popper-cycle) (global-set-key (kbd "C-M-`") 'popper-toggle-type) (popper-mode +1) @@ -195,7 +195,7 @@ https://user-images.githubusercontent.com/8607532/135748097-268f5aae-ad42-44fa-9 This section details these (and other) customization options. ** Grouping popups by context -Popper can group popups by "context", so that the popups available for display are limited to those that are relevant to the context in which =popper-toggle-latest= or =popper-cycle= is called. For example, when cycling popups from a project buffer, you may only want to see the popups (REPLs, help buffers and compilation output, say) that were spawned from buffers in that project. This is intended to approximate DWIM behavior, so that the most relevant popup in any context is never more than one command away. +Popper can group popups by "context", so that the popups available for display are limited to those that are relevant to the context in which =popper-toggle= or =popper-cycle= is called. For example, when cycling popups from a project buffer, you may only want to see the popups (REPLs, help buffers and compilation output, say) that were spawned from buffers in that project. This is intended to approximate DWIM behavior, so that the most relevant popup in any context is never more than one command away. Built in contexts include projects as defined in Emacs' built in =project.el= and =projectile=, using =perspective= names (from =persp.el=), as well as the default directory of a buffer. To set this, customize =popper-group-function= or use one of @@ -257,7 +257,7 @@ If you already have rules in place for how various buffers should be displayed, #+end_src ** Suppressing popups -Popper can suppress popups when they are first created. The buffer will be registered in the list of popups but will not show up on your screen. Instead, a message ("Popup suppressed: $buffer-name") will be printed to the echo area. You can then raise it using =popper-toggle-latest= or =popper-cycle= at your convenience. It behaves as a regular popup from that point on: +Popper can suppress popups when they are first created. The buffer will be registered in the list of popups but will not show up on your screen. Instead, a message ("Popup suppressed: $buffer-name") will be printed to the echo area. You can then raise it using =popper-toggle= or =popper-cycle= at your convenience. It behaves as a regular popup from that point on: [[https://user-images.githubusercontent.com/8607532/132929265-37eee976-131f-4631-9bad-73090bf17231.mp4]] # [[file:images/popper-hide-popup.gif]] diff --git a/popper-echo.el b/popper-echo.el index d89016a..0369840 100644 --- a/popper-echo.el +++ b/popper-echo.el @@ -26,8 +26,8 @@ ;;; 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. +;; 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: @@ -93,7 +93,7 @@ NOTE: This feature is experimental." The first element is bound to the currently open popup. Each entry in the list can be a character or a string suitable -for the kbd macro. These keys are available when using +for the kbd macro. These keys are available when using popper-echo-mode. Examples: @@ -126,20 +126,20 @@ off." "Show popup list in the echo area when cycling popups." (let* ((message-log-max nil) (grp-symb (when popper-group-function - (funcall popper-group-function))) + (funcall popper-group-function))) (buried-popups (thread-last (alist-get grp-symb popper-buried-popup-alist nil nil 'equal) - (mapcar #'cdr) - (cl-remove-if-not #'buffer-live-p) - (mapcar #'buffer-name) - (delete-dups))) + (mapcar #'cdr) + (cl-remove-if-not #'buffer-live-p) + (mapcar #'buffer-name) + (delete-dups))) (group (and grp-symb (concat "Group (" (truncate-string-to-width (format "%S" grp-symb) 20 nil nil t) "): "))) (open-popup (buffer-name)) (dispatch-keys-extended (append (cdr popper-echo-dispatch-keys) - (make-list (max 0 (- (length buried-popups) - (1- (length popper-echo-dispatch-keys)))) - nil))) + (make-list (max 0 (- (length buried-popups) + (1- (length popper-echo-dispatch-keys)))) + nil))) (popup-strings (cl-reduce #'concat (cons @@ -181,28 +181,28 @@ off." (make-vector 1 keybind)) ((stringp keybind) (kbd keybind))) - (popper-echo--dispatch-toggle i (cons open-popup - buried-popups))) + (popper-echo--dispatch-toggle i (cons open-popup + buried-popups))) (when popper-echo-dispatch-actions (define-key map - (kbd - (concat "k " (cond - ((characterp keybind) - (char-to-string keybind)) - ((stringp keybind) - keybind)))) - (popper-echo--dispatch-kill i (cons open-popup - buried-popups))) + (kbd + (concat "k " (cond + ((characterp keybind) + (char-to-string keybind)) + ((stringp keybind) + keybind)))) + (popper-echo--dispatch-kill i (cons open-popup + buried-popups))) (define-key map - (kbd - (concat "^ " (cond - ((characterp keybind) - (char-to-string keybind)) - ((stringp keybind) - keybind)))) - (popper-echo--dispatch-raise i (cons open-popup - buried-popups)))) + (kbd + (concat "^ " (cond + ((characterp keybind) + (char-to-string keybind)) + ((stringp keybind) + keybind)))) + (popper-echo--dispatch-raise i (cons open-popup + buried-popups)))) (setq i (1+ i))))))) @@ -245,10 +245,11 @@ quickly." ;;;###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'). + "Toggle 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'." diff --git a/popper.el b/popper.el index e4673cd..c61f822 100644 --- a/popper.el +++ b/popper.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2023 Free Software Foundation, Inc. ;; Author: Karthik Chikmagalur -;; Version: 0.4.5 +;; Version: 0.4.6 ;; Package-Requires: ((emacs "26.1")) ;; Keywords: convenience ;; URL: https://github.com/karthink/popper @@ -39,7 +39,7 @@ ;;;; Commands: ;; `popper-mode': Turn on popup management -;; `popper-toggle-latest': Toggle latest popup +;; `popper-toggle': 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 ;; `popper-kill-latest-popup': Kill latest open popup @@ -291,9 +291,9 @@ This is intended to be used in `display-buffer-alist'." (with-current-buffer buffer (eq popper-popup-status 'user-popup))) ('t (with-current-buffer buffer - (or (memq popper-popup-status '(popup user-popup)) - (unless (eq popper-popup-status 'raised) - (popper-popup-p buffer)))))))) + (or (memq popper-popup-status '(popup user-popup)) + (unless (eq popper-popup-status 'raised) + (popper-popup-p buffer)))))))) (defun popper-group-by-directory () "Return an identifier (default directory) to group popups. @@ -443,10 +443,10 @@ Optional argument GROUP is called with no arguments to select a popup buffer to open." (unless popper-mode (user-error "Popper-mode not active!")) (let* ((identifier (when popper-group-function group)) - (no-popup-msg (format "No buried popups for group %s" - (if (symbolp identifier) - (symbol-name identifier) - identifier)))) + (no-popup-msg (format "No buried popups for group %s" + (if (symbolp identifier) + (symbol-name identifier) + identifier)))) (if (null (alist-get identifier popper-buried-popup-alist nil 'remove 'equal)) (message (if identifier no-popup-msg "No buried popups")) @@ -513,7 +513,7 @@ the screen by `display-buffer' will not all be displayed." (while (alist-get group popper-buried-popup-alist nil nil 'equal) (popper-open-latest group)))) -(defun popper-toggle-latest (&optional arg) +(defun popper-toggle (&optional arg) "Toggle visibility of the last opened popup window. With prefix ARG \\[universal-argument], toggle visibility of the @@ -536,6 +536,9 @@ windows as it can." (popper--open-all) (popper-open-latest group))))) +(define-obsolete-function-alias + 'popper-toggle-latest #'popper-toggle "0.4.6") + (defun popper-cycle (&optional num) "Cycle visibility of popup windows one at a time. @@ -616,8 +619,8 @@ If BUFFER is not specified act on the current buffer instead." (defun popper--suppress-p (buf) "Predicate to check if popup-buffer BUF needs to be suppressed." (or (seq-some (lambda (buf-regexp) - (string-match-p buf-regexp (buffer-name buf))) - popper--suppressed-names) + (string-match-p buf-regexp (buffer-name buf))) + popper--suppressed-names) (member (buffer-local-value 'major-mode buf) popper--suppressed-modes) (seq-some (lambda (pred) (funcall pred buf)) popper--suppressed-predicates))) @@ -647,27 +650,27 @@ This should run after `popper--update-popups' in "Unpack `popper-reference-buffers' to set popper--reference- variables." (cl-labels ((popper--classify-type (elm) (pcase-exhaustive elm - ((pred stringp) 'name) - ((and (pred symbolp) - (guard (or (memq 'derived-mode-parent (symbol-plist elm)) - (memq 'mode-class (symbol-plist elm)) - (string= "-mode" (substring (symbol-name elm) -5))))) - 'mode) - ((pred functionp) 'pred) - ((pred consp) 'cons))) + ((pred stringp) 'name) + ((and (pred symbolp) + (guard (or (memq 'derived-mode-parent (symbol-plist elm)) + (memq 'mode-class (symbol-plist elm)) + (string= "-mode" (substring (symbol-name elm) -5))))) + 'mode) + ((pred functionp) 'pred) + ((pred consp) 'cons))) (popper--insert-type (elm) (pcase-exhaustive (popper--classify-type elm) - ('name (cl-pushnew elm popper--reference-names)) - ('mode (cl-pushnew elm popper--reference-modes)) - ('pred (cl-pushnew elm popper--reference-predicates)) - ('cons (when (eq (cdr elm) 'hide) - (pcase-exhaustive (popper--classify-type (car elm)) - ('name (cl-pushnew (car elm) popper--suppressed-names)) - ('mode (cl-pushnew (car elm) popper--suppressed-modes)) - ('pred (cl-pushnew (car elm) popper--suppressed-predicates)))) - (popper--insert-type (car elm)))))) + ('name (cl-pushnew elm popper--reference-names)) + ('mode (cl-pushnew elm popper--reference-modes)) + ('pred (cl-pushnew elm popper--reference-predicates)) + ('cons (when (eq (cdr elm) 'hide) + (pcase-exhaustive (popper--classify-type (car elm)) + ('name (cl-pushnew (car elm) popper--suppressed-names)) + ('mode (cl-pushnew (car elm) popper--suppressed-modes)) + ('pred (cl-pushnew (car elm) popper--suppressed-predicates)))) + (popper--insert-type (car elm)))))) (dolist (entry popper-reference-buffers nil) - (popper--insert-type entry)))) + (popper--insert-type entry)))) ;;;###autoload (define-minor-mode popper-mode