emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/files.el


From: Kim F. Storm
Subject: [Emacs-diffs] Changes to emacs/lisp/files.el
Date: Sat, 04 Feb 2006 23:33:53 +0000

Index: emacs/lisp/files.el
diff -u emacs/lisp/files.el:1.802 emacs/lisp/files.el:1.803
--- emacs/lisp/files.el:1.802   Thu Jan 26 17:55:04 2006
+++ emacs/lisp/files.el Sat Feb  4 23:33:53 2006
@@ -2047,6 +2047,9 @@
 If FUNCTION is nil, then it is not called.  (That is a way of saying
 \"allow `auto-mode-alist' to decide for these files.\")")
 
+(defvar magic-mode-regexp-match-limit 4000
+  "Upper limit on `magic-mode-alist' regexp matches.")
+
 (defun set-auto-mode (&optional keep-mode-if-same)
   "Select major mode appropriate for current buffer.
 
@@ -2120,9 +2123,13 @@
     (unless done
       (if (setq done (save-excursion
                       (goto-char (point-min))
-                      (assoc-default nil magic-mode-alist
-                                     (lambda (re dummy)
-                                       (looking-at re)))))
+                      (save-restriction
+                        (narrow-to-region (point-min)
+                                          (min (point-max)
+                                               (+ (point-min) 
magic-mode-regexp-match-limit)))
+                        (assoc-default nil magic-mode-alist
+                                       (lambda (re dummy)
+                                         (looking-at re))))))
          (set-auto-mode-0 done keep-mode-if-same)
        ;; Compare the filename against the entries in auto-mode-alist.
        (if buffer-file-name




reply via email to

[Prev in Thread] Current Thread [Next in Thread]