[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 7f5520b330 307/366: Add support for non-propo
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 7f5520b330 307/366: Add support for non-proportional text |
Date: |
Tue, 25 Jan 2022 18:54:50 -0500 (EST) |
branch: externals/transient
commit 7f5520b330d4d23e3241b731cb32f59a33aa251c
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Add support for non-proportional text
Add a new `variable-pitch' prefix slot to enable support.
---
lisp/transient.el | 40 ++++++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index c364c127b9..f80e6afb10 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -604,7 +604,8 @@ If `transient-save-history' is nil, then do nothing."
(transient-suffix :initarg :transient-suffix :initform nil)
(transient-non-suffix :initarg :transient-non-suffix :initform nil)
(incompatible :initarg :incompatible :initform nil)
- (suffix-description :initarg :suffix-description))
+ (suffix-description :initarg :suffix-description)
+ (variable-pitch :initarg :variable-pitch :initform nil))
"Transient prefix command.
Each transient prefix command consists of a command, which is
@@ -2994,11 +2995,17 @@ have a history of their own.")
(push desc rows))
rows))
(oref group suffixes)))
+ (vp (oref transient--prefix variable-pitch))
(rs (apply #'max (mapcar #'length columns)))
(cs (length columns))
- (cw (mapcar (lambda (col) (apply #'max (mapcar #'length col)))
+ (cw (mapcar (lambda (col)
+ (apply #'max
+ (mapcar (if vp #'transient--pixel-width #'length)
+ col)))
columns))
- (cc (transient--seq-reductions-from (apply-partially #'+ 3) cw 0)))
+ (cc (transient--seq-reductions-from
+ (apply-partially #'+ (* 3 (if vp (transient--pixel-width " ")
1)))
+ cw 0)))
(if transient-force-single-column
(dotimes (c cs)
(dotimes (r rs)
@@ -3009,11 +3016,28 @@ have a history of their own.")
(insert ?\n)))
(dotimes (r rs)
(dotimes (c cs)
- (insert (make-string (- (nth c cc) (current-column)) ?\s))
- (when-let ((cell (nth r (nth c columns))))
- (insert cell))
- (when (= c (1- cs))
- (insert ?\n)))))))
+ (if vp
+ (progn
+ (when-let ((cell (nth r (nth c columns))))
+ (insert cell))
+ (if (= c (1- cs))
+ (insert ?\n)
+ (insert (propertize " " 'display
+ `(space :align-to (,(nth (1+ c) cc)))))))
+ (insert (make-string (- (nth c cc) (current-column)) ?\s))
+ (when-let ((cell (nth r (nth c columns))))
+ (insert cell))
+ (when (= c (1- cs))
+ (insert ?\n))))))))
+
+(defun transient--pixel-width (string)
+ (save-window-excursion
+ (with-temp-buffer
+ (insert string)
+ (set-window-dedicated-p nil nil)
+ (set-window-buffer nil (current-buffer))
+ (car (window-text-pixel-size
+ nil (line-beginning-position) (point))))))
(cl-defmethod transient--insert-group ((group transient-subgroups))
(let* ((subgroups (oref group suffixes))
- [elpa] externals/transient a7f6c3c23d 191/366: transient-plist-to-alist: New utility function, (continued)
- [elpa] externals/transient a7f6c3c23d 191/366: transient-plist-to-alist: New utility function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient cb740f5a4e 203/366: transient-lisp-variable: Add new set-value slot, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient afdf1f0050 066/366: Clean echo-area when the timer shows the popup, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient e7a16d2006 076/366: Bring back isearch in transient popups, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 17ad01e0c7 079/366: Don't explicitly require isearch, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 1e090b0cd4 240/366: Fixup changelog, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient d5476e1d9f 266/366: Update changelog, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 45975c24e1 282/366: manual: Update info about `incompatible' slot, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2b1d184c6a 287/366: make: Remove dash dependency, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 62769279a6 298/366: transient--describe-function: Move definition, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 7f5520b330 307/366: Add support for non-proportional text,
Jonas Bernoulli <=
- [elpa] externals/transient 129c2b1685 315/366: make: Set more variables in default.mk, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient abbe17560c 318/366: manual: Move common settings to .orgconfig, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 51c50d8c82 319/366: manual: Use updated support for definition commands, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 2e33f96cf0 326/366: transient--post-command: Cosmetics, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 76b77e01ac 328/366: magit--{pre, post}-command: Add emergency exits, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 41521a5c93 331/366: transient--get-predicate-for: Always return a function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 69f42f9e89 334/366: transient--make-predicate-map: Cosmetics, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 8d8ed1965f 345/366: Hide infix commands from execute-extended-command, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 22e032ae65 343/366: Move obsolete variable declaration, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 804feb3b41 361/366: transient--{push, pop}-keymap: Do nothing if keymap is void, Jonas Bernoulli, 2022/01/25