bug#21304: 24.5; follow-switch-to-buffer changes positions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#21304: 24.5; follow-switch-to-buffer changes positions

Milan Zamazal


`follow-switch-to-buffer' doesn't retain cursor position nor buffer
position within the windows.

How to reproduce the bug:

- Start Emacs.
- Type `C-h n' (NEWS gets displayed)
- Type `C-h C-c' (COPYING gets displayed)
- Type `C-x 3' (the window gets split)
- Type `M-x follow-mode RET' (follow mode gets enabled)
- Type `C-v' (the buffer gets scrolled -- note the cursor position)
- Type `M-x follow-switch-to-buffer RET RET' (NEWS gets displayed)
- Type `M-x follow-switch-to-buffer RET RET' (COPYING gets displayed again)

I'd expect the window contents and cursor position would be the same as
after typing `C-v'; there is no reason why they should be changed just
after switching to another buffer and back.  But they are changed.

I think the problem is in the order of window selection and buffer
switching in follow-switch-to-buffer.  When I change the function body
to something like

  (let ((orig-window (selected-window)))
    (dolist (w (follow-all-followers))
      (unless (eq w orig-window)
        (select-window w)
        (switch-to-buffer buffer)))
    (select-window orig-window)
    (switch-to-buffer buffer)))

then it works as expected.




In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)
 of 2015-06-29 on blackbird, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
System Description: Debian GNU/Linux 8.1 (jessie)

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-z,relro'

Important settings:
  value of $LC_CTYPE: cs_CZ.UTF-8
  value of $LANG: C
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  follow-mode: t
  goto-address-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t
  view-mode: t

Recent messages:
Loading /usr/share/emacs/site-lisp/slime/slime-autoloads.el (source)...done
Loading /etc/emacs/site-start.d/50slime.el (source)...done
Loading /etc/emacs/site-start.d/51debian-el.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Note: file is write protected
View mode: type C-h for help, h for commands, q to quit.
Note: file is write protected
View mode: type C-h for help, h for commands, q to quit.
Follow mode enabled
You can run the command `follow-switch-to-buffer' with C-c . b

Load-path shadows:
/usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs24/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/site-lisp/rst hides /usr/share/emacs/24.5/lisp/textmodes/rst
/usr/share/emacs24/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.5/lisp/textmodes/flyspell
/usr/share/emacs24/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.5/lisp/textmodes/ispell
/usr/share/emacs/24.5/site-lisp/slime/lib/ert-x hides /usr/share/emacs/24.5/lisp/emacs-lisp/ert-x
/usr/share/emacs/24.5/site-lisp/slime/lib/ert hides /usr/share/emacs/24.5/lisp/emacs-lisp/ert

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils follow easymenu goto-addr thingatpt
noutline outline easy-mmode view debian-el debian-el-loaddefs
slime-autoloads dpkg-dev-el dpkg-dev-el-loaddefs time-date tooltip
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 81114 6398)
 (symbols 48 19487 0)
 (miscs 40 115 136)
 (strings 32 12653 4707)
 (string-bytes 1 307717)
 (vectors 16 9684)
 (vector-slots 8 401376 6969)
 (floats 8 67 289)
 (intervals 56 329 0)
 (buffers 960 15)
 (heap 1024 46481 988))



Reply | Threaded
Open this post in threaded view
|

bug#21304: 24.5; follow-switch-to-buffer changes positions

martin rudalics
 > `follow-switch-to-buffer' doesn't retain cursor position nor buffer
 > position within the windows.
 >
 > How to reproduce the bug:
 >
 > - Start Emacs.
 > - Type `C-h n' (NEWS gets displayed)
 > - Type `C-h C-c' (COPYING gets displayed)
 > - Type `C-x 3' (the window gets split)
 > - Type `M-x follow-mode RET' (follow mode gets enabled)
 > - Type `C-v' (the buffer gets scrolled -- note the cursor position)
 > - Type `M-x follow-switch-to-buffer RET RET' (NEWS gets displayed)
 > - Type `M-x follow-switch-to-buffer RET RET' (COPYING gets displayed again)
 >
 > I'd expect the window contents and cursor position would be the same as
 > after typing `C-v'; there is no reason why they should be changed just
 > after switching to another buffer and back.  But they are changed.

I see the behavior you describe with Emacs 25 but do not see it with the
upcoming release version.  Can you try with Emacs 26?

Thanks, martin