Function: set-auto-mode-0

set-auto-mode-0 is a byte-compiled function defined in files.el.gz.

Signature

(set-auto-mode-0 MODE &optional KEEP-MODE-IF-SAME)

Documentation

Apply MODE and return it.

If optional arg 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.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
;; 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 &optional keep-mode-if-same)
  "Apply MODE and return it.
If optional arg 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."
  (unless (and keep-mode-if-same
	       (eq (indirect-function mode)
		   (indirect-function major-mode)))
    (when mode
      (funcall mode)
      mode)))