aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-02-04 23:33:53 +0000
committerKim F. Storm2006-02-04 23:33:53 +0000
commit5cce080e9551156ad58ca9391a69734777f3a07e (patch)
treeee0167cd1e4406cbdad646825ad250c7b43ea67c
parent533919895efd86a2bfdd7d3fb573bbf50e369a94 (diff)
downloademacs-5cce080e9551156ad58ca9391a69734777f3a07e.tar.gz
emacs-5cce080e9551156ad58ca9391a69734777f3a07e.zip
(magic-mode-regexp-match-limit): New defvar.
(set-auto-mode): Use it to limit magic-mode-alist matching.
-rw-r--r--lisp/files.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 112056e4f9e..969c2d93659 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2047,6 +2047,9 @@ to decide the buffer's major mode.
2047If FUNCTION is nil, then it is not called. (That is a way of saying 2047If FUNCTION is nil, then it is not called. (That is a way of saying
2048\"allow `auto-mode-alist' to decide for these files.\")") 2048\"allow `auto-mode-alist' to decide for these files.\")")
2049 2049
2050(defvar magic-mode-regexp-match-limit 4000
2051 "Upper limit on `magic-mode-alist' regexp matches.")
2052
2050(defun set-auto-mode (&optional keep-mode-if-same) 2053(defun set-auto-mode (&optional keep-mode-if-same)
2051 "Select major mode appropriate for current buffer. 2054 "Select major mode appropriate for current buffer.
2052 2055
@@ -2120,9 +2123,13 @@ only set the major mode, if that would change it."
2120 (unless done 2123 (unless done
2121 (if (setq done (save-excursion 2124 (if (setq done (save-excursion
2122 (goto-char (point-min)) 2125 (goto-char (point-min))
2123 (assoc-default nil magic-mode-alist 2126 (save-restriction
2124 (lambda (re dummy) 2127 (narrow-to-region (point-min)
2125 (looking-at re))))) 2128 (min (point-max)
2129 (+ (point-min) magic-mode-regexp-match-limit)))
2130 (assoc-default nil magic-mode-alist
2131 (lambda (re dummy)
2132 (looking-at re))))))
2126 (set-auto-mode-0 done keep-mode-if-same) 2133 (set-auto-mode-0 done keep-mode-if-same)
2127 ;; Compare the filename against the entries in auto-mode-alist. 2134 ;; Compare the filename against the entries in auto-mode-alist.
2128 (if buffer-file-name 2135 (if buffer-file-name