forked from mirrors/org-mode
org-sting-width: Do no err in dedicated windows
* lisp/org-macs.el (org-string-width): Do not err when current window is dedicated. Force-remove dedicated status temporarily during the call. This should be safe as we only need to take over the window temporarily to hook into Emacs display and calculate the string width. Reported-by: Bruno BARBIER <brubar.cs@gmail.com> Link: https://orgmode.org/list/63662793.5d0a0220.62647.3003@mx.google.com
This commit is contained in:
parent
3e010d81dc
commit
946abeb49a
|
@ -1100,9 +1100,17 @@ Return width in pixels when PIXELS is non-nil."
|
|||
(if (get-buffer-window (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max)))
|
||||
(set-window-buffer nil (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max)))))
|
||||
(let ((dedicatedp (window-dedicated-p))
|
||||
(oldbuffer (window-buffer)))
|
||||
(unwind-protect
|
||||
(progn
|
||||
;; Do not throw error in dedicated windows.
|
||||
(set-window-dedicated-p nil nil)
|
||||
(set-window-buffer nil (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max))))
|
||||
(set-window-buffer nil oldbuffer)
|
||||
(set-window-dedicated-p nil dedicatedp)))))
|
||||
(unless pixels
|
||||
(erase-buffer)
|
||||
(insert "a")
|
||||
|
@ -1110,9 +1118,17 @@ Return width in pixels when PIXELS is non-nil."
|
|||
(if (get-buffer-window (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max)))
|
||||
(set-window-buffer nil (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max)))))))
|
||||
(let ((dedicatedp (window-dedicated-p))
|
||||
(oldbuffer (window-buffer)))
|
||||
(unwind-protect
|
||||
(progn
|
||||
;; Do not throw error in dedicated windows.
|
||||
(set-window-dedicated-p nil nil)
|
||||
(set-window-buffer nil (current-buffer))
|
||||
(car (window-text-pixel-size
|
||||
nil (line-beginning-position) (point-max))))
|
||||
(set-window-buffer nil oldbuffer)
|
||||
(set-window-dedicated-p nil dedicatedp)))))))
|
||||
(if pixels
|
||||
pixel-width
|
||||
(/ pixel-width symbol-width)))))))
|
||||
|
|
Loading…
Reference in New Issue