[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/files.el
From: |
Daniel Pfeiffer |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/files.el |
Date: |
Thu, 28 Oct 2004 02:11:31 -0400 |
Index: emacs/lisp/files.el
diff -c emacs/lisp/files.el:1.714 emacs/lisp/files.el:1.715
*** emacs/lisp/files.el:1.714 Wed Oct 27 21:44:35 2004
--- emacs/lisp/files.el Thu Oct 28 06:05:17 2004
***************
*** 1857,1865 ****
If `enable-local-variables' is nil, this function does not check for a
-*- mode tag.
! If the optional argument KEEP-MODE-IF-SAME is non-nil,
! then we do not set anything but the major mode,
! and we don't even do that unless it would come from the file name."
;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
(let (end done mode modes xml)
;; Find a -*- mode tag
--- 1857,1864 ----
If `enable-local-variables' is nil, this function does not check for a
-*- mode tag.
! If the optional argument KEEP-MODE-IF-SAME is non-nil, then we
! only set the major mode, if that would change it."
;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
(let (end done mode modes xml)
;; Find a -*- mode tag
***************
*** 1891,1902 ****
modes))))
;; If we found modes to use, invoke them now, outside the save-excursion.
(if modes
! (dolist (mode (nreverse modes))
! (if (not (functionp mode))
! (message "Ignoring unknown mode `%s'" mode)
! (setq done t)
! (unless (if keep-mode-if-same (eq mode major-mode))
! (funcall mode))))
;; If we didn't, look for an interpreter specified in the first line.
;; As a special case, allow for things like "#!/bin/env perl", which
;; finds the interpreter anywhere in $PATH.
--- 1890,1902 ----
modes))))
;; If we found modes to use, invoke them now, outside the save-excursion.
(if modes
! (catch 'nop
! (dolist (mode (nreverse modes))
! (if (not (functionp mode))
! (message "Ignoring unknown mode `%s'" mode)
! (setq done t)
! (or (set-auto-mode-0 mode)
! (throw 'nop)))))
;; If we didn't, look for an interpreter specified in the first line.
;; As a special case, allow for things like "#!/bin/env perl", which
;; finds the interpreter anywhere in $PATH.
***************
*** 1910,1918 ****
done (assoc (file-name-nondirectory mode)
interpreter-mode-alist))
;; If we found an interpreter mode to use, invoke it now.
! (and done
! (not (if keep-mode-if-same (eq mode major-mode)))
! (funcall (cdr done))))
(if (and (not done) buffer-file-name)
(let ((name buffer-file-name))
;; Remove backup-suffixes from file name.
--- 1910,1916 ----
done (assoc (file-name-nondirectory mode)
interpreter-mode-alist))
;; If we found an interpreter mode to use, invoke it now.
! (if done (set-auto-mode-0 (cdr done))))
(if (and (not done) buffer-file-name)
(let ((name buffer-file-name))
;; Remove backup-suffixes from file name.
***************
*** 1930,1948 ****
(setq name)))
(when mode
(if xml (or (memq mode xml-based-modes)
! (setq mode 'sgml-mode))) ; alias to xml-mode for `eq'
! ;; When KEEP-MODE-IF-SAME is set, we are working on behalf of
! ;; set-visited-file-name. In that case, if the major mode
! ;; specified is the same one we already have, don't actually
! ;; reset it. We don't want to lose minor modes such as Font
! ;; Lock.
! (unless (if keep-mode-if-same (eq mode major-mode))
! (funcall mode))
(setq done t)))))
! (and (not done)
! xml
! (not (if keep-mode-if-same (eq 'sgml-mode major-mode)))
! (xml-mode))))
(defun set-auto-mode-1 ()
--- 1928,1958 ----
(setq name)))
(when mode
(if xml (or (memq mode xml-based-modes)
! (setq mode 'xml-mode)))
! (set-auto-mode-0 mode)
(setq done t)))))
! (and xml
! (not done)
! (set-auto-mode-0 'xml-mode))))
!
!
! ;; When `keep-mode-if-same' is set, we are working on behalf of
! ;; set-visited-file-name. In that case, if the major mode specified is the
! ;; same one we already have, don't actually reset it. We don't want to lose
! ;; minor modes such as Font Lock.
! (defun set-auto-mode-0 (mode)
! "Apply MODE and return it.
! If `keep-mode-if-same' is non-nil MODE is chased of any aliases and
! compared to current major mode. If they are the same, do nothing
! and return nil."
! (when keep-mode-if-same
! (while (symbolp (symbol-function mode))
! (setq mode (symbol-function mode)))
! (if (eq mode major-mode)
! (setq mode)))
! (when mode
! (funcall mode)
! mode))
(defun set-auto-mode-1 ()