diff options
| author | Chong Yidong | 2006-10-30 14:52:56 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-10-30 14:52:56 +0000 |
| commit | cb753f52412f6054296b1d3cf8d396ca3f1cbcae (patch) | |
| tree | 5c2639c09771058a859dd320d4d21a23a3c1c433 /lisp/tutorial.el | |
| parent | 6db93af0c32214993d990d72b517f54a6630e65c (diff) | |
| download | emacs-cb753f52412f6054296b1d3cf8d396ca3f1cbcae.tar.gz emacs-cb753f52412f6054296b1d3cf8d396ca3f1cbcae.zip | |
* tutorial.el: Move defvars to avoid bytecomp warnings.
(tutorial--find-changed-keys): Check if viper-current-state is
bound before using it.
(help-with-tutorial): Check if viper-tutorial is defined before
using it.
Diffstat (limited to 'lisp/tutorial.el')
| -rw-r--r-- | lisp/tutorial.el | 348 |
1 files changed, 173 insertions, 175 deletions
diff --git a/lisp/tutorial.el b/lisp/tutorial.el index 8b8b939b389..90e44d47e0d 100644 --- a/lisp/tutorial.el +++ b/lisp/tutorial.el | |||
| @@ -35,6 +35,166 @@ | |||
| 35 | (require 'help-mode) ;; for function help-buffer | 35 | (require 'help-mode) ;; for function help-buffer |
| 36 | (eval-when-compile (require 'cl)) | 36 | (eval-when-compile (require 'cl)) |
| 37 | 37 | ||
| 38 | (defvar tutorial--point-before-chkeys 0 | ||
| 39 | "Point before display of key changes.") | ||
| 40 | (make-variable-buffer-local 'tutorial--point-before-chkeys) | ||
| 41 | |||
| 42 | (defvar tutorial--point-after-chkeys 0 | ||
| 43 | "Point after display of key changes.") | ||
| 44 | (make-variable-buffer-local 'tutorial--point-after-chkeys) | ||
| 45 | |||
| 46 | (defvar tutorial--lang nil | ||
| 47 | "Tutorial language.") | ||
| 48 | (make-variable-buffer-local 'tutorial--lang) | ||
| 49 | |||
| 50 | (defconst tutorial--default-keys | ||
| 51 | (let* ( | ||
| 52 | ;; On window system suspend Emacs is replaced in the | ||
| 53 | ;; default keymap so honor this here. | ||
| 54 | (suspend-emacs (if window-system | ||
| 55 | 'iconify-or-deiconify-frame | ||
| 56 | 'suspend-emacs)) | ||
| 57 | (default-keys | ||
| 58 | `( | ||
| 59 | ;; These are not mentioned but are basic: | ||
| 60 | (ESC-prefix [27]) | ||
| 61 | (Control-X-prefix [?\C-x]) | ||
| 62 | (mode-specific-command-prefix [?\C-c]) | ||
| 63 | |||
| 64 | (save-buffers-kill-emacs [?\C-x ?\C-c]) | ||
| 65 | |||
| 66 | |||
| 67 | ;; * SUMMARY | ||
| 68 | (scroll-up [?\C-v]) | ||
| 69 | (scroll-down [?\M-v]) | ||
| 70 | (recenter [?\C-l]) | ||
| 71 | |||
| 72 | |||
| 73 | ;; * BASIC CURSOR CONTROL | ||
| 74 | (forward-char [?\C-f]) | ||
| 75 | (backward-char [?\C-b]) | ||
| 76 | |||
| 77 | (forward-word [?\M-f]) | ||
| 78 | (backward-word [?\M-b]) | ||
| 79 | |||
| 80 | (next-line [?\C-n]) | ||
| 81 | (previous-line [?\C-p]) | ||
| 82 | |||
| 83 | (move-beginning-of-line [?\C-a]) | ||
| 84 | (move-end-of-line [?\C-e]) | ||
| 85 | |||
| 86 | (backward-sentence [?\M-a]) | ||
| 87 | (forward-sentence [?\M-e]) | ||
| 88 | |||
| 89 | |||
| 90 | (beginning-of-buffer [?\M-<]) | ||
| 91 | (end-of-buffer [?\M->]) | ||
| 92 | |||
| 93 | (universal-argument [?\C-u]) | ||
| 94 | |||
| 95 | |||
| 96 | ;; * WHEN EMACS IS HUNG | ||
| 97 | (keyboard-quit [?\C-g]) | ||
| 98 | |||
| 99 | |||
| 100 | ;; * DISABLED COMMANDS | ||
| 101 | (downcase-region [?\C-x ?\C-l]) | ||
| 102 | |||
| 103 | |||
| 104 | ;; * WINDOWS | ||
| 105 | (delete-other-windows [?\C-x ?1]) | ||
| 106 | ;; C-u 0 C-l | ||
| 107 | ;; Type CONTROL-h k CONTROL-f. | ||
| 108 | |||
| 109 | |||
| 110 | ;; * INSERTING AND DELETING | ||
| 111 | ;; C-u 8 * to insert ********. | ||
| 112 | |||
| 113 | (delete-backward-char [backspace]) | ||
| 114 | (delete-char [?\C-d]) | ||
| 115 | |||
| 116 | (backward-kill-word [(meta backspace)]) | ||
| 117 | (kill-word [?\M-d]) | ||
| 118 | |||
| 119 | (kill-line [?\C-k]) | ||
| 120 | (kill-sentence [?\M-k]) | ||
| 121 | |||
| 122 | (set-mark-command [?\C-@]) | ||
| 123 | (set-mark-command [?\C- ]) | ||
| 124 | (kill-region [?\C-w]) | ||
| 125 | (yank [?\C-y]) | ||
| 126 | (yank-pop [?\M-y]) | ||
| 127 | |||
| 128 | |||
| 129 | ;; * UNDO | ||
| 130 | (advertised-undo [?\C-x ?u]) | ||
| 131 | (advertised-undo [?\C-x ?u]) | ||
| 132 | |||
| 133 | |||
| 134 | ;; * FILES | ||
| 135 | (find-file [?\C-x ?\C-f]) | ||
| 136 | (save-buffer [?\C-x ?\C-s]) | ||
| 137 | |||
| 138 | |||
| 139 | ;; * BUFFERS | ||
| 140 | (list-buffers [?\C-x ?\C-b]) | ||
| 141 | (switch-to-buffer [?\C-x ?b]) | ||
| 142 | (save-some-buffers [?\C-x ?s]) | ||
| 143 | |||
| 144 | |||
| 145 | ;; * EXTENDING THE COMMAND SET | ||
| 146 | ;; C-x Character eXtend. Followed by one character. | ||
| 147 | (execute-extended-command [?\M-x]) | ||
| 148 | |||
| 149 | ;; C-x C-f Find file | ||
| 150 | ;; C-x C-s Save file | ||
| 151 | ;; C-x s Save some buffers | ||
| 152 | ;; C-x C-b List buffers | ||
| 153 | ;; C-x b Switch buffer | ||
| 154 | ;; C-x C-c Quit Emacs | ||
| 155 | ;; C-x 1 Delete all but one window | ||
| 156 | ;; C-x u Undo | ||
| 157 | |||
| 158 | |||
| 159 | ;; * MODE LINE | ||
| 160 | (describe-mode [?\C-h ?m]) | ||
| 161 | |||
| 162 | (set-fill-column [?\C-x ?f]) | ||
| 163 | (fill-paragraph [?\M-q]) | ||
| 164 | |||
| 165 | |||
| 166 | ;; * SEARCHING | ||
| 167 | (isearch-forward [?\C-s]) | ||
| 168 | (isearch-backward [?\C-r]) | ||
| 169 | |||
| 170 | |||
| 171 | ;; * MULTIPLE WINDOWS | ||
| 172 | (split-window-vertically [?\C-x ?2]) | ||
| 173 | (scroll-other-window [?\C-\M-v]) | ||
| 174 | (other-window [?\C-x ?o]) | ||
| 175 | (find-file-other-window [?\C-x ?4 ?\C-f]) | ||
| 176 | |||
| 177 | |||
| 178 | ;; * RECURSIVE EDITING LEVELS | ||
| 179 | (keyboard-escape-quit [27 27 27]) | ||
| 180 | |||
| 181 | |||
| 182 | ;; * GETTING MORE HELP | ||
| 183 | ;; The most basic HELP feature is C-h c | ||
| 184 | (describe-key-briefly [?\C-h ?c]) | ||
| 185 | (describe-key [?\C-h ?k]) | ||
| 186 | |||
| 187 | |||
| 188 | ;; * MORE FEATURES | ||
| 189 | ;; F10 | ||
| 190 | |||
| 191 | |||
| 192 | ;; * CONCLUSION | ||
| 193 | ;;(iconify-or-deiconify-frame [?\C-z]) | ||
| 194 | (,suspend-emacs [?\C-z]) | ||
| 195 | ))) | ||
| 196 | (sort default-keys 'tutorial--sort-keys)) | ||
| 197 | "Default Emacs key bindings that the tutorial depends on.") | ||
| 38 | 198 | ||
| 39 | (defun tutorial--detailed-help (button) | 199 | (defun tutorial--detailed-help (button) |
| 40 | "Give detailed help about changed keys." | 200 | "Give detailed help about changed keys." |
| @@ -267,155 +427,6 @@ LEFT and RIGHT are the elements to compare." | |||
| 267 | (symbol-name cx))) | 427 | (symbol-name cx))) |
| 268 | )))) | 428 | )))) |
| 269 | 429 | ||
| 270 | (defconst tutorial--default-keys | ||
| 271 | (let* ( | ||
| 272 | ;; On window system suspend Emacs is replaced in the | ||
| 273 | ;; default keymap so honor this here. | ||
| 274 | (suspend-emacs (if window-system | ||
| 275 | 'iconify-or-deiconify-frame | ||
| 276 | 'suspend-emacs)) | ||
| 277 | (default-keys | ||
| 278 | `( | ||
| 279 | ;; These are not mentioned but are basic: | ||
| 280 | (ESC-prefix [27]) | ||
| 281 | (Control-X-prefix [?\C-x]) | ||
| 282 | (mode-specific-command-prefix [?\C-c]) | ||
| 283 | |||
| 284 | (save-buffers-kill-emacs [?\C-x ?\C-c]) | ||
| 285 | |||
| 286 | |||
| 287 | ;; * SUMMARY | ||
| 288 | (scroll-up [?\C-v]) | ||
| 289 | (scroll-down [?\M-v]) | ||
| 290 | (recenter [?\C-l]) | ||
| 291 | |||
| 292 | |||
| 293 | ;; * BASIC CURSOR CONTROL | ||
| 294 | (forward-char [?\C-f]) | ||
| 295 | (backward-char [?\C-b]) | ||
| 296 | |||
| 297 | (forward-word [?\M-f]) | ||
| 298 | (backward-word [?\M-b]) | ||
| 299 | |||
| 300 | (next-line [?\C-n]) | ||
| 301 | (previous-line [?\C-p]) | ||
| 302 | |||
| 303 | (move-beginning-of-line [?\C-a]) | ||
| 304 | (move-end-of-line [?\C-e]) | ||
| 305 | |||
| 306 | (backward-sentence [?\M-a]) | ||
| 307 | (forward-sentence [?\M-e]) | ||
| 308 | |||
| 309 | |||
| 310 | (beginning-of-buffer [?\M-<]) | ||
| 311 | (end-of-buffer [?\M->]) | ||
| 312 | |||
| 313 | (universal-argument [?\C-u]) | ||
| 314 | |||
| 315 | |||
| 316 | ;; * WHEN EMACS IS HUNG | ||
| 317 | (keyboard-quit [?\C-g]) | ||
| 318 | |||
| 319 | |||
| 320 | ;; * DISABLED COMMANDS | ||
| 321 | (downcase-region [?\C-x ?\C-l]) | ||
| 322 | |||
| 323 | |||
| 324 | ;; * WINDOWS | ||
| 325 | (delete-other-windows [?\C-x ?1]) | ||
| 326 | ;; C-u 0 C-l | ||
| 327 | ;; Type CONTROL-h k CONTROL-f. | ||
| 328 | |||
| 329 | |||
| 330 | ;; * INSERTING AND DELETING | ||
| 331 | ;; C-u 8 * to insert ********. | ||
| 332 | |||
| 333 | (delete-backward-char [backspace]) | ||
| 334 | (delete-char [?\C-d]) | ||
| 335 | |||
| 336 | (backward-kill-word [(meta backspace)]) | ||
| 337 | (kill-word [?\M-d]) | ||
| 338 | |||
| 339 | (kill-line [?\C-k]) | ||
| 340 | (kill-sentence [?\M-k]) | ||
| 341 | |||
| 342 | (set-mark-command [?\C-@]) | ||
| 343 | (set-mark-command [?\C- ]) | ||
| 344 | (kill-region [?\C-w]) | ||
| 345 | (yank [?\C-y]) | ||
| 346 | (yank-pop [?\M-y]) | ||
| 347 | |||
| 348 | |||
| 349 | ;; * UNDO | ||
| 350 | (advertised-undo [?\C-x ?u]) | ||
| 351 | (advertised-undo [?\C-x ?u]) | ||
| 352 | |||
| 353 | |||
| 354 | ;; * FILES | ||
| 355 | (find-file [?\C-x ?\C-f]) | ||
| 356 | (save-buffer [?\C-x ?\C-s]) | ||
| 357 | |||
| 358 | |||
| 359 | ;; * BUFFERS | ||
| 360 | (list-buffers [?\C-x ?\C-b]) | ||
| 361 | (switch-to-buffer [?\C-x ?b]) | ||
| 362 | (save-some-buffers [?\C-x ?s]) | ||
| 363 | |||
| 364 | |||
| 365 | ;; * EXTENDING THE COMMAND SET | ||
| 366 | ;; C-x Character eXtend. Followed by one character. | ||
| 367 | (execute-extended-command [?\M-x]) | ||
| 368 | |||
| 369 | ;; C-x C-f Find file | ||
| 370 | ;; C-x C-s Save file | ||
| 371 | ;; C-x s Save some buffers | ||
| 372 | ;; C-x C-b List buffers | ||
| 373 | ;; C-x b Switch buffer | ||
| 374 | ;; C-x C-c Quit Emacs | ||
| 375 | ;; C-x 1 Delete all but one window | ||
| 376 | ;; C-x u Undo | ||
| 377 | |||
| 378 | |||
| 379 | ;; * MODE LINE | ||
| 380 | (describe-mode [?\C-h ?m]) | ||
| 381 | |||
| 382 | (set-fill-column [?\C-x ?f]) | ||
| 383 | (fill-paragraph [?\M-q]) | ||
| 384 | |||
| 385 | |||
| 386 | ;; * SEARCHING | ||
| 387 | (isearch-forward [?\C-s]) | ||
| 388 | (isearch-backward [?\C-r]) | ||
| 389 | |||
| 390 | |||
| 391 | ;; * MULTIPLE WINDOWS | ||
| 392 | (split-window-vertically [?\C-x ?2]) | ||
| 393 | (scroll-other-window [?\C-\M-v]) | ||
| 394 | (other-window [?\C-x ?o]) | ||
| 395 | (find-file-other-window [?\C-x ?4 ?\C-f]) | ||
| 396 | |||
| 397 | |||
| 398 | ;; * RECURSIVE EDITING LEVELS | ||
| 399 | (keyboard-escape-quit [27 27 27]) | ||
| 400 | |||
| 401 | |||
| 402 | ;; * GETTING MORE HELP | ||
| 403 | ;; The most basic HELP feature is C-h c | ||
| 404 | (describe-key-briefly [?\C-h ?c]) | ||
| 405 | (describe-key [?\C-h ?k]) | ||
| 406 | |||
| 407 | |||
| 408 | ;; * MORE FEATURES | ||
| 409 | ;; F10 | ||
| 410 | |||
| 411 | |||
| 412 | ;; * CONCLUSION | ||
| 413 | ;;(iconify-or-deiconify-frame [?\C-z]) | ||
| 414 | (,suspend-emacs [?\C-z]) | ||
| 415 | ))) | ||
| 416 | (sort default-keys 'tutorial--sort-keys)) | ||
| 417 | "Default Emacs key bindings that the tutorial depends on.") | ||
| 418 | |||
| 419 | (defun tutorial--find-changed-keys (default-keys) | 430 | (defun tutorial--find-changed-keys (default-keys) |
| 420 | "Find the key bindings that have changed. | 431 | "Find the key bindings that have changed. |
| 421 | Check if the default Emacs key bindings that the tutorial depends | 432 | Check if the default Emacs key bindings that the tutorial depends |
| @@ -444,7 +455,7 @@ Where | |||
| 444 | the user clicks the link. | 455 | the user clicks the link. |
| 445 | 456 | ||
| 446 | KEY-FUN is the actual binding for KEY." | 457 | KEY-FUN is the actual binding for KEY." |
| 447 | (let (changed-keys) | 458 | (let (changed-keys remark) |
| 448 | ;; (default-keys tutorial--default-keys)) | 459 | ;; (default-keys tutorial--default-keys)) |
| 449 | (dolist (kdf default-keys) | 460 | (dolist (kdf default-keys) |
| 450 | ;; The variables below corresponds to those with the same names | 461 | ;; The variables below corresponds to those with the same names |
| @@ -508,6 +519,7 @@ Where | |||
| 508 | nil) | 519 | nil) |
| 509 | ;; viper-mode specials: | 520 | ;; viper-mode specials: |
| 510 | ((and (boundp 'viper-mode-string) | 521 | ((and (boundp 'viper-mode-string) |
| 522 | (boundp 'viper-current-state) | ||
| 511 | (eq viper-current-state 'vi-state) | 523 | (eq viper-current-state 'vi-state) |
| 512 | (or (and (eq def-fun 'isearch-forward) | 524 | (or (and (eq def-fun 'isearch-forward) |
| 513 | (eq key-fun 'viper-isearch-forward)) | 525 | (eq key-fun 'viper-isearch-forward)) |
| @@ -645,17 +657,6 @@ CHANGED-KEYS should be a list in the format returned by | |||
| 645 | ;; Make this area read-only: | 657 | ;; Make this area read-only: |
| 646 | (put-text-property start end 'read-only t))))) | 658 | (put-text-property start end 'read-only t))))) |
| 647 | 659 | ||
| 648 | (defvar tutorial--point-before-chkeys 0 | ||
| 649 | "Point before display of key changes.") | ||
| 650 | (make-variable-buffer-local 'tutorial--point-before-chkeys) | ||
| 651 | (defvar tutorial--point-after-chkeys 0 | ||
| 652 | "Point after display of key changes.") | ||
| 653 | (make-variable-buffer-local 'tutorial--point-after-chkeys) | ||
| 654 | |||
| 655 | (defvar tutorial--lang nil | ||
| 656 | "Tutorial language.") | ||
| 657 | (make-variable-buffer-local 'tutorial--lang) | ||
| 658 | |||
| 659 | (defun tutorial--saved-dir () | 660 | (defun tutorial--saved-dir () |
| 660 | "Directory where to save tutorials." | 661 | "Directory where to save tutorials." |
| 661 | (expand-file-name ".emacstut" "~/")) | 662 | (expand-file-name ".emacstut" "~/")) |
| @@ -787,20 +788,17 @@ position in the buffer is saved so that the tutorial may be | |||
| 787 | resumed later." | 788 | resumed later." |
| 788 | (interactive "P") | 789 | (interactive "P") |
| 789 | (if (boundp 'viper-current-state) | 790 | (if (boundp 'viper-current-state) |
| 790 | (let ((prompt | 791 | (let ((prompt1 |
| 791 | " | 792 | "You can not run the Emacs tutorial directly because you have \ |
| 792 | You can not run the Emacs tutorial directly because you have | 793 | enabled Viper.") |
| 793 | enabled Viper. There is however a Viper tutorial you can run | 794 | (prompt2 "\nThere is however a Viper tutorial you can run instead. |
| 794 | instead. From this you can also run a slightly modified version | 795 | Run the Viper tutorial? ")) |
| 795 | of the Emacs tutorial. | 796 | (if (fboundp 'viper-tutorial) |
| 796 | 797 | (if (y-or-n-p (concat prompt1 prompt2)) | |
| 797 | Do you want to run the Viper tutorial instead? ")) | 798 | (progn (message "") |
| 798 | (if (y-or-n-p prompt) | 799 | (funcall 'viper-tutorial 0)) |
| 799 | (progn | 800 | (message "Tutorial aborted by user")) |
| 800 | (message "") | 801 | (message prompt1))) |
| 801 | (viper-tutorial 0)) | ||
| 802 | (message "Tutorial aborted by user"))) | ||
| 803 | |||
| 804 | (let* ((lang (if arg | 802 | (let* ((lang (if arg |
| 805 | (let ((minibuffer-setup-hook minibuffer-setup-hook)) | 803 | (let ((minibuffer-setup-hook minibuffer-setup-hook)) |
| 806 | (add-hook 'minibuffer-setup-hook | 804 | (add-hook 'minibuffer-setup-hook |