Skip to content

Commit e7ab351

Browse files
committed
Fix positioning client buffer as instructed by emacsclient
* lisp/server.el (server-switch-buffer): Let-bind switch-to-buffer-preserve-window-point to nil when switching to the client buffer, when the client requested a specific position. (Bug#35602)
1 parent 916510b commit e7ab351

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lisp/server.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,14 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)."
16211621
(frame-terminal))))
16221622
'nomini 'visible (selected-window))))
16231623
(condition-case nil
1624-
(switch-to-buffer next-buffer)
1624+
;; If the client specified a new buffer position,
1625+
;; treat that as an explicit point-move command, and
1626+
;; override switch-to-buffer-preserve-window-point.
1627+
(let ((switch-to-buffer-preserve-window-point
1628+
(if filepos
1629+
nil
1630+
switch-to-buffer-preserve-window-point)))
1631+
(switch-to-buffer next-buffer))
16251632
;; After all the above, we might still have ended up with
16261633
;; a minibuffer/dedicated-window (if there's no other).
16271634
(error (pop-to-buffer next-buffer)))))))

0 commit comments

Comments
 (0)