unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: 48535@debbugs.gnu.org
Subject: bug#48535: 28.0.50; ff-find-other-file no longer sets current-buffer?
Date: Sun, 23 May 2021 14:56:57 -0700	[thread overview]
Message-ID: <86lf85jeqe.fsf@stephe-leake.org> (raw)
In-Reply-To: <86pmxhjgj8.fsf@stephe-leake.org> (Stephen Leake's message of "Sun, 23 May 2021 14:18:03 -0700")

[-- Attachment #1: Type: text/plain, Size: 695 bytes --]

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> Stephen Leake <stephen_leake@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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: find-file.diff --]
[-- Type: text/x-patch, Size: 1404 bytes --]

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

  reply	other threads:[~2021-05-23 21:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 13:08 bug#48535: 28.0.50; ff-find-other-file no longer sets current-buffer? Stephen Leake
     [not found] ` <handler.48535.B.162151612728412.ack@debbugs.gnu.org>
2021-05-21 21:09   ` Stephen Leake
2021-05-21 21:27     ` Stephen Leake
2021-05-23 15:57       ` Stephen Leake
2021-05-23 21:18         ` Stephen Leake
2021-05-23 21:56           ` Stephen Leake [this message]
2021-05-25 20:26             ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86lf85jeqe.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=48535@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).