diff options
| author | Jim Blandy | 1992-02-27 23:17:44 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-02-27 23:17:44 +0000 |
| commit | 7b3f3dc2bba80dcb204f76b8fbf3d7d242b609d0 (patch) | |
| tree | df2479c227bf5092a5438db6fba3a4f11007fb7c | |
| parent | 80dcc39079dbbcdbbe529090696d85b2655cb031 (diff) | |
| download | emacs-7b3f3dc2bba80dcb204f76b8fbf3d7d242b609d0.tar.gz emacs-7b3f3dc2bba80dcb204f76b8fbf3d7d242b609d0.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/files.el | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/lisp/files.el b/lisp/files.el index 2deba0db011..ed2882eddeb 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -450,26 +450,86 @@ run `normal-mode' explicitly." | |||
| 450 | (error (message "File mode specification error: %s" | 450 | (error (message "File mode specification error: %s" |
| 451 | (prin1-to-string err)))) | 451 | (prin1-to-string err)))) |
| 452 | (condition-case err | 452 | (condition-case err |
| 453 | (hack-local-variables (not find-file)) | 453 | (let ((enable-local-variables (or (not find-file) |
| 454 | enable-local-variables))) | ||
| 455 | (hack-local-variables)) | ||
| 454 | (error (message "File local-variables error: %s" | 456 | (error (message "File local-variables error: %s" |
| 455 | (prin1-to-string err))))) | 457 | (prin1-to-string err))))) |
| 456 | 458 | ||
| 457 | ;(defvar auto-mode-alist ...) now in loaddefs.el | 459 | (defvar auto-mode-alist (mapcar 'purecopy |
| 460 | '(("\\.text\\'" . text-mode) | ||
| 461 | ("\\.c\\'" . c-mode) | ||
| 462 | ("\\.h\\'" . c-mode) | ||
| 463 | ("\\.tex\\'" . TeX-mode) | ||
| 464 | ("\\.ltx\\'" . LaTeX-mode) | ||
| 465 | ("\\.el\\'" . emacs-lisp-mode) | ||
| 466 | ("\\.mm\\'" . nroff-mode) | ||
| 467 | ("\\.me\\'" . nroff-mode) | ||
| 468 | ("\\.[12345678]\\'" . nroff-mode) | ||
| 469 | ("\\.scm\\'" . scheme-mode) | ||
| 470 | ("\\.l\\'" . lisp-mode) | ||
| 471 | ("\\.lisp\\'" . lisp-mode) | ||
| 472 | ("\\.f\\'" . fortran-mode) | ||
| 473 | ("\\.for\\'" . fortran-mode) | ||
| 474 | ("\\.mss\\'" . scribe-mode) | ||
| 475 | ("\\.pl\\'" . prolog-mode) | ||
| 476 | ("\\.cc\\'" . c++-mode) | ||
| 477 | ("\\.C\\'" . c++-mode) | ||
| 478 | ;;; Less common extensions come here | ||
| 479 | ;;; so more common ones above are found faster. | ||
| 480 | ("\\.s\\'" . asm-mode) | ||
| 481 | ("ChangeLog\\'" . change-log-mode) | ||
| 482 | ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) | ||
| 483 | ("\\.TeX\\'" . TeX-mode) | ||
| 484 | ("\\.sty\\'" . LaTeX-mode) | ||
| 485 | ("\\.bbl\\'" . LaTeX-mode) | ||
| 486 | ("\\.bib\\'" . bibtex-mode) | ||
| 487 | ("\\.article\\'" . text-mode) | ||
| 488 | ("\\.letter\\'" . text-mode) | ||
| 489 | ("\\.texinfo\\'" . texinfo-mode) | ||
| 490 | ("\\.lsp\\'" . lisp-mode) | ||
| 491 | ("\\.awk\\'" . awk-mode) | ||
| 492 | ("\\.prolog\\'" . prolog-mode) | ||
| 493 | ;; Mailer puts message to be edited in | ||
| 494 | ;; /tmp/Re.... or Message | ||
| 495 | ("^/tmp/Re" . text-mode) | ||
| 496 | ("/Message[0-9]*\\'" . text-mode) | ||
| 497 | ;; some news reader is reported to use this | ||
| 498 | ("^/tmp/fol/" . text-mode) | ||
| 499 | ("\\.y\\'" . c-mode) | ||
| 500 | ("\\.oak\\'" . scheme-mode) | ||
| 501 | ("\\.scm.[0-9]*\\'" . scheme-mode) | ||
| 502 | ;; .emacs following a directory delimiter | ||
| 503 | ;; in either Unix or VMS syntax. | ||
| 504 | ("[]>:/]\\..*emacs\\'" . emacs-lisp-mode) | ||
| 505 | ("\\.ml\\'" . lisp-mode))) | ||
| 506 | "\ | ||
| 507 | Alist of filename patterns vs corresponding major mode functions. | ||
| 508 | Each element looks like (REGEXP . FUNCTION). | ||
| 509 | Visiting a file whose name matches REGEXP causes FUNCTION to be called.") | ||
| 510 | |||
| 458 | (defun set-auto-mode () | 511 | (defun set-auto-mode () |
| 459 | "Select major mode appropriate for current buffer. | 512 | "Select major mode appropriate for current buffer. |
| 460 | May base decision on visited file name (see variable `auto-mode-alist') | 513 | This checks for a -*- mode tag in the buffer's text, or |
| 461 | or on buffer contents (-*- line or local variables spec), but does not look | 514 | compares the filename against the entries in auto-mode-alist. It does |
| 462 | for the \"mode:\" local variable. For that, use `hack-local-variables'." | 515 | not check for the \"mode:\" local variable in the Local Variables |
| 516 | section of the file; for that, use `hack-local-variables'. | ||
| 517 | |||
| 518 | If enable-local-variables is nil, this function will not check for a | ||
| 519 | -*- mode tag." | ||
| 463 | ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- | 520 | ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- |
| 464 | (let (beg end mode) | 521 | (let (beg end mode) |
| 465 | (save-excursion | 522 | (save-excursion |
| 466 | (goto-char (point-min)) | 523 | (goto-char (point-min)) |
| 467 | (skip-chars-forward " \t\n") | 524 | (skip-chars-forward " \t\n") |
| 468 | (if (and (search-forward "-*-" (save-excursion (end-of-line) (point)) t) | 525 | (if (and enable-local-variables |
| 526 | (search-forward "-*-" (save-excursion (end-of-line) (point)) t) | ||
| 469 | (progn | 527 | (progn |
| 470 | (skip-chars-forward " \t") | 528 | (skip-chars-forward " \t") |
| 471 | (setq beg (point)) | 529 | (setq beg (point)) |
| 472 | (search-forward "-*-" (save-excursion (end-of-line) (point)) t)) | 530 | (search-forward "-*-" |
| 531 | (save-excursion (end-of-line) (point)) | ||
| 532 | t)) | ||
| 473 | (progn | 533 | (progn |
| 474 | (forward-char -3) | 534 | (forward-char -3) |
| 475 | (skip-chars-backward " \t") | 535 | (skip-chars-backward " \t") |
| @@ -502,7 +562,7 @@ for the \"mode:\" local variable. For that, use `hack-local-variables'." | |||
| 502 | (setq alist (cdr alist))))))) | 562 | (setq alist (cdr alist))))))) |
| 503 | (if mode (funcall mode)))) | 563 | (if mode (funcall mode)))) |
| 504 | 564 | ||
| 505 | (defun hack-local-variables (&optional force) | 565 | (defun hack-local-variables () |
| 506 | "Parse (and bind or evaluate as appropriate) any local variables | 566 | "Parse (and bind or evaluate as appropriate) any local variables |
| 507 | for current buffer." | 567 | for current buffer." |
| 508 | ;; Look for "Local variables:" line in last page. | 568 | ;; Look for "Local variables:" line in last page. |
| @@ -511,7 +571,7 @@ for current buffer." | |||
| 511 | (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) | 571 | (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |
| 512 | (if (let ((case-fold-search t)) | 572 | (if (let ((case-fold-search t)) |
| 513 | (and (search-forward "Local Variables:" nil t) | 573 | (and (search-forward "Local Variables:" nil t) |
| 514 | (or force (eq enable-local-variables t) | 574 | (or (eq enable-local-variables t) |
| 515 | (and enable-local-variables | 575 | (and enable-local-variables |
| 516 | (save-window-excursion | 576 | (save-window-excursion |
| 517 | (switch-to-buffer (current-buffer)) | 577 | (switch-to-buffer (current-buffer)) |
| @@ -533,6 +593,7 @@ for current buffer." | |||
| 533 | (setq prefix | 593 | (setq prefix |
| 534 | (buffer-substring (point) | 594 | (buffer-substring (point) |
| 535 | (progn (beginning-of-line) (point))))) | 595 | (progn (beginning-of-line) (point))))) |
| 596 | |||
| 536 | (if prefix (setq prefixlen (length prefix) | 597 | (if prefix (setq prefixlen (length prefix) |
| 537 | prefix (regexp-quote prefix))) | 598 | prefix (regexp-quote prefix))) |
| 538 | (if suffix (setq suffix (concat (regexp-quote suffix) "$"))) | 599 | (if suffix (setq suffix (concat (regexp-quote suffix) "$"))) |
| @@ -570,7 +631,7 @@ for current buffer." | |||
| 570 | (funcall (intern (concat (downcase (symbol-name val)) | 631 | (funcall (intern (concat (downcase (symbol-name val)) |
| 571 | "-mode")))) | 632 | "-mode")))) |
| 572 | ((eq var 'eval) | 633 | ((eq var 'eval) |
| 573 | (if (or (and ignore-local-eval (not force)) | 634 | (if (or ignore-local-eval |
| 574 | (string= (user-login-name) "root")) | 635 | (string= (user-login-name) "root")) |
| 575 | (message "Ignoring `eval:' in file's local variables") | 636 | (message "Ignoring `eval:' in file's local variables") |
| 576 | (save-excursion (eval val)))) | 637 | (save-excursion (eval val)))) |