From a0197aef96e091b2bb4e317669a8ad5c9108f269 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 22 Jan 2026 09:37:14 +0200 Subject: [PATCH] Restrict the 'buffer' arg of 'goto-line' only to interactive uses * lisp/simple.el (goto-line): Use 'buffer' arg only when 'interactive' is non-nil (bug#80150). Update docstring. --- lisp/simple.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 774dab254c3..2a59437406f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1644,9 +1644,8 @@ If called interactively, a numeric prefix argument specifies LINE; without a numeric prefix argument, read LINE from the minibuffer. -If optional argument BUFFER is non-nil, switch to that buffer and -move to line LINE there. If called interactively with \\[universal-argument] -as argument, BUFFER is the most recently selected other buffer. +If called interactively with \\[universal-argument], switch to the +most recently selected other buffer and move to line LINE there. If optional argument RELATIVE is non-nil, counting starts at the beginning of the accessible portion of the (potentially narrowed) buffer. @@ -1659,7 +1658,8 @@ Prior to moving point, this function sets the mark (without activating it), unless Transient Mark mode is enabled and the mark is already active. -A non-nil INTERACTIVE argument means to push the mark. +A non-nil INTERACTIVE argument pushes the mark and switches the buffer +if optional argument BUFFER is non-nil. This function is usually the wrong thing to use in a Lisp program. What you probably want instead is something like: @@ -1669,7 +1669,7 @@ If at all possible, an even better solution is to use char counts rather than line counts." (interactive (append (goto-line-read-args) '(nil t))) ;; Switch to the desired buffer, one way or another. - (if buffer + (if (and buffer interactive) (let ((window (get-buffer-window buffer))) (if window (select-window window) (switch-to-buffer-other-window buffer))))