comparison lisp/files.el @ 42017:50851bbcf637

(set-auto-mode): Fix previous change.
author Richard M. Stallman <rms@gnu.org>
date Fri, 14 Dec 2001 03:21:24 +0000
parents faa66f17e91f
children 5df6b6e21575
comparison
equal deleted inserted replaced
42016:3900be0515b0 42017:50851bbcf637
1574 1574
1575 If the optional argument JUST-FROM-FILE-NAME is non-nil, 1575 If the optional argument JUST-FROM-FILE-NAME is non-nil,
1576 then we do not set anything but the major mode, 1576 then we do not set anything but the major mode,
1577 and we don't even do that unless it would come from the file name." 1577 and we don't even do that unless it would come from the file name."
1578 ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- 1578 ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
1579 (let (beg end done modes) 1579 (let (end done modes)
1580 (save-excursion 1580 (save-excursion
1581 (goto-char (point-min)) 1581 (goto-char (point-min))
1582 (skip-chars-forward " \t\n") 1582 (skip-chars-forward " \t\n")
1583 (and enable-local-variables 1583 (and enable-local-variables
1584 (setq end (set-auto-mode-1)) 1584 (setq end (set-auto-mode-1))
1585 (progn 1585 (if (save-excursion (search-forward ":" end t))
1586 (if (save-excursion (search-forward ":" end t)) 1586 ;; Find all specifications for the `mode:' variable
1587 ;; Find all specifications for the `mode:' variable 1587 ;; and execute them left to right.
1588 ;; and execute them left to right. 1588 (while (let ((case-fold-search t))
1589 (while (let ((case-fold-search t)) 1589 (or (and (looking-at "mode:")
1590 (or (and (looking-at "mode:") 1590 (goto-char (match-end 0)))
1591 (goto-char (match-end 0))) 1591 (re-search-forward "[ \t;]mode:" end t)))
1592 (re-search-forward "[ \t;]mode:" end t))) 1592 (skip-chars-forward " \t")
1593 (skip-chars-forward " \t") 1593 (let ((beg (point)))
1594 (setq beg (point))
1595 (if (search-forward ";" end t) 1594 (if (search-forward ";" end t)
1596 (forward-char -1) 1595 (forward-char -1)
1597 (goto-char end)) 1596 (goto-char end))
1598 (skip-chars-backward " \t") 1597 (skip-chars-backward " \t")
1599 (push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) 1598 (push (intern (concat (downcase (buffer-substring beg (point))) "-mode"))
1600 modes)) 1599 modes)))
1601 ;; Simple -*-MODE-*- case. 1600 ;; Simple -*-MODE-*- case.
1602 (push (intern (concat (downcase (buffer-substring beg end)) 1601 (push (intern (concat (downcase (buffer-substring (point) end))
1603 "-mode")) 1602 "-mode"))
1604 modes))))) 1603 modes))))
1605 ;; If we found modes to use, invoke them now, 1604 ;; If we found modes to use, invoke them now,
1606 ;; outside the save-excursion. 1605 ;; outside the save-excursion.
1607 (unless just-from-file-name 1606 (unless just-from-file-name
1608 (dolist (mode (nreverse modes)) 1607 (dolist (mode (nreverse modes))
1609 (if (not (functionp mode)) 1608 (if (not (functionp mode))