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

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

bug#69093: window-state-put doesn't update current buffer


From: Juri Linkov
Subject: bug#69093: window-state-put doesn't update current buffer
Date: Wed, 21 Feb 2024 19:27:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

> I'd say that saving a window configuration where the current buffer is
> _not_ shown in the selected window is never right.  So can you give me a
> practical example where you think that this
>
>> +          (set-buffer (window-buffer))))
>
> is useful or needed?

This fix is needed for this case:

(defun pulse-momentary-highlight-one-line (&optional point face)
  (save-excursion
    (goto-char (or point (point)))
    (let ((start (progn (vertical-motion 0) (point)))
          (end (progn (vertical-motion 1) (point))))
      (pulse-momentary-highlight-region start end face))))

It expects that 'point' should be in the current buffer
that is displayed in the selected window.

But this hook fails:

(add-hook 'tab-bar-tab-post-select-functions
          (lambda (_from-tab _to-tab)
            (pulse-momentary-highlight-one-line)))

because this new hook is called in the patch below
after finishing 'window-state-put' that doesn't
set the current buffer to the window's buffer.
So after 'window-state-put' finishes,
the current buffer stays in some previous buffer.

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 3e1d8278b04..50679f54474 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1499,7 +1565,10 @@ tab-bar-select-tab
               (tab-bar--current-tab-make (nth to-index tabs)))
 
         (unless tab-bar-mode
-          (message "Selected tab '%s'" (alist-get 'name to-tab))))
+          (message "Selected tab '%s'" (alist-get 'name to-tab)))
+
+        (run-hook-with-args 'tab-bar-tab-post-select-functions
+                            from-tab to-tab))
 
       (force-mode-line-update))))
 





reply via email to

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