diff options
| author | Chong Yidong | 2006-12-21 17:26:00 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-12-21 17:26:00 +0000 |
| commit | c188100527af5d40d5ca2b2848a151da261d0747 (patch) | |
| tree | 39ab6385bdc93878227d1dff41fb72c3bf194465 /lisp/tutorial.el | |
| parent | 397e270a287a0d2c4eb817b67e3cb69e9f966083 (diff) | |
| download | emacs-c188100527af5d40d5ca2b2848a151da261d0747.tar.gz emacs-c188100527af5d40d5ca2b2848a151da261d0747.zip | |
Remove `cl' requirement. Clean up whitespace.
Replace '?\ ' by '?\s' throughout.
(tutorial-warning-face): Inherit font-lock-warning-face. Move to
`help' custom group.
(tutorial--key-description): New function.
(tutorial--display-changes): Remove redundant arg. Scan for all
key sequences to avoid false matches. Cleanup.
(tutorial--saved-dir): Save to a subdirectory in .emacs.d to
reduce homedir pollution.
(help-with-tutorial): Call tutorial--display-changes with no arg.
Diffstat (limited to 'lisp/tutorial.el')
| -rw-r--r-- | lisp/tutorial.el | 284 |
1 files changed, 105 insertions, 179 deletions
diff --git a/lisp/tutorial.el b/lisp/tutorial.el index b171ee9a07b..a711e766221 100644 --- a/lisp/tutorial.el +++ b/lisp/tutorial.el | |||
| @@ -33,21 +33,11 @@ | |||
| 33 | ;;; Code: | 33 | ;;; Code: |
| 34 | 34 | ||
| 35 | (require 'help-mode) ;; for function help-buffer | 35 | (require 'help-mode) ;; for function help-buffer |
| 36 | (eval-when-compile (require 'cl)) | ||
| 37 | 36 | ||
| 38 | (defface tutorial-warning-face | 37 | (defface tutorial-warning-face |
| 39 | '((((class color) (min-colors 88) (background light)) | 38 | '((t :inherit font-lock-warning-face)) |
| 40 | (:foreground "Red1" :weight bold)) | ||
| 41 | (((class color) (min-colors 88) (background dark)) | ||
| 42 | (:foreground "Pink" :weight bold)) | ||
| 43 | (((class color) (min-colors 16) (background light)) | ||
| 44 | (:foreground "Red1" :weight bold)) | ||
| 45 | (((class color) (min-colors 16) (background dark)) | ||
| 46 | (:foreground "Pink" :weight bold)) | ||
| 47 | (((class color) (min-colors 8)) (:foreground "red")) | ||
| 48 | (t (:inverse-video t :weight bold))) | ||
| 49 | "Face used to highlight warnings in the tutorial." | 39 | "Face used to highlight warnings in the tutorial." |
| 50 | :group 'font-lock-faces) | 40 | :group 'help) |
| 51 | 41 | ||
| 52 | (defvar tutorial--point-before-chkeys 0 | 42 | (defvar tutorial--point-before-chkeys 0 |
| 53 | "Point before display of key changes.") | 43 | "Point before display of key changes.") |
| @@ -168,8 +158,7 @@ options: | |||
| 168 | where | 158 | where |
| 169 | " to get the function `" | 159 | " to get the function `" |
| 170 | (format "%s" db) | 160 | (format "%s" db) |
| 171 | "'.")) | 161 | "'."))) |
| 172 | ) | ||
| 173 | (fill-region (point-min) (point))))) | 162 | (fill-region (point-min) (point))))) |
| 174 | (print-help-return-message)))) | 163 | (print-help-return-message)))) |
| 175 | 164 | ||
| @@ -213,110 +202,83 @@ LEFT and RIGHT are the elements to compare." | |||
| 213 | ((and (symbolp cx) | 202 | ((and (symbolp cx) |
| 214 | (symbolp cy)) | 203 | (symbolp cy)) |
| 215 | (string< (symbol-name cy) | 204 | (string< (symbol-name cy) |
| 216 | (symbol-name cx))) | 205 | (symbol-name cx))))))) |
| 217 | )))) | ||
| 218 | 206 | ||
| 219 | (defconst tutorial--default-keys | 207 | (defconst tutorial--default-keys |
| 220 | (let* ( | 208 | ;; On window system, `suspend-emacs' is replaced in the default |
| 221 | ;; On window system suspend Emacs is replaced in the | 209 | ;; keymap |
| 222 | ;; default keymap so honor this here. | 210 | (let* ((suspend-emacs (if window-system |
| 223 | (suspend-emacs (if window-system | ||
| 224 | 'iconify-or-deiconify-frame | 211 | 'iconify-or-deiconify-frame |
| 225 | 'suspend-emacs)) | 212 | 'suspend-emacs)) |
| 226 | (default-keys | 213 | (default-keys |
| 227 | `( | 214 | `((ESC-prefix [27]) |
| 228 | ;; These are not mentioned but are basic: | ||
| 229 | (ESC-prefix [27]) | ||
| 230 | (Control-X-prefix [?\C-x]) | 215 | (Control-X-prefix [?\C-x]) |
| 231 | (mode-specific-command-prefix [?\C-c]) | 216 | (mode-specific-command-prefix [?\C-c]) |
| 232 | |||
| 233 | (save-buffers-kill-emacs [?\C-x ?\C-c]) | 217 | (save-buffers-kill-emacs [?\C-x ?\C-c]) |
| 234 | 218 | ||
| 235 | |||
| 236 | ;; * SUMMARY | 219 | ;; * SUMMARY |
| 237 | (scroll-up [?\C-v]) | 220 | (scroll-up [?\C-v]) |
| 238 | (scroll-down [?\M-v]) | 221 | (scroll-down [?\M-v]) |
| 239 | (recenter [?\C-l]) | 222 | (recenter [?\C-l]) |
| 240 | 223 | ||
| 241 | |||
| 242 | ;; * BASIC CURSOR CONTROL | 224 | ;; * BASIC CURSOR CONTROL |
| 243 | (forward-char [?\C-f]) | 225 | (forward-char [?\C-f]) |
| 244 | (backward-char [?\C-b]) | 226 | (backward-char [?\C-b]) |
| 245 | |||
| 246 | (forward-word [?\M-f]) | 227 | (forward-word [?\M-f]) |
| 247 | (backward-word [?\M-b]) | 228 | (backward-word [?\M-b]) |
| 248 | |||
| 249 | (next-line [?\C-n]) | 229 | (next-line [?\C-n]) |
| 250 | (previous-line [?\C-p]) | 230 | (previous-line [?\C-p]) |
| 251 | |||
| 252 | (move-beginning-of-line [?\C-a]) | 231 | (move-beginning-of-line [?\C-a]) |
| 253 | (move-end-of-line [?\C-e]) | 232 | (move-end-of-line [?\C-e]) |
| 254 | |||
| 255 | (backward-sentence [?\M-a]) | 233 | (backward-sentence [?\M-a]) |
| 256 | (forward-sentence [?\M-e]) | 234 | (forward-sentence [?\M-e]) |
| 257 | |||
| 258 | (newline "\r") | 235 | (newline "\r") |
| 259 | |||
| 260 | (beginning-of-buffer [?\M-<]) | 236 | (beginning-of-buffer [?\M-<]) |
| 261 | (end-of-buffer [?\M->]) | 237 | (end-of-buffer [?\M->]) |
| 262 | |||
| 263 | (universal-argument [?\C-u]) | 238 | (universal-argument [?\C-u]) |
| 264 | 239 | ||
| 265 | |||
| 266 | ;; * WHEN EMACS IS HUNG | 240 | ;; * WHEN EMACS IS HUNG |
| 267 | (keyboard-quit [?\C-g]) | 241 | (keyboard-quit [?\C-g]) |
| 268 | 242 | ||
| 269 | |||
| 270 | ;; * DISABLED COMMANDS | 243 | ;; * DISABLED COMMANDS |
| 271 | (downcase-region [?\C-x ?\C-l]) | 244 | (downcase-region [?\C-x ?\C-l]) |
| 272 | 245 | ||
| 273 | |||
| 274 | ;; * WINDOWS | 246 | ;; * WINDOWS |
| 275 | (delete-other-windows [?\C-x ?1]) | 247 | (delete-other-windows [?\C-x ?1]) |
| 276 | ;; C-u 0 C-l | 248 | ;; C-u 0 C-l |
| 277 | ;; Type CONTROL-h k CONTROL-f. | 249 | ;; Type CONTROL-h k CONTROL-f. |
| 278 | 250 | ||
| 279 | |||
| 280 | ;; * INSERTING AND DELETING | 251 | ;; * INSERTING AND DELETING |
| 281 | ;; C-u 8 * to insert ********. | 252 | ;; C-u 8 * to insert ********. |
| 282 | |||
| 283 | (delete-backward-char [backspace]) | 253 | (delete-backward-char [backspace]) |
| 284 | (delete-backward-char "\d") | 254 | (delete-backward-char "\d") |
| 285 | (delete-char [?\C-d]) | 255 | (delete-char [?\C-d]) |
| 286 | |||
| 287 | (backward-kill-word [(meta backspace)]) | 256 | (backward-kill-word [(meta backspace)]) |
| 288 | (kill-word [?\M-d]) | 257 | (kill-word [?\M-d]) |
| 289 | |||
| 290 | (kill-line [?\C-k]) | 258 | (kill-line [?\C-k]) |
| 291 | (kill-sentence [?\M-k]) | 259 | (kill-sentence [?\M-k]) |
| 292 | |||
| 293 | (set-mark-command [?\C-@]) | 260 | (set-mark-command [?\C-@]) |
| 294 | (set-mark-command [?\C- ]) | 261 | (set-mark-command [?\C- ]) |
| 295 | (kill-region [?\C-w]) | 262 | (kill-region [?\C-w]) |
| 296 | (yank [?\C-y]) | 263 | (yank [?\C-y]) |
| 297 | (yank-pop [?\M-y]) | 264 | (yank-pop [?\M-y]) |
| 298 | 265 | ||
| 299 | |||
| 300 | ;; * UNDO | 266 | ;; * UNDO |
| 301 | (advertised-undo [?\C-x ?u]) | 267 | (advertised-undo [?\C-x ?u]) |
| 302 | (advertised-undo [?\C-x ?u]) | 268 | (advertised-undo [?\C-x ?u]) |
| 303 | 269 | ||
| 304 | |||
| 305 | ;; * FILES | 270 | ;; * FILES |
| 306 | (find-file [?\C-x ?\C-f]) | 271 | (find-file [?\C-x ?\C-f]) |
| 307 | (save-buffer [?\C-x ?\C-s]) | 272 | (save-buffer [?\C-x ?\C-s]) |
| 308 | 273 | ||
| 309 | |||
| 310 | ;; * BUFFERS | 274 | ;; * BUFFERS |
| 311 | (list-buffers [?\C-x ?\C-b]) | 275 | (list-buffers [?\C-x ?\C-b]) |
| 312 | (switch-to-buffer [?\C-x ?b]) | 276 | (switch-to-buffer [?\C-x ?b]) |
| 313 | (save-some-buffers [?\C-x ?s]) | 277 | (save-some-buffers [?\C-x ?s]) |
| 314 | 278 | ||
| 315 | |||
| 316 | ;; * EXTENDING THE COMMAND SET | 279 | ;; * EXTENDING THE COMMAND SET |
| 317 | ;; C-x Character eXtend. Followed by one character. | 280 | ;; C-x Character eXtend. Followed by one character. |
| 318 | (execute-extended-command [?\M-x]) | 281 | (execute-extended-command [?\M-x]) |
| 319 | |||
| 320 | ;; C-x C-f Find file | 282 | ;; C-x C-f Find file |
| 321 | ;; C-x C-s Save file | 283 | ;; C-x C-s Save file |
| 322 | ;; C-x s Save some buffers | 284 | ;; C-x s Save some buffers |
| @@ -326,44 +288,35 @@ LEFT and RIGHT are the elements to compare." | |||
| 326 | ;; C-x 1 Delete all but one window | 288 | ;; C-x 1 Delete all but one window |
| 327 | ;; C-x u Undo | 289 | ;; C-x u Undo |
| 328 | 290 | ||
| 329 | |||
| 330 | ;; * MODE LINE | 291 | ;; * MODE LINE |
| 331 | (describe-mode [?\C-h ?m]) | 292 | (describe-mode [?\C-h ?m]) |
| 332 | |||
| 333 | (set-fill-column [?\C-x ?f]) | 293 | (set-fill-column [?\C-x ?f]) |
| 334 | (fill-paragraph [?\M-q]) | 294 | (fill-paragraph [?\M-q]) |
| 335 | 295 | ||
| 336 | |||
| 337 | ;; * SEARCHING | 296 | ;; * SEARCHING |
| 338 | (isearch-forward [?\C-s]) | 297 | (isearch-forward [?\C-s]) |
| 339 | (isearch-backward [?\C-r]) | 298 | (isearch-backward [?\C-r]) |
| 340 | 299 | ||
| 341 | |||
| 342 | ;; * MULTIPLE WINDOWS | 300 | ;; * MULTIPLE WINDOWS |
| 343 | (split-window-vertically [?\C-x ?2]) | 301 | (split-window-vertically [?\C-x ?2]) |
| 344 | (scroll-other-window [?\C-\M-v]) | 302 | (scroll-other-window [?\C-\M-v]) |
| 345 | (other-window [?\C-x ?o]) | 303 | (other-window [?\C-x ?o]) |
| 346 | (find-file-other-window [?\C-x ?4 ?\C-f]) | 304 | (find-file-other-window [?\C-x ?4 ?\C-f]) |
| 347 | 305 | ||
| 348 | |||
| 349 | ;; * RECURSIVE EDITING LEVELS | 306 | ;; * RECURSIVE EDITING LEVELS |
| 350 | (keyboard-escape-quit [27 27 27]) | 307 | (keyboard-escape-quit [27 27 27]) |
| 351 | 308 | ||
| 352 | |||
| 353 | ;; * GETTING MORE HELP | 309 | ;; * GETTING MORE HELP |
| 354 | ;; The most basic HELP feature is C-h c | 310 | ;; The most basic HELP feature is C-h c |
| 355 | (describe-key-briefly [?\C-h ?c]) | 311 | (describe-key-briefly [?\C-h ?c]) |
| 356 | (describe-key [?\C-h ?k]) | 312 | (describe-key [?\C-h ?k]) |
| 357 | 313 | ||
| 358 | |||
| 359 | ;; * MORE FEATURES | 314 | ;; * MORE FEATURES |
| 360 | ;; F10 | 315 | ;; F10 |
| 361 | 316 | ||
| 362 | |||
| 363 | ;; * CONCLUSION | 317 | ;; * CONCLUSION |
| 364 | ;;(iconify-or-deiconify-frame [?\C-z]) | 318 | ;;(iconify-or-deiconify-frame [?\C-z]) |
| 365 | (,suspend-emacs [?\C-z]) | 319 | (,suspend-emacs [?\C-z])))) |
| 366 | ))) | ||
| 367 | (sort default-keys 'tutorial--sort-keys)) | 320 | (sort default-keys 'tutorial--sort-keys)) |
| 368 | "Default Emacs key bindings that the tutorial depends on.") | 321 | "Default Emacs key bindings that the tutorial depends on.") |
| 369 | 322 | ||
| @@ -374,7 +327,6 @@ LEFT and RIGHT are the elements to compare." | |||
| 374 | (interactive-p)) | 327 | (interactive-p)) |
| 375 | (with-current-buffer (help-buffer) | 328 | (with-current-buffer (help-buffer) |
| 376 | (let* ((tutorial-buffer (button-get button 'tutorial-buffer)) | 329 | (let* ((tutorial-buffer (button-get button 'tutorial-buffer)) |
| 377 | ;;(tutorial-arg (button-get button 'tutorial-arg)) | ||
| 378 | (explain-key-desc (button-get button 'explain-key-desc)) | 330 | (explain-key-desc (button-get button 'explain-key-desc)) |
| 379 | (changed-keys (with-current-buffer tutorial-buffer | 331 | (changed-keys (with-current-buffer tutorial-buffer |
| 380 | (save-excursion | 332 | (save-excursion |
| @@ -405,7 +357,7 @@ from Emacs default in the " (buffer-name tutorial-buffer) " buffer:\n\n" ) | |||
| 405 | (insert " " key-txt " ") | 357 | (insert " " key-txt " ") |
| 406 | (setq tot-len (length key-txt)) | 358 | (setq tot-len (length key-txt)) |
| 407 | (when (> 9 tot-len) | 359 | (when (> 9 tot-len) |
| 408 | (insert (make-string (- 9 tot-len) ? )) | 360 | (insert (make-string (- 9 tot-len) ?\s)) |
| 409 | (setq tot-len 9)) | 361 | (setq tot-len 9)) |
| 410 | ;; Insert a link describing the old binding: | 362 | ;; Insert a link describing the old binding: |
| 411 | (insert-button def-fun-txt | 363 | (insert-button def-fun-txt |
| @@ -417,7 +369,7 @@ from Emacs default in the " (buffer-name tutorial-buffer) " buffer:\n\n" ) | |||
| 417 | 'follow-link t) | 369 | 'follow-link t) |
| 418 | (setq tot-len (+ tot-len (length def-fun-txt))) | 370 | (setq tot-len (+ tot-len (length def-fun-txt))) |
| 419 | (when (> 36 tot-len) | 371 | (when (> 36 tot-len) |
| 420 | (insert (make-string (- 36 tot-len) ? ))) | 372 | (insert (make-string (- 36 tot-len) ?\s))) |
| 421 | (when (listp where) | 373 | (when (listp where) |
| 422 | (setq where "list")) | 374 | (setq where "list")) |
| 423 | ;; Tell where the old binding is now: | 375 | ;; Tell where the old binding is now: |
| @@ -438,8 +390,8 @@ from Emacs default in the " (buffer-name tutorial-buffer) " buffer:\n\n" ) | |||
| 438 | (insert "\n"))))) | 390 | (insert "\n"))))) |
| 439 | 391 | ||
| 440 | (insert " | 392 | (insert " |
| 441 | It is legitimate to change key bindings, but changed bindings do not | 393 | It is OK to change key bindings, but changed bindings do not |
| 442 | correspond to what the tutorial says. (See also " ) | 394 | correspond to what the tutorial says. (See also ") |
| 443 | (insert-button "Key Binding Conventions" | 395 | (insert-button "Key Binding Conventions" |
| 444 | 'action | 396 | 'action |
| 445 | (lambda(button) (interactive) | 397 | (lambda(button) (interactive) |
| @@ -479,7 +431,6 @@ Where | |||
| 479 | 431 | ||
| 480 | KEY-FUN is the actual binding for KEY." | 432 | KEY-FUN is the actual binding for KEY." |
| 481 | (let (changed-keys remark) | 433 | (let (changed-keys remark) |
| 482 | ;; (default-keys tutorial--default-keys)) | ||
| 483 | (dolist (kdf default-keys) | 434 | (dolist (kdf default-keys) |
| 484 | ;; The variables below corresponds to those with the same names | 435 | ;; The variables below corresponds to those with the same names |
| 485 | ;; described in the doc string. | 436 | ;; described in the doc string. |
| @@ -578,113 +529,99 @@ Where | |||
| 578 | map) | 529 | map) |
| 579 | "Keymap that allows tabbing between buttons.") | 530 | "Keymap that allows tabbing between buttons.") |
| 580 | 531 | ||
| 581 | (defun tutorial--display-changes (changed-keys) | 532 | (defun tutorial--key-description (key) |
| 533 | (let ((desc (key-description key))) | ||
| 534 | (cond ((string= "ESC" desc) "<ESC>") | ||
| 535 | ((string= "RET" desc) "<Return>") | ||
| 536 | ((string= "DEL" desc) "<Delback>") | ||
| 537 | (t desc)))) | ||
| 538 | |||
| 539 | (defun tutorial--display-changes () | ||
| 582 | "Display changes to some default key bindings. | 540 | "Display changes to some default key bindings. |
| 583 | If some of the default key bindings that the tutorial depends on | 541 | If some of the default key bindings that the tutorial depends on |
| 584 | have been changed then display the changes in the tutorial buffer | 542 | have been changed then display the changes in the tutorial buffer |
| 585 | with some explanatory links. | 543 | with some explanatory links." |
| 586 | 544 | (let* ((changed-keys (tutorial--find-changed-keys | |
| 587 | CHANGED-KEYS should be a list in the format returned by | 545 | tutorial--default-keys)) |
| 588 | `tutorial--find-changed-keys'." | 546 | ;; Alist of element (DESC . CK) where DESC is the |
| 589 | (when (or changed-keys | 547 | ;; key-description of a changed key and CK is the |
| 590 | (boundp 'viper-mode-string)) | 548 | ;; corresponding element in `changed-keys'. |
| 549 | (changed-keys-alist | ||
| 550 | (mapcar (lambda (ck) (cons (tutorial--key-description (car ck)) ck)) | ||
| 551 | changed-keys)) | ||
| 552 | (start (point)) | ||
| 553 | (case-fold-search nil) | ||
| 554 | (keybindings-regexp | ||
| 555 | (concat "[[:space:]]\\(" | ||
| 556 | (mapconcat (lambda (kdf) | ||
| 557 | (regexp-quote | ||
| 558 | (tutorial--key-description | ||
| 559 | (nth 1 kdf)))) | ||
| 560 | tutorial--default-keys | ||
| 561 | "\\|") | ||
| 562 | "\\)[[:punct:][:space:]]"))) | ||
| 591 | ;; Need the custom button face for viper buttons: | 563 | ;; Need the custom button face for viper buttons: |
| 592 | (when (boundp 'viper-mode-string) | 564 | (if (boundp 'viper-mode-string) (require 'cus-edit)) |
| 593 | (require 'cus-edit)) | 565 | |
| 594 | (let ((start (point)) | 566 | (if (or changed-keys (boundp 'viper-mode-string)) |
| 595 | end | 567 | (let ((head (get-lang-string tutorial--lang 'tut-chgdhead)) |
| 596 | (head (get-lang-string tutorial--lang 'tut-chgdhead)) | 568 | (head2 (get-lang-string tutorial--lang 'tut-chgdhead2))) |
| 597 | (head2 (get-lang-string tutorial--lang 'tut-chgdhead2))) | 569 | (when (and head head2) |
| 598 | (when (and head head2) | 570 | (goto-char tutorial--point-before-chkeys) |
| 599 | (goto-char tutorial--point-before-chkeys) | 571 | (insert head) |
| 600 | (insert head) | 572 | (insert-button head2 'tutorial-buffer (current-buffer) |
| 601 | (insert-button head2 | 573 | 'action 'tutorial--detailed-help |
| 602 | 'tutorial-buffer | 574 | 'follow-link t 'face 'link) |
| 603 | (current-buffer) | 575 | (insert "]\n\n") |
| 604 | ;;'tutorial-arg arg | 576 | (add-text-properties tutorial--point-before-chkeys (point) |
| 605 | 'action | 577 | '(local-map tutorial--tab-map |
| 606 | 'tutorial--detailed-help | 578 | tutorial-remark t |
| 607 | 'follow-link t | 579 | face tutorial-warning-face |
| 608 | 'face 'link) | 580 | read-only t))))) |
| 609 | (insert "]\n\n" ) | 581 | |
| 610 | (when changed-keys | 582 | ;; Scan the tutorial for all key sequences. |
| 611 | (dolist (tk changed-keys) | 583 | (goto-char (point-min)) |
| 612 | (let* ((def-fun (nth 1 tk)) | 584 | (while (re-search-forward keybindings-regexp (point-max) t) |
| 613 | (key (nth 0 tk)) | 585 | ;; Then highlight each rebound key sequence. |
| 614 | (def-fun-txt (nth 2 tk)) | 586 | ;; This avoids issuing a warning for, e.g., C-x C-b if C-b is rebound. |
| 615 | (where (nth 3 tk)) | 587 | (let ((changed-key (assoc (match-string 1) changed-keys-alist))) |
| 616 | (remark (nth 4 tk)) | 588 | (and changed-key |
| 617 | (rem-fun (command-remapping def-fun)) | 589 | (not (get-text-property (match-beginning 1) 'tutorial-remark)) |
| 618 | (key-txt (key-description key)) | 590 | (let* ((desc (car changed-key)) |
| 619 | (key-fun (key-binding key)) | 591 | (ck (cdr changed-key)) |
| 620 | tot-len) | 592 | (key (nth 0 ck)) |
| 621 | (unless (eq def-fun key-fun) | 593 | (def-fun (nth 1 ck)) |
| 622 | ;; Mark the key in the tutorial text | 594 | (where (nth 3 ck))) |
| 623 | (unless (string= "Same key" where) | 595 | (unless (string= where "Same key") |
| 624 | (let ((here (point)) | 596 | (setq tutorial--point-after-chkeys (point-marker)) |
| 625 | (case-fold-search nil) | 597 | (put-text-property (match-beginning 1) |
| 626 | (key-desc (key-description key))) | 598 | (match-end 1) |
| 627 | (cond ((string= "ESC" key-desc) | 599 | 'face 'tutorial-warning-face) |
| 628 | (setq key-desc "<ESC>")) | 600 | (put-text-property (match-beginning 1) |
| 629 | ((string= "RET" key-desc) | 601 | (match-end 1) |
| 630 | (setq key-desc "<Return>")) | 602 | 'tutorial-remark t) |
| 631 | ((string= "DEL" key-desc) | 603 | (save-excursion |
| 632 | (setq key-desc "<Delback>"))) | 604 | (forward-line) |
| 633 | (while (re-search-forward | 605 | (let ((s (get-lang-string tutorial--lang 'tut-chgdkey)) |
| 634 | (concat "[[:space:]]\\(" | 606 | (s2 (get-lang-string tutorial--lang 'tut-chgdkey2)) |
| 635 | (regexp-quote key-desc) | 607 | (start (point))) |
| 636 | "\\)[[:space:]]") nil t) | 608 | (when (and s s2) |
| 637 | (put-text-property (match-beginning 1) | 609 | (insert (format s desc where s2)) |
| 638 | (match-end 1) | 610 | (insert-button s2 'tutorial-buffer (current-buffer) |
| 639 | 'tutorial-remark 'only-colored) | 611 | 'action 'tutorial--detailed-help |
| 640 | (put-text-property (match-beginning 1) | 612 | 'explain-key-desc desc 'follow-link t |
| 641 | (match-end 1) | 613 | 'face 'link) |
| 642 | 'face 'tutorial-warning-face) | 614 | (insert "] **\n") |
| 643 | (forward-line) | 615 | (add-text-properties start (point) |
| 644 | (let ((s (get-lang-string tutorial--lang 'tut-chgdkey)) | 616 | '(local-map tutorial--tab-map |
| 645 | (s2 (get-lang-string tutorial--lang 'tut-chgdkey2)) | 617 | tutorial-remark t |
| 646 | (start (point)) | 618 | face tutorial-warning-face |
| 647 | end) | 619 | read-only t)))))))))))) |
| 648 | (when (and s s2) | ||
| 649 | (setq s (format s key-desc where s2)) | ||
| 650 | (insert s) | ||
| 651 | (insert-button s2 | ||
| 652 | 'tutorial-buffer | ||
| 653 | (current-buffer) | ||
| 654 | ;;'tutorial-arg arg | ||
| 655 | 'action | ||
| 656 | 'tutorial--detailed-help | ||
| 657 | 'explain-key-desc key-desc | ||
| 658 | 'follow-link t | ||
| 659 | 'face 'link) | ||
| 660 | (insert "] **") | ||
| 661 | (insert "\n") | ||
| 662 | (setq end (point)) | ||
| 663 | (put-text-property start end 'local-map tutorial--tab-map) | ||
| 664 | ;; Add a property so we can remove the remark: | ||
| 665 | (put-text-property start end 'tutorial-remark t) | ||
| 666 | (put-text-property start end | ||
| 667 | 'face 'tutorial-warning-face) | ||
| 668 | (put-text-property start end 'read-only t)))) | ||
| 669 | (goto-char here))))))) | ||
| 670 | |||
| 671 | |||
| 672 | (setq end (point)) | ||
| 673 | ;; Make the area with information about change key | ||
| 674 | ;; bindings stand out: | ||
| 675 | (put-text-property start end 'tutorial-remark t) | ||
| 676 | (put-text-property start end | ||
| 677 | 'face 'tutorial-warning-face) | ||
| 678 | ;; Make it possible to use Tab/S-Tab between fields in | ||
| 679 | ;; this area: | ||
| 680 | (put-text-property start end 'local-map tutorial--tab-map) | ||
| 681 | (setq tutorial--point-after-chkeys (point-marker)) | ||
| 682 | ;; Make this area read-only: | ||
| 683 | (put-text-property start end 'read-only t))))) | ||
| 684 | 620 | ||
| 685 | (defun tutorial--saved-dir () | 621 | (defun tutorial--saved-dir () |
| 686 | "Directory where to save tutorials." | 622 | "Directory to which tutorials are saved." |
| 687 | (expand-file-name ".emacstut" "~/")) | 623 | (expand-file-name "tutorial" |
| 624 | (if (eq system-type 'ms-dos) "~/_emacs.d/" "~/.emacs.d/"))) | ||
| 688 | 625 | ||
| 689 | (defun tutorial--saved-file () | 626 | (defun tutorial--saved-file () |
| 690 | "File name in which to save tutorials." | 627 | "File name in which to save tutorials." |
| @@ -908,13 +845,7 @@ Run the Viper tutorial? ")) | |||
| 908 | (forward-line) | 845 | (forward-line) |
| 909 | (setq tutorial--point-before-chkeys (point-marker))) | 846 | (setq tutorial--point-before-chkeys (point-marker))) |
| 910 | 847 | ||
| 911 | 848 | (tutorial--display-changes) | |
| 912 | ;; Check if there are key bindings that may disturb the | ||
| 913 | ;; tutorial. If so tell the user. | ||
| 914 | (let ((changed-keys (tutorial--find-changed-keys tutorial--default-keys))) | ||
| 915 | (when changed-keys | ||
| 916 | (tutorial--display-changes changed-keys))) | ||
| 917 | |||
| 918 | 849 | ||
| 919 | ;; Clear message: | 850 | ;; Clear message: |
| 920 | (unless dont-ask-for-revert | 851 | (unless dont-ask-for-revert |
| @@ -971,11 +902,9 @@ Run the Viper tutorial? ")) | |||
| 971 | ;; are currently only used in the tutorial. | 902 | ;; are currently only used in the tutorial. |
| 972 | 903 | ||
| 973 | (defconst lang-strings | 904 | (defconst lang-strings |
| 974 | '( | 905 | '(("English" . |
| 975 | ("English" . | 906 | ((tut-chgdkey . "** %s has been rebound, but you can use %s instead [") |
| 976 | ( | 907 | (tut-chgdkey2 . "More") |
| 977 | (tut-chgdkey . "** The key %s has been rebound, but you can use %s instead [") | ||
| 978 | (tut-chgdkey2 . "More information") | ||
| 979 | (tut-chgdhead . " | 908 | (tut-chgdhead . " |
| 980 | NOTICE: The main purpose of the Emacs tutorial is to teach you | 909 | NOTICE: The main purpose of the Emacs tutorial is to teach you |
| 981 | the most important standard Emacs commands (key bindings). | 910 | the most important standard Emacs commands (key bindings). |
| @@ -983,10 +912,7 @@ Run the Viper tutorial? ")) | |||
| 983 | these basic editing commands, so it doesn't correspond to the | 912 | these basic editing commands, so it doesn't correspond to the |
| 984 | tutorial. We have inserted colored notices where the altered | 913 | tutorial. We have inserted colored notices where the altered |
| 985 | commands have been introduced. [") | 914 | commands have been introduced. [") |
| 986 | (tut-chgdhead2 . "Details") | 915 | (tut-chgdhead2 . "More")))) |
| 987 | ) | ||
| 988 | ) | ||
| 989 | ) | ||
| 990 | "Language specific strings for Emacs. | 916 | "Language specific strings for Emacs. |
| 991 | This is an association list with the keys equal to the strings | 917 | This is an association list with the keys equal to the strings |
| 992 | that can be returned by `read-language-name'. The elements in | 918 | that can be returned by `read-language-name'. The elements in |