aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/files.el108
2 files changed, 62 insertions, 52 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6b83f7c1c77..a62a846d172 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-09-18 Chong Yidong <cyd@stupidchicken.com>
2
3 * files.el (inhibit-first-line-modes-regexps): Add image files.
4 (hack-local-variables-prop-line): Return nil for malformed
5 prop-lines (Bug#9044).
6
12011-09-18 Michael Albinus <michael.albinus@gmx.de> 72011-09-18 Michael Albinus <michael.albinus@gmx.de>
2 8
3 * net/tramp.el (top): Don't require 'shell. 9 * net/tramp.el (top): Don't require 'shell.
diff --git a/lisp/files.el b/lisp/files.el
index 5ca9af6783d..b29c0596d7b 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2461,7 +2461,9 @@ of a script, mode MODE is enabled.
2461 2461
2462See also `auto-mode-alist'.") 2462See also `auto-mode-alist'.")
2463 2463
2464(defvar inhibit-first-line-modes-regexps (mapcar 'purecopy '("\\.tar\\'" "\\.tgz\\'")) 2464(defvar inhibit-first-line-modes-regexps
2465 (mapcar 'purecopy '("\\.tar\\'" "\\.tgz\\'" "\\.tiff?\\'"
2466 "\\.gif\\'" "\\.png\\'" "\\.jpe?g\\'"))
2465 "List of regexps; if one matches a file name, don't look for `-*-'.") 2467 "List of regexps; if one matches a file name, don't look for `-*-'.")
2466 2468
2467(defvar inhibit-first-line-modes-suffixes nil 2469(defvar inhibit-first-line-modes-suffixes nil
@@ -2952,60 +2954,62 @@ Returns an alist of elements (VAR . VAL), where VAR is a variable
2952and VAL is the specified value. Ignores any specification for 2954and VAL is the specified value. Ignores any specification for
2953`mode:' and `coding:' (which should have already been handled 2955`mode:' and `coding:' (which should have already been handled
2954by `set-auto-mode' and `set-auto-coding', respectively). 2956by `set-auto-mode' and `set-auto-coding', respectively).
2955Throws an error if the -*- line is malformed. 2957Return nil if the -*- line is malformed.
2956 2958
2957If MODE-ONLY is non-nil, just returns the symbol specifying the 2959If MODE-ONLY is non-nil, just returns the symbol specifying the
2958mode, if there is one, otherwise nil." 2960mode, if there is one, otherwise nil."
2959 (save-excursion 2961 (catch 'malformed-line
2960 (goto-char (point-min)) 2962 (save-excursion
2961 (let ((end (set-auto-mode-1)) 2963 (goto-char (point-min))
2962 result) 2964 (let ((end (set-auto-mode-1))
2963 (cond ((not end) 2965 result)
2964 nil) 2966 (cond ((not end)
2965 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") 2967 nil)
2966 ;; Simple form: "-*- MODENAME -*-". 2968 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)")
2967 (if mode-only 2969 ;; Simple form: "-*- MODENAME -*-".
2968 (intern (concat (match-string 1) "-mode")))) 2970 (if mode-only
2969 (t 2971 (intern (concat (match-string 1) "-mode"))))
2970 ;; Hairy form: '-*-' [ <variable> ':' <value> ';' ]* '-*-' 2972 (t
2971 ;; (last ";" is optional). 2973 ;; Hairy form: '-*-' [ <variable> ':' <value> ';' ]* '-*-'
2972 ;; If MODE-ONLY, just check for `mode'. 2974 ;; (last ";" is optional).
2973 ;; Otherwise, parse the -*- line into the RESULT alist. 2975 ;; If MODE-ONLY, just check for `mode'.
2974 (while (and (or (not mode-only) 2976 ;; Otherwise, parse the -*- line into the RESULT alist.
2975 (not result)) 2977 (while (and (or (not mode-only)
2976 (< (point) end)) 2978 (not result))
2977 (or (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*") 2979 (< (point) end))
2978 (error "Malformed -*- line")) 2980 (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
2979 (goto-char (match-end 0)) 2981 (message "Malformed mode-line")
2980 ;; There used to be a downcase here, 2982 (throw 'malformed-line nil))
2981 ;; but the manual didn't say so, 2983 (goto-char (match-end 0))
2982 ;; and people want to set var names that aren't all lc. 2984 ;; There used to be a downcase here,
2983 (let* ((key (intern (match-string 1))) 2985 ;; but the manual didn't say so,
2984 (val (save-restriction 2986 ;; and people want to set var names that aren't all lc.
2985 (narrow-to-region (point) end) 2987 (let* ((key (intern (match-string 1)))
2986 (let ((read-circle nil)) 2988 (val (save-restriction
2987 (read (current-buffer))))) 2989 (narrow-to-region (point) end)
2988 ;; It is traditional to ignore 2990 (let ((read-circle nil))
2989 ;; case when checking for `mode' in set-auto-mode, 2991 (read (current-buffer)))))
2990 ;; so we must do that here as well. 2992 ;; It is traditional to ignore
2991 ;; That is inconsistent, but we're stuck with it. 2993 ;; case when checking for `mode' in set-auto-mode,
2992 ;; The same can be said for `coding' in set-auto-coding. 2994 ;; so we must do that here as well.
2993 (keyname (downcase (symbol-name key)))) 2995 ;; That is inconsistent, but we're stuck with it.
2994 (if mode-only 2996 ;; The same can be said for `coding' in set-auto-coding.
2995 (and (equal keyname "mode") 2997 (keyname (downcase (symbol-name key))))
2996 (setq result 2998 (if mode-only
2997 (intern (concat (downcase (symbol-name val)) 2999 (and (equal keyname "mode")
2998 "-mode")))) 3000 (setq result
2999 (or (equal keyname "coding") 3001 (intern (concat (downcase (symbol-name val))
3000 (condition-case nil 3002 "-mode"))))
3001 (push (cons (cond ((eq key 'eval) 'eval) 3003 (or (equal keyname "coding")
3002 ;; Downcase "Mode:". 3004 (condition-case nil
3003 ((equal keyname "mode") 'mode) 3005 (push (cons (cond ((eq key 'eval) 'eval)
3004 (t (indirect-variable key))) 3006 ;; Downcase "Mode:".
3005 val) result) 3007 ((equal keyname "mode") 'mode)
3006 (error nil)))) 3008 (t (indirect-variable key)))
3007 (skip-chars-forward " \t;"))) 3009 val) result)
3008 result))))) 3010 (error nil))))
3011 (skip-chars-forward " \t;")))
3012 result))))))
3009 3013
3010(defun hack-local-variables-filter (variables dir-name) 3014(defun hack-local-variables-filter (variables dir-name)
3011 "Filter local variable settings, querying the user if necessary. 3015 "Filter local variable settings, querying the user if necessary.