[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 7e45a57ec8 030/366: No longer depend on lv to
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 7e45a57ec8 030/366: No longer depend on lv to display the transient buffer |
Date: |
Tue, 25 Jan 2022 18:54:23 -0500 (EST) |
branch: externals/transient
commit 7e45a57ec81185631fe763733f64c99021df2a06
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
No longer depend on lv to display the transient buffer
---
default.mk | 1 -
docs/CHANGELOG | 4 +++
docs/transient.org | 32 ++++++++++++++++++-----
docs/transient.texi | 33 ++++++++++++++++++-----
lisp/transient.el | 75 +++++++++++++++++++++++++++++++++++++++++++++++------
5 files changed, 124 insertions(+), 21 deletions(-)
diff --git a/default.mk b/default.mk
index 82bee06299..2294eb9c34 100644
--- a/default.mk
+++ b/default.mk
@@ -4,7 +4,6 @@ ELS = $(PKG).el
ELCS = $(ELS:.el=.elc)
DEPS = dash
-DEPS += hydra # for lv.el
EMACS ?= emacs
EMACS_ARGS ?=
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index c593c0fd22..32db5f4376 100644
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -1,6 +1,10 @@
# -*- mode: org -*-
* v0.2.0 UNRELEASED
+- The new option ~transient-display-buffer-action~ allows users to
+ specify how a window is selected to display the transient popup
+ buffer. The ~lv~ library is no longer used. #17
+
- The window that was selected before the transient window was shown
is no longer re-selected before calling a suffix that exits the
transient. If a suffix changes the selected window unintentionally,
diff --git a/docs/transient.org b/docs/transient.org
index 85bbfacca4..809c09dfe2 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -8,7 +8,7 @@
#+TEXINFO_DIR_CATEGORY: Emacs
#+TEXINFO_DIR_TITLE: Transient: (transient).
#+TEXINFO_DIR_DESC: Transient Commands
-#+SUBTITLE: for version 0.1.0 (v0.1.0-23-g6467626+1)
+#+SUBTITLE: for version 0.1.0 (v0.1.0-28-g625683c+1)
#+TEXINFO_DEFFN: t
#+OPTIONS: H:4 num:4 toc:2
@@ -37,7 +37,7 @@ Calling a suffix command usually causes the transient to be
exited
but suffix commands can also be configured to not exit the transient.
#+TEXINFO: @noindent
-This manual is for Transient version 0.1.0 (v0.1.0-23-g6467626+1).
+This manual is for Transient version 0.1.0 (v0.1.0-28-g625683c+1).
#+BEGIN_QUOTE
Copyright (C) 2018-2019 Jonas Bernoulli <jonas@bernoul.li>
@@ -502,6 +502,28 @@ as many additional suffixes as you hoped.)
sequence. If a number, behave as for ~nil~ but also show the commands
after that many seconds of inactivity.
+- User Option: transient-display-buffer-action
+
+ This option specifies the action used to display the transient popup
+ buffer. The transient popup buffer is displayed in a window using
+ ~(display-buffer buf transient-display-buffer-action)~.
+
+ The value of this option has the form ~(FUNCTION . ALIST)~, where
+ FUNCTION is a function or a list of functions. Each such function
+ should accept two arguments: a buffer to display and an alist of the
+ same form as ALIST. See [[info:elisp#Choosing Window]].
+
+ The default is ~(display-buffer-in-side-window (side . bottom))~.
+ This displays the window at the bottom of the selected frame.
+ Another useful value is ~(display-buffer-below-selected)~. This is
+ what ~magit-popup~ used by default. For more alternatives see
+ [[info:elisp#Display Action Functions]].
+
+ It may be possible to display the window in another frame, but
+ whether that works in practice depends on the window-manager.
+ If the window manager selects the new window (Emacs frame),
+ then it doesn't work.
+
- User Option: transient-highlight-mismatched-keys
This option controls whether key bindings of infix commands that do
@@ -1746,10 +1768,8 @@ Hydra (see https://github.com/abo-abo/hydra) is another
package that
provides features similar to those of Transient.
Both packages use transient keymaps to make a set of commands
-temporarily available and the ~lv~ library to show these commands in a
-popup buffer, which looks like it is using the echo area (but without
-actually using the echo area). The author of Hydra is also the author
-of ~lv~, which is maintained in the same repository.
+temporarily available and show the available commands in a popup
+buffer.
A Hydra "body" is equivalent to a Transient "prefix" and a Hydra
"head" is equivalent to a Transient "suffix". Hydra has no equivalent
diff --git a/docs/transient.texi b/docs/transient.texi
index 0aa2e2ccbb..befba1b9f1 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -31,7 +31,7 @@ General Public License for more details.
@finalout
@titlepage
@title Transient User and Developer Manual
-@subtitle for version 0.1.0 (v0.1.0-23-g6467626+1)
+@subtitle for version 0.1.0 (v0.1.0-28-g625683c+1)
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
@@ -65,7 +65,7 @@ Calling a suffix command usually causes the transient to be
exited
but suffix commands can also be configured to not exit the transient.
@noindent
-This manual is for Transient version 0.1.0 (v0.1.0-23-g6467626+1).
+This manual is for Transient version 0.1.0 (v0.1.0-28-g625683c+1).
@quotation
Copyright (C) 2018-2019 Jonas Bernoulli <jonas@@bernoul.li>
@@ -659,6 +659,29 @@ sequence. If a number, behave as for @code{nil} but also
show the commands
after that many seconds of inactivity.
@end defopt
+@defopt transient-display-buffer-action
+
+This option specifies the action used to display the transient popup
+buffer. The transient popup buffer is displayed in a window using
+@code{(display-buffer buf transient-display-buffer-action)}.
+
+The value of this option has the form @code{(FUNCTION . ALIST)}, where
+FUNCTION is a function or a list of functions. Each such function
+should accept two arguments: a buffer to display and an alist of the
+same form as ALIST@. See @ref{Choosing Window,,,elisp,}.
+
+The default is @code{(display-buffer-in-side-window (side . bottom))}.
+This displays the window at the bottom of the selected frame.
+Another useful value is @code{(display-buffer-below-selected)}. This is
+what @code{magit-popup} used by default. For more alternatives see
+@ref{Display Action Functions,,,elisp,}.
+
+It may be possible to display the window in another frame, but
+whether that works in practice depends on the window-manager.
+If the window manager selects the new window (Emacs frame),
+then it doesn't work.
+@end defopt
+
@defopt transient-highlight-mismatched-keys
This option controls whether key bindings of infix commands that do
@@ -2110,10 +2133,8 @@ Hydra (see @uref{https://github.com/abo-abo/hydra}) is
another package that
provides features similar to those of Transient.
Both packages use transient keymaps to make a set of commands
-temporarily available and the @code{lv} library to show these commands in a
-popup buffer, which looks like it is using the echo area (but without
-actually using the echo area). The author of Hydra is also the author
-of @code{lv}, which is maintained in the same repository.
+temporarily available and show the available commands in a popup
+buffer.
A Hydra "body" is equivalent to a Transient "prefix" and a Hydra
"head" is equivalent to a Transient "suffix". Hydra has no equivalent
diff --git a/lisp/transient.el b/lisp/transient.el
index 1e176402d3..a4db1422c3 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -4,7 +4,7 @@
;; Author: Jonas Bernoulli <jonas@bernoul.li>
;; Homepage: https://github.com/magit/transient
-;; Package-Requires: ((emacs "25.1") (dash "2.15.0") (lv "0.14.0"))
+;; Package-Requires: ((emacs "25.1") (dash "2.15.0"))
;; Keywords: bindings
;; This file is not part of GNU Emacs.
@@ -51,7 +51,6 @@
(require 'dash)
(require 'eieio)
(require 'format-spec)
-(require 'lv)
(eval-when-compile
(require 'subr-x))
@@ -83,6 +82,35 @@ or when the user explicitly requests it."
(const :tag "on demand" nil)
(number :tag "after delay" 1)))
+(defcustom transient-display-buffer-action
+ '(display-buffer-in-side-window (side . bottom))
+ "The action used to display the transient popup buffer.
+
+The transient popup buffer is displayed in a window using
+
+ \(display-buffer buf transient-display-buffer-action)
+
+The value of this option has the form (FUNCTION . ALIST),
+where FUNCTION is a function or a list of functions. Each such
+function should accept two arguments: a buffer to display and
+an alist of the same form as ALIST. See `display-buffer' for
+details.
+
+The default is (display-buffer-in-side-window (side . bottom)).
+This displays the window at the bottom of the selected frame.
+Another useful value is (display-buffer-below-selected). This
+is what `magit-popup' used by default. For more alternatives
+see info node `(elisp)Display Action Functions'.
+
+It may be possible to display the window in another frame, but
+whether that works in practice depends on the window-manager.
+If the window manager selects the new window (Emacs frame),
+then it doesn't work."
+ :package-version '(transient . "0.2.0")
+ :group 'transient
+ :type '(cons (choice function (repeat :tag "Functions" function))
+ alist))
+
(defcustom transient-show-common-commands nil
"Whether to show common transient suffixes in the popup buffer.
@@ -270,6 +298,13 @@ See info node `(transient)Enabling and Disabling
Suffixes'."
See info node `(transient)Enabling and Disabling Suffixes'."
:group 'transient-faces)
+(defface transient-separator
+ '((((class color) (background light)) :background "grey80")
+ (((class color) (background dark)) :background "grey30"))
+ "Face used to draw line below transient popup window.
+Only the background color is significant."
+ :group 'transient-faces)
+
;;; Persistence
(defun transient--read-file-contents (file)
@@ -921,6 +956,8 @@ variable instead.")
(defvar transient--stack nil)
+(defvar transient--window nil)
+
(defvar transient--debug nil "Whether put debug information into *Messages*.")
(defvar transient--history nil)
@@ -1456,6 +1493,12 @@ EDIT may be non-nil."
(setq transient--layout nil)
(setq transient--suffixes nil))
+(defun transient--delete-window ()
+ (when (window-live-p transient--window)
+ (let ((buf (window-buffer transient--window)))
+ (delete-window transient--window)
+ (kill-buffer buf))))
+
(defun transient--export ()
(setq current-transient-prefix transient--prefix)
(setq current-transient-command (oref transient--prefix command))
@@ -2181,15 +2224,31 @@ have a history of their own.")
(defun transient--show ()
(transient--timer-cancel)
(setq transient--showp t)
- (let ((transient--source-buffer (current-buffer)))
- (with-temp-buffer
+ (let ((transient--source-buffer (current-buffer))
+ (buf (get-buffer-create " *transient*")))
+ (unless (window-live-p transient--window)
+ (setq transient--window
+ (display-buffer buf transient-display-buffer-action)))
+ (with-selected-window transient--window
+ (erase-buffer)
+ (set-window-hscroll transient--window 0)
+ (set-window-dedicated-p transient--window t)
+ (set-window-parameter transient--window 'no-other-window t)
+ (setq window-size-fixed t)
+ (setq mode-line-format nil)
+ (setq cursor-type nil)
+ (setq display-line-numbers nil)
+ (setq show-trailing-whitespace nil)
(transient--insert-groups)
(when (or transient--helpp transient--editp)
(transient--insert-help))
- (delete-trailing-whitespace)
- (let ((lv-force-update t)
- (lv-use-separator t))
- (lv-message "%s" (buffer-string))))))
+ (insert
+ (propertize "__" 'face 'transient-separator 'display '(space :height
(1)))
+ (propertize "\n" 'face 'transient-separator 'line-height t))
+ (let ((window-resize-pixelwise t)
+ (window-size-fixed nil))
+ (fit-window-to-buffer nil nil 1))
+ (goto-char (point-min)))))
(defun transient--insert-groups ()
(let ((groups (cl-mapcan (lambda (group)
- [elpa] externals/transient 1ffd0ba498 071/366: transient--original-buffer: Renamed from transient--source-buffer, (continued)
- [elpa] externals/transient 1ffd0ba498 071/366: transient--original-buffer: Renamed from transient--source-buffer, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 892bc840c0 072/366: transient--original-buffer: Set globally, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient fa3b7574bb 087/366: transient--layout-member: Use appropriate argument order, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 20c231e0ec 089/366: transient--layout-member-1: Refactor, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient cac657a03e 092/366: Support inserting/removing groups and doing it using coordinates, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6236a4fd38 019/366: Bind ESC ESC ESC in all maps, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient e889030b0f 027/366: Quote a parenthesis in a doc-string, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2033ac1ed9 031/366: transient-mode-line-format: New option, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 08b4778890 033/366: Make it trivial to use "q" to quit again, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 9429cb628a 035/366: transient-scroll-down: Fix pasto, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 7e45a57ec8 030/366: No longer depend on lv to display the transient buffer,
Jonas Bernoulli <=
- [elpa] externals/transient 625683c9ea 029/366: transient--pre-exit: Don't reselect original window, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a2dada29c8 034/366: manual: Add a FAQ, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a2222d294c 038/366: transient-base-map: New parent of other shared keymaps, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient b1da0cab5d 040/366: Remove my personal key bindings, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient bbf81297c6 041/366: Prevent infix commands from being added to command-history, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a6295fa7ee 042/366: Declare that prefix and suffix commands are for interactive use only, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2872b4a661 045/366: transient-init-value: Define for transient-prefix, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a47ae9499b 049/366: transient-{set, save}: Support exiting the transient, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 9e30038d2d 051/366: transient-set-level: Limit when it is called, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 544b3bb864 057/366: Support automatically disabling incompatible arguments, Jonas Bernoulli, 2022/01/25