Function: disabled-command-function

disabled-command-function is an autoloaded and byte-compiled function defined in novice.el.gz.

Signature

(disabled-command-function &optional CMD KEYS)

Source Code

;; Defined in /usr/src/emacs/lisp/novice.el.gz
;; It is ok here to assume that this-command is a symbol
;; because we won't get called otherwise.
;;;###autoload
(defun disabled-command-function (&optional cmd keys)
  (let* ((cmd (or cmd this-command))
         (keys (or keys (this-command-keys)))
         (help-string
          (concat
           (if (or (eq (aref keys 0)
                       (if (stringp keys)
                           (aref "\M-x" 0)
                         ?\M-x))
                   (and (>= (length keys) 2)
                        (eq (aref keys 0) meta-prefix-char)
                        (eq (aref keys 1) ?x)))
               (format "You have invoked the disabled command %s.\n" cmd)
             (substitute-command-keys
              (format "You have typed \\`%s', invoking disabled command %s.\n"
                      (key-description keys) cmd)))
           ;; Any special message saying why the command is disabled.
           (if (stringp (get cmd 'disabled))
               (get cmd 'disabled)
             (concat
              "It is disabled because new users often find it confusing.\n"
              (substitute-command-keys
               "Here's the first part of its description:\n\n")
              ;; Keep only the first paragraph of the documentation.
              (with-temp-buffer
                (insert (or (condition-case ()
                                (documentation cmd)
			      (error nil))
			    "<< not documented >>"))
                (goto-char (point-min))
                (when (search-forward "\n\n" nil t)
                  (delete-region (match-beginning 0) (point-max)))
                (indent-rigidly (point-min) (point-max) 3)
                (buffer-string))))
           (substitute-command-keys "\n
Do you want to use this command anyway?

You can now type:
 \\`n'    (also C-g) to cancel--don't try the command; it remains disabled.
 \\`y'    to enable the command (no questions if you use it again).
 \\`SPC'  to try the command just this once, but leave it disabled.
 \\`!'    to enable it and all the disabled commands for this session.")))
         (char
          ;; Note: the prompt produced from the choices below must not
          ;; overflow a single screen line, because otherwise it will
          ;; cause the mini-window to resize, which will in turn hide
          ;; the last line of the help text above: the code which fits
          ;; the window to the size of the help text does not expect
          ;; the mini-window to become taller.
          (car (read-multiple-choice "Use this command?"
                                     '((?n "no")
                                       (?y "yes")
                                       (?\s "(space bar) only once")
                                       (?! "use and enable all"))
                                     help-string
                                     "*Disabled Command*"))))
    (pcase char
      (?\C-g (setq quit-flag t))
      (?! (setq disabled-command-function nil))
      (?y
       (if (and user-init-file
                (not (string= "" user-init-file))
                (y-or-n-p "Enable command for future editing sessions also? "))
           (enable-command cmd)
         (put cmd 'disabled nil))))
    (unless (char-equal char ?n)
      (call-interactively cmd))))