Subject: bug#44303: 28.0.50; json-pretty-print-buffer creates spurious lock file

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 30 Oct 2020 14:28:59 +0100

Simen Heggestøyl <[email-masked]> writes:

> Given a file named 'test.json' with the following content: {}
>
>>>From 'emacs -Q', visit the file and call 'json-pretty-print-buffer'.
>
> The buffer stays unchanged as expected since the pretty printed content
> is identical to the original. The buffer is not marked as modified (also
> expected), but a spurious lock file '.#test.json' has been created.

Yup.  It's this code in Freplace_buffer_contents:

  if (!inhibit_modification_hooks)
    {
      prepare_to_modify_buffer (BEGV, ZV, NULL);
      specbind (Qinhibit_modification_hooks, Qt);
      modification_hooks_inhibited = true;
    }

prepare_to_modify_buffer creates the backup file.

But is that even needed here?  Don't the later
Finsert_buffer_substring/del_range_both functions do the necessary
bookkeeping?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no