Skip to content

Commit

Permalink
transient--maybe-pad-keys: Delay actually padding
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Oct 24, 2023
1 parent ae4ac65 commit ae5aba3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -3550,6 +3550,8 @@ Optional support for popup buttons is also implemented here."
"Format OBJ's `key' for display and return the result."
(let ((key (oref obj key))
(cmd (oref obj command)))
(when-let ((width (oref transient--pending-group pad-keys)))
(setq key (truncate-string-to-width key width nil ?\s)))
(if transient--redisplay-key
(let ((len (length transient--redisplay-key))
(seq (cl-coerce (edmacro-parse-keys key t) 'list)))
Expand Down Expand Up @@ -3706,16 +3708,13 @@ If the OBJ's `key' is currently unreachable, then apply the face
(defun transient--maybe-pad-keys (group &optional parent)
(when-let ((pad (or (oref group pad-keys)
(and parent (oref parent pad-keys)))))
(let ((width (apply #'max
(cons (if (integerp pad) pad 0)
(seq-keep (lambda (suffix)
(and (not (stringp suffix))
(length (oref suffix key))))
(oref group suffixes))))))
(dolist (suffix (oref group suffixes))
(unless (stringp suffix)
(oset suffix key
(truncate-string-to-width (oref suffix key) width nil ?\s)))))))
(oset group pad-keys
(apply #'max (cons (if (integerp pad) pad 0)
(seq-keep (lambda (suffix)
(and (eieio-object-p suffix)
(slot-boundp suffix 'key)
(length (oref suffix key))))
(oref group suffixes)))))))

(defun transient--pixel-width (string)
(save-window-excursion
Expand Down

0 comments on commit ae5aba3

Please sign in to comment.