From 2d2ab9da1b332f6620e25dc76914cf7d9c65b972 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 14 Dec 2001 03:21:49 +0000 Subject: [PATCH] (set-auto-mode): Fix previous change. --- lisp/ChangeLog | 4 ++++ lisp/files.el | 31 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 26087a6d607..34018fccc73 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2001-12-13 Richard M. Stallman + + * files.el (set-auto-mode): Fix previous change. + 2001-12-13 Stefan Monnier * emacs-lisp/easymenu.el (easy-menu-intern): New fun. diff --git a/lisp/files.el b/lisp/files.el index c7426d05d04..054dd0368e5 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1576,32 +1576,31 @@ If the optional argument JUST-FROM-FILE-NAME is non-nil, then we do not set anything but the major mode, and we don't even do that unless it would come from the file name." ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- - (let (beg end done modes) + (let (end done modes) (save-excursion (goto-char (point-min)) (skip-chars-forward " \t\n") (and enable-local-variables (setq end (set-auto-mode-1)) - (progn - (if (save-excursion (search-forward ":" end t)) - ;; Find all specifications for the `mode:' variable - ;; and execute them left to right. - (while (let ((case-fold-search t)) - (or (and (looking-at "mode:") - (goto-char (match-end 0))) - (re-search-forward "[ \t;]mode:" end t))) - (skip-chars-forward " \t") - (setq beg (point)) + (if (save-excursion (search-forward ":" end t)) + ;; Find all specifications for the `mode:' variable + ;; and execute them left to right. + (while (let ((case-fold-search t)) + (or (and (looking-at "mode:") + (goto-char (match-end 0))) + (re-search-forward "[ \t;]mode:" end t))) + (skip-chars-forward " \t") + (let ((beg (point))) (if (search-forward ";" end t) (forward-char -1) (goto-char end)) (skip-chars-backward " \t") (push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) - modes)) - ;; Simple -*-MODE-*- case. - (push (intern (concat (downcase (buffer-substring beg end)) - "-mode")) - modes))))) + modes))) + ;; Simple -*-MODE-*- case. + (push (intern (concat (downcase (buffer-substring (point) end)) + "-mode")) + modes)))) ;; If we found modes to use, invoke them now, ;; outside the save-excursion. (unless just-from-file-name -- 2.39.2