bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53910: [External] : bug#53910: 29.0.50; context-menu-mode breaks hel


From: martin rudalics
Subject: bug#53910: [External] : bug#53910: 29.0.50; context-menu-mode breaks help in read-only buffers
Date: Sun, 13 Feb 2022 09:49:10 +0100

> What worries me more is that the following idiom is not always safe:
>
>    (with-selected-window (or window (selected-window))
>      body
>      ...)
>
> because it might switch the buffer of the already selected window.

IIUC you mean that it might make another buffer current?  But the whole
idea of selecting a window is that it gets you in a consistent state
where, for example, the window is the selected window of its frame which
is also the selected frame and point returns the position of point of
the selected window.  Everything else is of evil (on the Lisp level).

I don't know why you need that idiom in tab-line.el but, for example,
the completely misguided

(defun window-safely-shrinkable-p (&optional window)
  "Return t if WINDOW can be shrunk without shrinking other windows.
WINDOW defaults to the selected window."
  (with-selected-window (or window (selected-window))
    (let ((edges (window-edges)))
      (or (= (nth 2 edges) (nth 2 (window-edges (previous-window))))
          (= (nth 0 edges) (nth 0 (window-edges (next-window))))))))

should be written as

(defun window-safely-shrinkable-p (&optional window)
  "Return t if WINDOW can be shrunk without shrinking other windows.
WINDOW defaults to the selected window."
  (let ((edges (window-edges window)))
    (or (= (nth 2 edges) (nth 2 (window-edges (previous-window window))))
        (= (nth 0 edges) (nth 0 (window-edges (next-window window)))))))

So I'd urge you to rewrite the tab-line functions in a more safe way.

martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]