Download
(when (>= emacs-major-version 20) (require 'novice))
(require 'thingatpt nil t)
(when (and (require 'thingatpt+ nil t)
(fboundp 'tap-put-thing-at-point-props))
(tap-define-aliases-wo-prefix)
(tap-put-thing-at-point-props))
(if (< emacs-major-version 21)
(defun enable-command (command)
"Allow COMMAND to be invoked without confirmation from now on.
Your `~/.emacs' file is altered so that this applies also to future
sessions. See command `\\[disable-command]'."
(interactive
(let ((symb (cond ((fboundp 'symbol-nearest-point) (symbol-nearest-point))
((fboundp 'symbol-at-point) (symbol-at-point))
(t nil)))
(enable-recursive-minibuffers t))
(list (intern (completing-read "Enable command: " obarray 'commandp nil
nil nil (symbol-name symb) t)))))
(put command 'disabled nil)
(with-current-buffer (find-file-noselect (substitute-in-file-name user-init-file))
(goto-char (point-min))
(when (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region (progn (beginning-of-line) (point))
(progn (forward-line 1) (point))))
(goto-char (point-max))
(insert "\n(put '" (symbol-name command) " 'disabled nil)\n")
(save-buffer)))
(defun enable-command (command)
"Allow COMMAND to be executed without special confirmation from now on.
The user's .emacs file is altered so that this will apply
to future sessions."
(interactive
(let ((symb (cond ((fboundp 'symbol-nearest-point) (symbol-nearest-point))
((fboundp 'symbol-at-point) (symbol-at-point))
(t nil)))
(enable-recursive-minibuffers t))
(list (intern (completing-read "Enable command: " obarray 'commandp nil
nil nil (symbol-name symb) t)))))
(put command 'disabled nil)
(let ((init-file user-init-file)
(default-init-file
(if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
(when (null init-file)
(if (or (file-exists-p default-init-file)
(and (eq system-type 'windows-nt)
(file-exists-p "~/_emacs")))
(error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
(setq init-file default-init-file)
(if (and (not (file-exists-p init-file))
(eq system-type 'windows-nt)
(file-exists-p "~/_emacs"))
(setq init-file "~/_emacs")))
(with-current-buffer (find-file-noselect (substitute-in-file-name init-file))
(goto-char (point-min))
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region (progn (beginning-of-line) (point))
(progn (forward-line 1) (point))))
(goto-char (point-max))
(insert "\n(put '" (symbol-name command) " 'disabled nil)\n")
(save-buffer)))))
(if (< emacs-major-version 21)
(defun disable-command (command)
"Require confirmation to execute COMMAND from now on.
Your `~/.emacs' file is altered so that this applies also to future
sessions. See command `\\[enable-command]'."
(interactive
(let ((symb (cond ((fboundp 'symbol-nearest-point) (symbol-nearest-point))
((fboundp 'symbol-at-point) (symbol-at-point))
(t nil)))
(enable-recursive-minibuffers t))
(list (intern (completing-read "Disable command: " obarray 'commandp nil
nil nil (symbol-name symb) t)))))
(unless (commandp command) (error "Invalid command name `%s'" command))
(put command 'disabled t)
(with-current-buffer (find-file-noselect (substitute-in-file-name user-init-file))
(goto-char (point-min))
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region (progn (beginning-of-line) (point))
(progn (forward-line 1) (point))))
(goto-char (point-max))
(insert "\n(put '" (symbol-name command) " 'disabled t)\n")
(save-buffer)))
(defun disable-command (command)
"Require special confirmation to execute COMMAND from now on.
The user's .emacs file is altered so that this will apply
to future sessions."
(interactive
(let ((symb (cond ((fboundp 'symbol-nearest-point) (symbol-nearest-point))
((fboundp 'symbol-at-point) (symbol-at-point))
(t nil)))
(enable-recursive-minibuffers t))
(list (intern (completing-read "Disable command: " obarray 'commandp nil
nil nil (symbol-name symb) t)))))
(if (not (commandp command))
(error "Invalid command name `%s'" command))
(put command 'disabled t)
(let ((init-file user-init-file)
(default-init-file
(if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
(when (null init-file)
(if (or (file-exists-p default-init-file)
(and (eq system-type 'windows-nt)
(file-exists-p "~/_emacs")))
(error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
(setq init-file default-init-file)
(if (and (not (file-exists-p init-file))
(eq system-type 'windows-nt)
(file-exists-p "~/_emacs"))
(setq init-file "~/_emacs")))
(with-current-buffer (find-file-noselect (substitute-in-file-name init-file))
(goto-char (point-min))
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region (progn (beginning-of-line) (point))
(progn (forward-line 1) (point))))
(goto-char (point-max))
(insert "\n(put '" (symbol-name command) " 'disabled t)\n")
(save-buffer)))))
(provide 'novice+)