master df68768d1d8: Avoid errors when "-*- -*-" prop line of a file has no tags
Eli Zaretskii <[email protected]> Thu, 30 Jul 2026 00:20:22 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit df68768d1d80ff1c90839b4c1789469b425808d8 Author: Eli Zaretskii <[email protected]> Commit: Eli Zaretskii <[email protected]> Avoid errors when "-*- -*-" prop line of a file has no tags * lisp/files.el (set-auto-mode): Don't add an invalid "-mode" to 'modes', if the mode tag is empty. (set-auto-mode-1): Make sure we return a position that is at or after point. (Bug#81516) --- lisp/files.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 9d5cd3fa30d..8f2d8e97e4b 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3634,9 +3634,11 @@ we don't actually set it to the same mode the buffer already has." (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. @@ -3827,6 +3829,7 @@ have no effect." (forward-char -3) (skip-chars-backward " \t") (setq end (point)) + (setq beg (min beg end)) (goto-char beg) end))))