1576 |
then we do not set anything but the major mode, |
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." |
and we don't even do that unless it would come from the file name." |
1578 |
;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- |
;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- |
1579 |
(let (beg end done modes) |
(let (end done modes) |
1580 |
(save-excursion |
(save-excursion |
1581 |
(goto-char (point-min)) |
(goto-char (point-min)) |
1582 |
(skip-chars-forward " \t\n") |
(skip-chars-forward " \t\n") |
1583 |
(and enable-local-variables |
(and enable-local-variables |
1584 |
(setq end (set-auto-mode-1)) |
(setq end (set-auto-mode-1)) |
1585 |
(progn |
(if (save-excursion (search-forward ":" end t)) |
1586 |
(if (save-excursion (search-forward ":" end t)) |
;; Find all specifications for the `mode:' variable |
1587 |
;; Find all specifications for the `mode:' variable |
;; and execute them left to right. |
1588 |
;; and execute them left to right. |
(while (let ((case-fold-search t)) |
1589 |
(while (let ((case-fold-search t)) |
(or (and (looking-at "mode:") |
1590 |
(or (and (looking-at "mode:") |
(goto-char (match-end 0))) |
1591 |
(goto-char (match-end 0))) |
(re-search-forward "[ \t;]mode:" end t))) |
1592 |
(re-search-forward "[ \t;]mode:" end t))) |
(skip-chars-forward " \t") |
1593 |
(skip-chars-forward " \t") |
(let ((beg (point))) |
|
(setq beg (point)) |
|
1594 |
(if (search-forward ";" end t) |
(if (search-forward ";" end t) |
1595 |
(forward-char -1) |
(forward-char -1) |
1596 |
(goto-char end)) |
(goto-char end)) |
1597 |
(skip-chars-backward " \t") |
(skip-chars-backward " \t") |
1598 |
(push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) |
(push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) |
1599 |
modes)) |
modes))) |
1600 |
;; Simple -*-MODE-*- case. |
;; Simple -*-MODE-*- case. |
1601 |
(push (intern (concat (downcase (buffer-substring beg end)) |
(push (intern (concat (downcase (buffer-substring (point) end)) |
1602 |
"-mode")) |
"-mode")) |
1603 |
modes))))) |
modes)))) |
1604 |
;; If we found modes to use, invoke them now, |
;; If we found modes to use, invoke them now, |
1605 |
;; outside the save-excursion. |
;; outside the save-excursion. |
1606 |
(unless just-from-file-name |
(unless just-from-file-name |