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

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

bug#35602: 26.1; emacsclient doesn't go to the desired line


From: Eli Zaretskii
Subject: 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@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)))))))





reply via email to

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