GNU bug report logs - #78777
30.1; insert-file-contents should not set buffer-file-name to nil

Previous Next

Package: emacs;

Reported by: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>

Date: Thu, 12 Jun 2025 16:59:01 UTC

Severity: normal

Found in version 30.1

Full log


Message #50 received at 78777 <at> debbugs.gnu.org (full text, mbox):

From: "K. Handa" <handa <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: handa <at> gnu.org, eliz <at> gnu.org, wyuenho <at> gmail.com, 78777 <at> debbugs.gnu.org
Subject: Re: bug#78777: 30.1; insert-file-contents should not set
 buffer-file-name to nil
Date: Wed, 18 Jun 2025 23:23:16 +0900
Hi,

In article <jwvtt4fag1z.fsf-monnier+emacs <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
[...]
>     (Finsert_file_contents): On replacing, temporarily bind
>     buffer-file-name to Qnil before calling insert_from_buffer.

> diff --git a/src/fileio.c b/src/fileio.c
> --- a/src/fileio.c
> +++ b/src/fileio.c
> @@ -4359,8 +4359,12 @@
>        inserted_chars
>  	= (buf_bytepos_to_charpos (XBUFFER (conversion_buffer),
>  				   same_at_start + inserted)
>  	   - same_at_start_charpos);
> +      /* This binding is to avoid ask-user-about-supersession-threat
> +	 being called in insert_from_buffer (via in
> +	 prepare_to_modify_buffer).  */
> +      specbind (intern ("buffer-file-name"), Qnil);
>        insert_from_buffer (XBUFFER (conversion_buffer),
>  			  same_at_start_charpos, inserted_chars, 0);
>        /* Set `inserted' to the number of inserted characters.  */
>        inserted = PT - temp;
> ```

> I'm not sure exactly what was the motivation for the change.
> I mean, the comment explains that the purpose is to silence a potential
> `ask-user-about-supersession-threat`, but I don't know why we should
> care about such a possibility and why it would be right to silence
> it here.

I don't remember, sorry.

> Nor do I understand why it was added to the code path where coding
> conversion was needed but not to the other one.

??? It seems that the code above is where coding conversion is not
needed.

---
K. Handa
handa <at> gnu.org




This bug report was last modified 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.