GNU bug report logs -
#48535
28.0.50; ff-find-other-file no longer sets current-buffer?
Previous Next
Reported by: Stephen Leake <stephen_leake <at> stephe-leake.org>
Date: Thu, 20 May 2021 13:09:02 UTC
Severity: normal
Tags: fixed
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Stephen Leake <stephen_leake <at> stephe-leake.org> writes:
> Stephen Leake <stephen_leake <at> stephe-leake.org> writes:
>
>> Stephen Leake <stephen_leake <at> stephe-leake.org> writes:
>>
>>>> I've confirmed that disabling lexical-binding fixes the problem.
>>>
>>> On the other hand, re-enabling lexical-binding, and byte-compiling just
>>> that file (which 'make' does), the problem does not come back. Sigh.
>>
>> I was confused; I was working in a 'good' commit, not the first 'bad'
>> commit.
>>
>> Disabling lexical-binding in find-file.el does not fix the problem in
>> the 'bad' commit.
>
> The attached patch fixes the problem, in master HEAD (c9655fcb47).
actually attach the patch
--
-- Stephe
[find-file.diff (text/x-patch, inline)]
diff --git a/lisp/find-file.el b/lisp/find-file.el
index 6c3c0f123b..4fd4f4e06b 100644
--- a/lisp/find-file.el
+++ b/lisp/find-file.el
@@ -305,6 +305,10 @@ ff-find-other-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 @@ ff-find-other-file
- `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
This bug report was last modified 3 years and 356 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.