From 9ee45b2cc114ab555e45d9f030747b9c7e5a7a89 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 7 Oct 2000 03:05:14 +0000 Subject: [PATCH] (set-auto-mode): Ignore unknown -*- mode -*- rather than raise an error. This way it can still defaults to a sane value. --- lisp/ChangeLog | 7 +++++-- lisp/files.el | 36 +++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5ef7457d88b..72e2fb27d15 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2000-10-06 Stefan Monnier + * files.el (set-auto-mode): Ignore unknown -*- mode -*- rather than + raise an error. This way it can still defaults to a sane value. + * startup.el (fancy-splash-screens): Use local rather than global map. Don't use `update-menu-bindings' any more. Get rid of assumptions about keymap representation. @@ -38,8 +41,8 @@ (tex-font-lock-keywords-1): Remove. (font-lock-turn-on-thing-lock): Use jit-lock-register. (font-lock-turn-off-thing-lock): Use jit-lock-unregister. - (font-lock-default-fontify-region): Expand beg..end correctly - when just following a multiline region. + (font-lock-default-fontify-region): + Expand beg..end correctly when just following a multiline region. (font-lock-fontify-anchored-keywords): Include the anchor text as part of the multiline. diff --git a/lisp/files.el b/lisp/files.el index 14a14c89cca..6fc452545e5 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -472,7 +472,7 @@ patterns and to guarantee valid names." (defvar cd-path nil "Value of the CDPATH environment variable, as a list. -Not actually set up until the first time you you use it.") +Not actually set up until the first time you use it.") (defun parse-colon-path (cd-path) "Explode a colon-separated search path into a list of directory names. @@ -1386,10 +1386,6 @@ in that case, this function acts as if `enable-local-variables' were t." ("\\.ms\\'" . nroff-mode) ("\\.man\\'" . nroff-mode) ("\\.\\(u?lpc\\|pike\\|pmod\\)\\'" . pike-mode) -;;; The following should come after the ChangeLog pattern -;;; for the sake of ChangeLog.1, etc. -;;; and after the .scm.[0-9] pattern too. - ("\\.[12345678]\\'" . nroff-mode) ("\\.TeX\\'" . tex-mode) ("\\.sty\\'" . latex-mode) ("\\.cls\\'" . latex-mode) ;LaTeX 2e class @@ -1455,7 +1451,15 @@ in that case, this function acts as if `enable-local-variables' were t." ("configure\\.in\\'" . autoconf-mode) ("BROWSE\\'" . ebrowse-tree-mode) ("\\.ebrowse\\'" . ebrowse-tree-mode) - ("#\\*mail\\*" . mail-mode))) + ("#\\*mail\\*" . mail-mode) + ;; Get rid of any trailing .n.m and try again. + ;; This is for files saved by cvs-merge that look like .#. + ;; or .#.- or VC's .~~ + ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t) +;;; The following should come after the ChangeLog pattern +;;; for the sake of ChangeLog.1, etc. +;;; and after the .scm.[0-9] and CVS' . patterns too. + ("\\.[12345678]\\'" . nroff-mode))) "Alist of filename patterns vs corresponding major mode functions. Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL). \(NON-NIL stands for anything that is not nil; the value does not matter.) @@ -1606,18 +1610,20 @@ and we don't even do that unless it would come from the file name." (forward-char -1) (goto-char end)) (skip-chars-backward " \t") - (setq modes (cons (intern (concat (downcase (buffer-substring beg (point))) "-mode")) - modes))) + (push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) + modes)) ;; Simple -*-MODE-*- case. - (setq modes (cons (intern (concat (downcase (buffer-substring beg end)) - "-mode")) - modes)))))) + (push (intern (concat (downcase (buffer-substring beg end)) + "-mode")) + modes))))) ;; If we found modes to use, invoke them now, ;; outside the save-excursion. - (when modes - (unless just-from-file-name - (mapc 'funcall (nreverse modes))) - (setq done t)) + (unless just-from-file-name + (dolist (mode (nreverse modes)) + (if (not (functionp mode)) + (message "Ignoring unknown mode `%s'" mode) + (setq done t) + (funcall mode)))) ;; If we didn't find a mode from a -*- line, try using the file name. (if (and (not done) buffer-file-name) (let ((name buffer-file-name) -- 2.39.2