bug#81516: 31.0.91; delete-file-local-variable(-prop-line) should delete "Local Variables" block (prop-line)

Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Eli Zaretskii <[email protected]> writes:

>> Date: Wed, 29 Jul 2026 15:02:38 +0200
>> From: Daniel Mendler via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email protected]>
>> 
>> When delete-file-local-variable is called for the last file-local
>> variable, the "Local Variables" block is not removed. Similarly for
>> delete-file-local-variable-prop-line, a remnant of the prop-line
>> remains: ;; -*- -*-
>> 
>> While the remnants are not highly problematic, one still gets an error
>> when the file is opened the next time:
>> 
>>   File mode specification error:
>>   (error "Invalid search bound (wrong side of point)")
>> 
>> This suggest that the empty prop line (or the "Local Variables" block)
>> should better be deleted.
>
> I cannot reproduce this error.  I created a file with file-local
> variables, then invoked delete-file-local-variable several times until
> all the variables were deleted and what was left was the empty block:
>
>   ;; Local Variables:
>   ;; End:
>
> Then I saved the buffer to its file, killed Emacs, and visited the
> file in a new session -- I saw no errors.
>
> If the recipe for reproducing the error is different, please describe
> it in enough detail for me to be able to reproduce it.

The error occurs only for delete-file-local-variable-prop-line. There
the header line ";; -*- -*-" remains which triggers the error the next
time the file is opened.

I suggest to handle both deletion commands the same, remove the faulty
prop line, and also the empty local variables block.

Daniel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.