[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/emoji 204e1e9: Copy the version of string-pixel-width from subr-
From: |
Lars Ingebrigtsen |
Subject: |
scratch/emoji 204e1e9: Copy the version of string-pixel-width from subr-x in Emacs 29 |
Date: |
Wed, 27 Oct 2021 09:49:29 -0400 (EDT) |
branch: scratch/emoji
commit 204e1e9808ee7184100a779cdac2c6a739245904
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Copy the version of string-pixel-width from subr-x in Emacs 29
---
lisp/transient.el | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 13dfbf5..3e4d094 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -2943,16 +2943,22 @@ have a history of their own.")
(insert ?\n)))))
(defun transient--pixel-width (string)
+ "Return the width of STRING in pixels."
(with-temp-buffer
(insert string)
- (if (not (get-buffer-window (current-buffer)))
- (save-window-excursion
- ;; Avoid errors if the selected window is a dedicated one,
- ;; and they just want to insert a document into it.
- (set-window-dedicated-p nil nil)
- (set-window-buffer nil (current-buffer))
- (car (window-text-pixel-size nil (line-beginning-position) (point))))
- (car (window-text-pixel-size nil (line-beginning-position) (point))))))
+ (save-window-excursion
+ (let ((dedicated (window-dedicated-p)))
+ ;; Avoid errors if the selected window is a dedicated one,
+ ;; and they just want to insert a document into it.
+ (unwind-protect
+ (progn
+ (when dedicated
+ (set-window-dedicated-p nil nil))
+ (set-window-buffer nil (current-buffer))
+ (car (window-text-pixel-size
+ nil (line-beginning-position) (point))))
+ (when dedicated
+ (set-window-dedicated-p nil dedicated)))))))
(cl-defmethod transient--insert-group ((group transient-columns))
(let* ((columns
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/emoji 204e1e9: Copy the version of string-pixel-width from subr-x in Emacs 29,
Lars Ingebrigtsen <=