GNU bug report logs - #35602
26.1; emacsclient doesn't go to the desired line

Previous Next

Package: emacs;

Reported by: Robert Parlett <r.parlett <at> gmail.com>

Date: Mon, 6 May 2019 14:24:01 UTC

Severity: normal

Found in version 26.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35602 in the body.
You can then email your comments to 35602 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35602; Package emacs. (Mon, 06 May 2019 14:24:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Robert Parlett <r.parlett <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 06 May 2019 14:24:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Robert Parlett <r.parlett <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; emacsclient doesn't go to the desired line
Date: Mon, 6 May 2019 11:05:19 +0100
[Message part 1 (text/plain, inline)]
When running emacsclient with the “+line” option, on a file already loaded
in emacs, but not the current buffer, emacs fails to go to the desired
line.  This is easy to reproduce as follows :-

   1. Start emacs with emacs -Q
   2. In emacs, start the server with M-x server-start
   3. In a shell, create some test text files :-
   $ man bash >f1.txt
   $ man top >f2.txt
   4. Now run the following commands in the shell :-
   $ emacsclient +200 -n f1.txt
   $ emacsclient +300 -n f2.txt
   $ emacsclient +400 -n f1.txt

The bug can be seen after the last emacsclient command above.  The correct
result would be that file f1.txt is made the current buffer, with the
cursor on line 400.  However, instead it is made the current buffer with
the cursor remaining on line 200.


In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.7)
 of 2019-04-11, modified by Debian built on lcy01-amd64-021
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Ubuntu 19.04

Recent messages:
Updating buffer list...done
Mark set
Updating buffer list...done
Mark set [3 times]
Updating buffer list...done
Mark set [3 times]
Replaced 5 occurrences
Updating buffer list...done

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 --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-cQxEw2/emacs-26.1+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LANG: en_GB.UTF8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-7/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-7/tablegen-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-7/emacs
/usr/share/emacs/site-lisp/llvm-6.0/llvm-mode hides
/usr/share/emacs/site-lisp/llvm-8/llvm-mode
/usr/share/emacs/site-lisp/llvm-6.0/tablegen-mode hides
/usr/share/emacs/site-lisp/llvm-8/tablegen-mode
/usr/share/emacs/site-lisp/llvm-6.0/emacs hides
/usr/share/emacs/site-lisp/llvm-8/emacs
/usr/share/emacs/26.1/lisp/emacs-lisp/regexp-opt hides
/home/rparlett/emacsinit/regexp-opt

Features:
(shadow sort mail-extr emacsbug message rmc puny format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils make-mode conf-mode m4-mode cl-extra
thingatpt rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc
rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap sgml-mode dom nxml-util nxml-enc xmltok
help-mode autoconf autoconf-mode sh-script smie executable etags xref
cl-seq project eieio eieio-core eieio-loaddefs ring cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
vc-dispatcher vc-svn misearch multi-isearch cl-macs ibuf-ext edmacro
kmacro ibuffer ibuffer-loaddefs seq byte-opt bytecomp byte-compile cconv
vc-cvs elec-pair cus-edit cus-start cus-load wid-edit server cl-indent
apropos objecticon-setup dired-x easymenu dired dired-loaddefs cl gv
cl-loaddefs cl-lib time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded 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 dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 517476 54974)
 (symbols 48 30916 1)
 (miscs 40 1296 2855)
 (strings 32 59904 5909)
 (string-bytes 1 1804425)
 (vectors 16 33815)
 (vector-slots 8 1553596 106048)
 (floats 8 81 842)
 (intervals 56 71779 3079)
 (buffers 992 163))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35602; Package emacs. (Tue, 07 May 2019 14:22:01 GMT) Full text and rfc822 format available.

