comparison lisp/files.el @ 32240:f2a40beeddaa

(set-auto-mode): Ignore unknown -*- mode -*- rather than raise an error. This way it can still defaults to a sane value.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 07 Oct 2000 03:04:02 +0000
parents 8a30e7f82c80
children e3c97d8f7a7e
comparison
equal deleted inserted replaced
32239:9f5f8cb6cb32 32240:f2a40beeddaa
470 (interactive nil) 470 (interactive nil)
471 (message "Directory %s" default-directory)) 471 (message "Directory %s" default-directory))
472 472
473 (defvar cd-path nil 473 (defvar cd-path nil
474 "Value of the CDPATH environment variable, as a list. 474 "Value of the CDPATH environment variable, as a list.
475 Not actually set up until the first time you you use it.") 475 Not actually set up until the first time you use it.")
476 476
477 (defun parse-colon-path (cd-path) 477 (defun parse-colon-path (cd-path)
478 "Explode a colon-separated search path into a list of directory names. 478 "Explode a colon-separated search path into a list of directory names.
479 \(For values of `colon' equal to `path-separator'.)" 479 \(For values of `colon' equal to `path-separator'.)"
480 ;; We could use split-string here. 480 ;; We could use split-string here.
1384 ("\\.mm\\'" . nroff-mode) 1384 ("\\.mm\\'" . nroff-mode)
1385 ("\\.me\\'" . nroff-mode) 1385 ("\\.me\\'" . nroff-mode)
1386 ("\\.ms\\'" . nroff-mode) 1386 ("\\.ms\\'" . nroff-mode)
1387 ("\\.man\\'" . nroff-mode) 1387 ("\\.man\\'" . nroff-mode)
1388 ("\\.\\(u?lpc\\|pike\\|pmod\\)\\'" . pike-mode) 1388 ("\\.\\(u?lpc\\|pike\\|pmod\\)\\'" . pike-mode)
1389 ;;; The following should come after the ChangeLog pattern
1390 ;;; for the sake of ChangeLog.1, etc.
1391 ;;; and after the .scm.[0-9] pattern too.
1392 ("\\.[12345678]\\'" . nroff-mode)
1393 ("\\.TeX\\'" . tex-mode) 1389 ("\\.TeX\\'" . tex-mode)
1394 ("\\.sty\\'" . latex-mode) 1390 ("\\.sty\\'" . latex-mode)
1395 ("\\.cls\\'" . latex-mode) ;LaTeX 2e class 1391 ("\\.cls\\'" . latex-mode) ;LaTeX 2e class
1396 ("\\.clo\\'" . latex-mode) ;LaTeX 2e class option 1392 ("\\.clo\\'" . latex-mode) ;LaTeX 2e class option
1397 ("\\.bbl\\'" . latex-mode) 1393 ("\\.bbl\\'" . latex-mode)
1453 ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) 1449 ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
1454 ("\\.[eE]?[pP][sS]$" . ps-mode) 1450 ("\\.[eE]?[pP][sS]$" . ps-mode)
1455 ("configure\\.in\\'" . autoconf-mode) 1451 ("configure\\.in\\'" . autoconf-mode)
1456 ("BROWSE\\'" . ebrowse-tree-mode) 1452 ("BROWSE\\'" . ebrowse-tree-mode)
1457 ("\\.ebrowse\\'" . ebrowse-tree-mode) 1453 ("\\.ebrowse\\'" . ebrowse-tree-mode)
1458 ("#\\*mail\\*" . mail-mode))) 1454 ("#\\*mail\\*" . mail-mode)
1455 ;; Get rid of any trailing .n.m and try again.
1456 ;; This is for files saved by cvs-merge that look like .#<file>.<rev>
1457 ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~
1458 ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
1459 ;;; The following should come after the ChangeLog pattern
1460 ;;; for the sake of ChangeLog.1, etc.
1461 ;;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too.
1462 ("\\.[12345678]\\'" . nroff-mode)))
1459 "Alist of filename patterns vs corresponding major mode functions. 1463 "Alist of filename patterns vs corresponding major mode functions.
1460 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL). 1464 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
1461 \(NON-NIL stands for anything that is not nil; the value does not matter.) 1465 \(NON-NIL stands for anything that is not nil; the value does not matter.)
1462 Visiting a file whose name matches REGEXP specifies FUNCTION as the 1466 Visiting a file whose name matches REGEXP specifies FUNCTION as the
1463 mode function to use. FUNCTION will be called, unless it is nil. 1467 mode function to use. FUNCTION will be called, unless it is nil.
1604 (setq beg (point)) 1608 (setq beg (point))
1605 (if (search-forward ";" end t) 1609 (if (search-forward ";" end t)
1606 (forward-char -1) 1610 (forward-char -1)
1607 (goto-char end)) 1611 (goto-char end))
1608 (skip-chars-backward " \t") 1612 (skip-chars-backward " \t")
1609 (setq modes (cons (intern (concat (downcase (buffer-substring beg (point))) "-mode")) 1613 (push (intern (concat (downcase (buffer-substring beg (point))) "-mode"))
1610 modes))) 1614 modes))
1611 ;; Simple -*-MODE-*- case. 1615 ;; Simple -*-MODE-*- case.
1612 (setq modes (cons (intern (concat (downcase (buffer-substring beg end)) 1616 (push (intern (concat (downcase (buffer-substring beg end))
1613 "-mode")) 1617 "-mode"))
1614 modes)))))) 1618 modes)))))
1615 ;; If we found modes to use, invoke them now, 1619 ;; If we found modes to use, invoke them now,
1616 ;; outside the save-excursion. 1620 ;; outside the save-excursion.
1617 (when modes 1621 (unless just-from-file-name
1618 (unless just-from-file-name 1622 (dolist (mode (nreverse modes))
1619 (mapc 'funcall (nreverse modes))) 1623 (if (not (functionp mode))
1620 (setq done t)) 1624 (message "Ignoring unknown mode `%s'" mode)
1625 (setq done t)
1626 (funcall mode))))
1621 ;; If we didn't find a mode from a -*- line, try using the file name. 1627 ;; If we didn't find a mode from a -*- line, try using the file name.
1622 (if (and (not done) buffer-file-name) 1628 (if (and (not done) buffer-file-name)
1623 (let ((name buffer-file-name) 1629 (let ((name buffer-file-name)
1624 (keep-going t)) 1630 (keep-going t))
1625 ;; Remove backup-suffixes from file name. 1631 ;; Remove backup-suffixes from file name.