bug#81516: 31.0.91; delete-file-local-variable(-prop-line) should delete "Local Variables" block (prop-line)
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
> From: Daniel Mendler <[email protected]> > Cc: [email protected] > Date: Wed, 29 Jul 2026 16:55:27 +0200 > > Eli Zaretskii <[email protected]> writes: > > >> I suggest to handle both deletion commands the same, remove the faulty > >> prop line, and also the empty local variables block. > > > > Why? > > Why not? Because a line like that could be present in a Lisp file regardless of local vars, and signaling an error when visiting such a file is a clear bug, IMO. So we need to fix the error regardless, and removing the remnants of the local vars just sweeps the problem under the carpet. How about the patch below? Stefan and Sean, any comments? diff --git a/lisp/files.el b/lisp/files.el index 9b1fc09..5756ca3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3633,9 +3633,11 @@ set-auto-mode (push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) modes))) ;; Simple -*-MODE-*- case. - (push (intern (concat (downcase (buffer-substring (point) end)) - "-mode")) - modes)))) + (and (< (point) end) + (push (intern (concat (downcase + (buffer-substring (point) end)) + "-mode")) + modes))))) (or ;; If we found modes to use, invoke them now, outside the save-excursion. ;; Presume `modes' holds a major mode followed by minor modes. @@ -3826,6 +3828,7 @@ set-auto-mode-1 (forward-char -3) (skip-chars-backward " \t") (setq end (point)) + (setq beg (min beg end)) (goto-char beg) end))))