Message #8 received at 35602 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Parlett <r.parlett <at> gmail.com>
Cc: 35602 <at> debbugs.gnu.org
Subject: Re: bug#35602: 26.1; emacsclient doesn't go to the desired line
Date: Tue, 07 May 2019 17:21:35 +0300
> From: Robert Parlett <r.parlett <at> gmail.com>
> Date: Mon, 6 May 2019 11:05:19 +0100
> 
> 1 Start emacs with emacs -Q
> 2 In emacs, start the server with M-x server-start
> 3 In a shell, create some test text files :-
>  $ man bash >f1.txt
>  $ man top >f2.txt
> 4 Now run the following commands in the shell :-
>  $ emacsclient +200 -n f1.txt 
>  $ emacsclient +300 -n f2.txt 
>  $ emacsclient +400 -n f1.txt 
> 
> The bug can be seen after the last emacsclient command above.  The correct result would be that file f1.txt is
> made the current buffer, with the cursor on line 400.  However, instead it is made the current buffer with the
> cursor remaining on line 200.

Thanks for reporting this.

This is switch-to-buffer-preserve-window-point in action.  Does the
patch below fix the problem for you?

--- lisp/server.el~0	2019-01-16 06:33:00.000000000 +0200
+++ lisp/server.el	2019-05-07 17:20:14.108225200 +0300
@@ -1655,7 +1655,14 @@
 			      (frame-terminal))))
 		'nomini 'visible (selected-window))))
 	    (condition-case nil
-		(switch-to-buffer next-buffer)
+                ;; If the client specified a new buffer position,
+                ;; treat that as an explicit point-move command, and
+                ;; override switch-to-buffer-preserve-window-point.
+                (let ((switch-to-buffer-preserve-window-point
+                       (if filepos
+                           nil
+                         switch-to-buffer-preserve-window-point)))
+                  (switch-to-buffer next-buffer))
 	      ;; After all the above, we might still have ended up with
 	      ;; a minibuffer/dedicated-window (if there's no other).
 	      (error (pop-to-buffer next-buffer)))))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35602; Package emacs. (Wed, 08 May 2019 06:08:01 GMT) Full text and rfc822 format available.

Message #11 received at 35602 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Parlett <r.parlett <at> gmail.com>
Cc: 35602 <at> debbugs.gnu.org
Subject: Re: bug#35602: 26.1; emacsclient doesn't go to the desired line
Date: Wed, 08 May 2019 09:07:09 +0300
[Please use Reply to All to have the bug address on the CC list.]

> From: Robert Parlett <r.parlett <at> gmail.com>
> Date: Tue, 7 May 2019 23:38:14 +0100
> 
> Thank you for your reply.  
> 
> I find that if the variable you mention (switch-to-buffer-preserve-window-point) is set to nil, then the problem is
> indeed averted.

Thanks.  Did you also try the patch?  It doesn't change the value of
that variable, only binds it temporarily while Emacs changes the
buffer in the selected window.

> I should have mentioned in my original report that this bug wasn't present in previous versions; it appeared
> after an update to emacs 26.1 from (I think) 25.2.

That's because Emacs 26 changed the default of that variable to t.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 08 May 2019 17:37:01 GMT) Full text and rfc822 format available.

Notification sent to Robert Parlett <r.parlett <at> gmail.com>:
bug acknowledged by developer. (Wed, 08 May 2019 17:37:02 GMT) Full text and rfc822 format available.

Message #16 received at 35602-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Parlett <r.parlett <at> gmail.com>
Cc: 35602-done <at> debbugs.gnu.org
Subject: Re: bug#35602: 26.1; emacsclient doesn't go to the desired line
Date: Wed, 08 May 2019 20:36:29 +0300
> From: Robert Parlett <r.parlett <at> gmail.com>
> Date: Wed, 8 May 2019 15:20:42 +0100
> 
> Thanks, that makes sense now.
> 
> I have just tried your patch by downloading the 26.2 source, editing server.el, removing server.elc, building and
> installing everything to a temporary directory, and can confirm the patch works fine.

Thanks, I installed the change on the emacs-26 branch, and I'm
therefore closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 06 Jun 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 320 days ago.

Previous Next


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