Function: so-long-mode-downgrade

so-long-mode-downgrade is a byte-compiled function defined in so-long.el.gz.

Signature

(so-long-mode-downgrade &optional MODE)

Documentation

The default value for so-long-file-local-mode-function.

A buffer-local "downgrade" from so-long-mode to so-long-minor-mode(var)/so-long-minor-mode(fun).

When so-long-function(var)/so-long-function(fun) is set to so-long-mode, then we change it to turn-on-so-long-minor-mode instead -- retaining the file-local major mode, but still doing everything else that so-long-mode would have done. so-long-revert-function(var)/so-long-revert-function(fun) is likewise updated.

If so-long-function(var)/so-long-function(fun) has any value other than so-long-mode, we do nothing, as if so-long-file-local-mode-function was nil.

We also do nothing if MODE (the file-local mode) has the value so-long-mode, because we do not want to downgrade the major mode in that scenario.

Source Code

;; Defined in /usr/src/emacs/lisp/so-long.el.gz
(defun so-long-mode-downgrade (&optional mode)
  "The default value for `so-long-file-local-mode-function'.

A buffer-local \"downgrade\" from `so-long-mode' to `so-long-minor-mode'.

When `so-long-function' is set to `so-long-mode', then we change it to
`turn-on-so-long-minor-mode' instead -- retaining the file-local major
mode, but still doing everything else that `so-long-mode' would have done.
`so-long-revert-function' is likewise updated.

If `so-long-function' has any value other than `so-long-mode', we do nothing,
as if `so-long-file-local-mode-function' was nil.

We also do nothing if MODE (the file-local mode) has the value `so-long-mode',
because we do not want to downgrade the major mode in that scenario."
  ;; Do nothing if the file-local mode was `so-long-mode'.
  (unless (provided-mode-derived-p mode 'so-long-mode)
    ;; Act only if `so-long-mode' would be enabled by the current action.
    (when (and (symbolp (so-long-function))
               (provided-mode-derived-p (so-long-function) 'so-long-mode))
      ;; Downgrade from `so-long-mode' to the `so-long-minor-mode' behavior.
      (setq so-long-function 'turn-on-so-long-minor-mode
            so-long-revert-function 'turn-off-so-long-minor-mode))))