GNU bug report logs - #1237
23.0.60; `switch-to-buffer-other-window' sometimes uses selected window

Previous Next

Package: emacs;

Reported by: Markus Triska <markus.triska <at> gmx.at>

Date: Fri, 24 Oct 2008 10:35:03 UTC

Severity: normal

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Markus Triska <markus.triska <at> gmx.at>
Cc: 1237 <at> debbugs.gnu.org, martin rudalics <rudalics <at> gmx.at>
Subject: bug#1237: 23.0.60; `switch-to-buffer-other-window' sometimes uses selected window
Date: Sat, 25 Oct 2008 15:08:10 -0400
> I constructed the following self-contained case that I hope helps you:

>    (defun my-walk () (walk-windows 'identity))
>    (add-hook 'window-configuration-change-hook 'my-walk nil t)
>    (split-window)
>    (switch-to-buffer-other-window "test")

In Emacs-22, window-configuration-change-hook did not work correctly
with buffer-local hooks, but in some cases you could make it work
somewhat by using `walk-window' in your hook to try and cover all the
affected windows.

With the code I installed to properly support buffer-local hooks on
window-configuration-change-hook, the walk-window should be unnecessary,
so the patch below should not break linum and might remove the problem.

This said, walk-windows should probably use `norecord', what do
people think?


        Stefan


=== modified file 'lisp/linum.el'
--- lisp/linum.el	2008-08-31 19:46:54 +0000
+++ lisp/linum.el	2008-10-25 19:06:30 +0000
@@ -82,17 +82,22 @@
                                            'linum-update-current) nil t)
           (add-hook 'after-change-functions 'linum-after-change nil t))
         (add-hook 'window-scroll-functions 'linum-after-scroll nil t)
+        ;; FIXME: using both window-size-change-functions and
+        ;; window-configuration-change-hook seems redundant.
         (add-hook 'window-size-change-functions 'linum-after-size nil t)
         (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
         (add-hook 'window-configuration-change-hook
-                  'linum-after-config nil t)
+                  ;; FIXME: If the buffer is shows in N windows, this
+                  ;; will be called N times rather than once.  We should use
+                  ;; something like linum-update-window instead.
+                  'linum-update-current nil t)
         (linum-update-current))
     (remove-hook 'post-command-hook 'linum-update-current t)
     (remove-hook 'post-command-hook 'linum-schedule t)
     (remove-hook 'window-size-change-functions 'linum-after-size t)
     (remove-hook 'window-scroll-functions 'linum-after-scroll t)
     (remove-hook 'after-change-functions 'linum-after-change t)
-    (remove-hook 'window-configuration-change-hook 'linum-after-config t)
+    (remove-hook 'window-configuration-change-hook 'linum-update-current t)
     (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
     (linum-delete-overlays)))
 





This bug report was last modified 16 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.