]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify string-pixel-width
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Oct 2021 14:50:40 +0000 (16:50 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Oct 2021 14:50:40 +0000 (16:50 +0200)
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Simplify --
save-window-excursion saves dedication status (and the code was
buggy).

lisp/emacs-lisp/subr-x.el

index 6f01209574d73bc31bc7bfd319206727c17b5478..f2060814f256d918f10e38e98f418b2b36a88049 100644 (file)
@@ -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)