emacs-diffs
[Top][All Lists]
Advanced

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

master f2a84ef: Restore `ff-find-other-file' buffer selection logic


From: Lars Ingebrigtsen
Subject: master f2a84ef: Restore `ff-find-other-file' buffer selection logic
Date: Tue, 25 May 2021 16:27:17 -0400 (EDT)

branch: master
commit f2a84ef8eec6a1b52bff4755e199d92de3ec3507
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Restore `ff-find-other-file' buffer selection logic
    
    * lisp/find-file.el (ff-find-other-file): Restore selection of
    buffer changed by previous change (bug#48535).
---
 lisp/find-file.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lisp/find-file.el b/lisp/find-file.el
index 6c3c0f1..4fd4f4e 100644
--- a/lisp/find-file.el
+++ b/lisp/find-file.el
@@ -305,6 +305,10 @@ Being on a `#include' line pulls in that file.
 If optional IN-OTHER-WINDOW is non-nil, find the file in the other window.
 If optional IGNORE-INCLUDE is non-nil, ignore being on `#include' lines.
 
+If optional EVENT is non-nil (default `last-nonmenu-event', move
+point to the end position of that event before calling the
+various ff-* hooks.
+
 Variables of interest include:
 
  - `ff-case-fold-search'
@@ -351,10 +355,16 @@ Variables of interest include:
  - `ff-file-created-hook'
    List of functions to be called if the other file has been created."
   (interactive (list current-prefix-arg nil last-nonmenu-event))
-  (save-excursion
+  ;; We want to preserve point in the current buffer. But the point of
+  ;; ff-find-the-other-file is to make the the other file buffer
+  ;; current, so we can't use save-excursion here (see bug 48535).
+  (let ((start-buffer (current-buffer))
+        (start-point (point)))
     (posn-set-point (event-end event))
     (let ((ff-ignore-include ignore-include))
-      (ff-find-the-other-file in-other-window))))
+      (ff-find-the-other-file in-other-window))
+    (with-current-buffer start-buffer
+      (goto-char start-point))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Support functions



reply via email to

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