summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/subr-x.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-10-27 16:50:40 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-10-27 16:50:40 +0200
commit7c6f7dc99bc036639bd1b64b412e8c3d3e0c044c (patch)
tree91acd1c4888b99cc21803983abc11bfc0d324b31 /lisp/emacs-lisp/subr-x.el
parent713e19a60adde301e5d7edc79f92bbb1b25b71a8 (diff)
downloademacs-7c6f7dc99bc036639bd1b64b412e8c3d3e0c044c.tar.gz
Simplify string-pixel-width
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Simplify -- save-window-excursion saves dedication status (and the code was buggy).
Diffstat (limited to 'lisp/emacs-lisp/subr-x.el')
-rw-r--r--lisp/emacs-lisp/subr-x.el18
1 files changed, 6 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 6f01209574d..f2060814f25 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -447,18 +447,12 @@ is inserted before adjusting the number of empty lines."
(with-temp-buffer
(insert string)
(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)))))))
+ ;; 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))))))
(provide 'subr-x)