comparison lisp/files.el @ 83467:d04d8ccb3c41

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-41 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-42 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-43 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-44 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-45 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-46 Merge from erc--emacs--0 * emacs@sv.gnu.org/emacs--devo--0--patch-47 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-48 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-14 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-15 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-16 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-17 Merge from emacs--devo--0 git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-507
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 06 Feb 2006 18:44:57 +0000
parents 9b150bc96d33 6236390263d7
children b98066f4aa10
comparison
equal deleted inserted replaced
83466:9bec09743395 83467:d04d8ccb3c41
2045 to decide the buffer's major mode. 2045 to decide the buffer's major mode.
2046 2046
2047 If FUNCTION is nil, then it is not called. (That is a way of saying 2047 If 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
2053 This checks for a -*- mode tag in the buffer's text, checks the 2056 This checks for a -*- mode tag in the buffer's text, checks the
2054 interpreter that runs this file against `interpreter-mode-alist', 2057 interpreter that runs this file against `interpreter-mode-alist',
2118 (set-auto-mode-0 (cdr done) keep-mode-if-same))) 2121 (set-auto-mode-0 (cdr done) keep-mode-if-same)))
2119 ;; If we didn't, match the buffer beginning against magic-mode-alist. 2122 ;; If we didn't, match the buffer beginning against magic-mode-alist.
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
2129 (let ((name buffer-file-name)) 2136 (let ((name buffer-file-name))
2130 ;; Remove backup-suffixes from file name. 2137 ;; Remove backup-suffixes from file name.