Mercurial > emacs
comparison lisp/novice.el @ 16649:8a01398a26e6
(disabled-command-hook): Use `defvar' and add documentation string.
(disabled-command-hook): New option ! turns off disabled commands.
author | Erik Naggum <erik@naggum.no> |
---|---|
date | Mon, 09 Dec 1996 04:21:11 +0000 |
parents | 83f275dcd93a |
children | 6f45dc8d9d56 |
comparison
equal
deleted
inserted
replaced
16648:912ff9d36bb1 | 16649:8a01398a26e6 |
---|---|
34 ;; to handle any disabled command. | 34 ;; to handle any disabled command. |
35 ;; The command is found in this-command | 35 ;; The command is found in this-command |
36 ;; and the keys are returned by (this-command-keys). | 36 ;; and the keys are returned by (this-command-keys). |
37 | 37 |
38 ;;;###autoload | 38 ;;;###autoload |
39 (setq disabled-command-hook 'disabled-command-hook) | 39 (defvar disabled-command-hook 'disabled-command-hook |
40 "Function to call to handle disabled commands. | |
41 If nil, the feature is disabled, i.e., all commands work normally.") | |
40 | 42 |
41 ;;;###autoload | 43 ;;;###autoload |
42 (defun disabled-command-hook (&rest ignore) | 44 (defun disabled-command-hook (&rest ignore) |
43 (let (char) | 45 (let (char) |
44 (save-window-excursion | 46 (save-window-excursion |
71 (if (search-forward "\n\n" nil t) | 73 (if (search-forward "\n\n" nil t) |
72 (delete-region (1- (point)) (point-max)) | 74 (delete-region (1- (point)) (point-max)) |
73 (goto-char (point-max)))) | 75 (goto-char (point-max)))) |
74 (princ "\n\n") | 76 (princ "\n\n") |
75 (princ "You can now type | 77 (princ "You can now type |
76 Space to try the command just this once, | 78 Space to try the command just this once, but leave it disabled, |
77 but leave it disabled, | |
78 Y to try it and enable it (no questions if you use it again), | 79 Y to try it and enable it (no questions if you use it again), |
80 ! to try it and enable all commands in this session, or | |
79 N to do nothing (command remains disabled).") | 81 N to do nothing (command remains disabled).") |
80 (save-excursion | 82 (save-excursion |
81 (set-buffer standard-output) | 83 (set-buffer standard-output) |
82 (help-mode))) | 84 (help-mode))) |
83 (message "Type y, n or Space: ") | 85 (message "Type y, n, ! or Space: ") |
84 (let ((cursor-in-echo-area t)) | 86 (let ((cursor-in-echo-area t)) |
85 (while (not (memq (setq char (downcase (read-char))) | 87 (while (not (memq (setq char (downcase (read-char))) |
86 '(? ?y ?n))) | 88 '(?! ? ?y ?n))) |
87 (ding) | 89 (ding) |
88 (message "Please type y, n or Space: ")))) | 90 (message "Please type y, n, ! or Space: ")))) |
91 (if (= char ?!) | |
92 (setq disabled-command-hook nil)) | |
89 (if (= char ?y) | 93 (if (= char ?y) |
90 (if (and user-init-file | 94 (if (and user-init-file |
91 (not (string= "" user-init-file)) | 95 (not (string= "" user-init-file)) |
92 (y-or-n-p "Enable command for future editing sessions also? ")) | 96 (y-or-n-p "Enable command for future editing sessions also? ")) |
93 (enable-command this-command) | 97 (enable-command this-command) |