Function: major-mode-restore

major-mode-restore is a byte-compiled function defined in subr.el.gz.

Signature

(major-mode-restore &optional AVOIDED-MODES)

Documentation

Restore major mode earlier suspended with major-mode-suspend.

If there was no earlier suspended major mode, then fallback to normal-mode, tho trying to avoid AVOIDED-MODES.

Probably introduced at or before Emacs version 27.1.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun major-mode-restore (&optional avoided-modes)
  "Restore major mode earlier suspended with `major-mode-suspend'.
If there was no earlier suspended major mode, then fallback to `normal-mode',
tho trying to avoid AVOIDED-MODES."
  (if major-mode--suspended
      (funcall (prog1 major-mode--suspended
                 (kill-local-variable 'major-mode--suspended)))
    (let ((auto-mode-alist
           (let ((alist (copy-sequence auto-mode-alist)))
             (dolist (mode avoided-modes)
               (setq alist (rassq-delete-all mode alist)))
             alist))
          (magic-fallback-mode-alist
           (let ((alist (copy-sequence magic-fallback-mode-alist)))
             (dolist (mode avoided-modes)
               (setq alist (rassq-delete-all mode alist)))
             alist)))
      (normal-mode))))