aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/files.el21
1 files changed, 7 insertions, 14 deletions
diff --git a/lisp/files.el b/lisp/files.el
index e648143b102..b6fb11df765 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -974,20 +974,15 @@ If `enable-local-variables' is nil, this function does not check for a
974 ;; set-auto-mode should already have handled that. 974 ;; set-auto-mode should already have handled that.
975 (save-excursion 975 (save-excursion
976 (goto-char (point-min)) 976 (goto-char (point-min))
977 (skip-chars-forward " \t\n\r") 977 (let ((result nil)
978 (let ((result '()) 978 (end (save-excursion (end-of-line (and (looking-at "^#!") 2)) (point))))
979 (end (save-excursion (end-of-line) (point))))
980 ;; Parse the -*- line into the `result' alist. 979 ;; Parse the -*- line into the `result' alist.
981 (cond ((not (search-forward "-*-" end t)) 980 (cond ((not (search-forward "-*-" end t))
982 ;; doesn't have one. 981 ;; doesn't have one.
983 nil) 982 nil)
984 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") 983 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)")
985 ;; Simple form: "-*- MODENAME -*-". 984 ;; Simple form: "-*- MODENAME -*-". Already handled.
986 (setq result 985 nil)
987 (list (cons 'mode
988 (intern (buffer-substring
989 (match-beginning 1)
990 (match-end 1)))))))
991 (t 986 (t
992 ;; Hairy form: '-*-' [ <variable> ':' <value> ';' ]* '-*-' 987 ;; Hairy form: '-*-' [ <variable> ':' <value> ';' ]* '-*-'
993 ;; (last ";" is optional). 988 ;; (last ";" is optional).
@@ -1005,7 +1000,8 @@ If `enable-local-variables' is nil, this function does not check for a
1005 (val (save-restriction 1000 (val (save-restriction
1006 (narrow-to-region (point) end) 1001 (narrow-to-region (point) end)
1007 (read (current-buffer))))) 1002 (read (current-buffer)))))
1008 (setq result (cons (cons key val) result)) 1003 (or (eq key 'mode)
1004 (setq result (cons (cons key val) result)))
1009 (skip-chars-forward " \t;"))) 1005 (skip-chars-forward " \t;")))
1010 (setq result (nreverse result)))) 1006 (setq result (nreverse result))))
1011 1007
@@ -1026,10 +1022,7 @@ If `enable-local-variables' is nil, this function does not check for a
1026 (y-or-n-p (format "Set local variables as specified in -*- line of %s? " 1022 (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
1027 (file-name-nondirectory buffer-file-name))))))) 1023 (file-name-nondirectory buffer-file-name)))))))
1028 (while result 1024 (while result
1029 (let ((key (car (car result))) 1025 (hack-one-local-variable (car (car result)) (cdr (car result)))
1030 (val (cdr (car result))))
1031 (or (eq key 'mode)
1032 (hack-one-local-variable key val)))
1033 (setq result (cdr result))))))) 1026 (setq result (cdr result)))))))
1034 1027
1035(defun hack-local-variables () 1028(defun hack-local-variables ()