Mercurial > emacs
annotate lisp/tutorial.el @ 75471:afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Don't check `backspace'.
(tutorial--find-changed-keys): Look up bindings in a temp buffer
in Fundamental mode.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 28 Jan 2007 07:08:51 +0000 |
parents | e3694f1cb928 |
children | 21cbf755a07c |
rev | line source |
---|---|
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1 ;;; tutorial.el --- tutorial for Emacs |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
75347 | 3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc. |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Maintainer: FSF |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Keywords: help, internal |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; any later version. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; Boston, MA 02110-1301, USA. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;;; Commentary: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; Code for running the Emacs tutorial. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;;; History: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; File was created 2006-09. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;;; Code: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 (require 'help-mode) ;; for function help-buffer |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 |
74100
9b8e3f194cc1
(tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents:
73567
diff
changeset
|
37 (defface tutorial-warning-face |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
38 '((t :inherit font-lock-warning-face)) |
74100
9b8e3f194cc1
(tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents:
73567
diff
changeset
|
39 "Face used to highlight warnings in the tutorial." |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
40 :group 'help) |
74100
9b8e3f194cc1
(tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents:
73567
diff
changeset
|
41 |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
42 (defvar tutorial--point-before-chkeys 0 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
43 "Point before display of key changes.") |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
44 (make-variable-buffer-local 'tutorial--point-before-chkeys) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
45 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
46 (defvar tutorial--point-after-chkeys 0 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
47 "Point after display of key changes.") |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
48 (make-variable-buffer-local 'tutorial--point-after-chkeys) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
49 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
50 (defvar tutorial--lang nil |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
51 "Tutorial language.") |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
52 (make-variable-buffer-local 'tutorial--lang) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
53 |
73552 | 54 (defun tutorial--describe-nonstandard-key (value) |
55 "Give more information about a changed key binding. | |
56 This is used in `help-with-tutorial'. The information includes | |
57 the key sequence that no longer has a default binding, the | |
58 default binding and the current binding. It also tells in what | |
59 keymap the new binding has been done and how to access the | |
60 function in the default binding from the keyboard. | |
61 | |
62 For `cua-mode' key bindings that try to combine CUA key bindings | |
63 with default Emacs bindings information about this is shown. | |
64 | |
65 VALUE should have either of these formats: | |
66 | |
67 \(cua-mode) | |
68 \(current-binding KEY-FUN DEF-FUN KEY WHERE) | |
69 | |
70 Where | |
71 KEY is a key sequence whose standard binding has been changed | |
72 KEY-FUN is the actual binding for KEY | |
73 DEF-FUN is the standard binding of KEY | |
74 WHERE is a text describing the key sequences to which DEF-FUN is | |
75 bound now (or, if it is remapped, a key sequence | |
76 for the function it is remapped to)" | |
77 (with-output-to-temp-buffer (help-buffer) | |
78 (help-setup-xref (list #'tutorial--describe-nonstandard-key value) | |
79 (interactive-p)) | |
80 (with-current-buffer (help-buffer) | |
81 (insert | |
82 "Your Emacs customizations override the default binding for this key:" | |
83 "\n\n") | |
84 (let ((inhibit-read-only t)) | |
85 (cond | |
86 ((eq (car value) 'cua-mode) | |
87 (insert | |
88 "CUA mode is enabled. | |
89 | |
90 When CUA mode is enabled, you can use C-z, C-x, C-c, and C-v to | |
91 undo, cut, copy, and paste in addition to the normal Emacs | |
92 bindings. The C-x and C-c keys only do cut and copy when the | |
93 region is active, so in most cases, they do not conflict with the | |
94 normal function of these prefix keys. | |
95 | |
96 If you really need to perform a command which starts with one of | |
97 the prefix keys even when the region is active, you have three | |
98 options: | |
99 - press the prefix key twice very quickly (within 0.2 seconds), | |
100 - press the prefix key and the following key within 0.2 seconds, or | |
101 - use the SHIFT key with the prefix key, i.e. C-S-x or C-S-c.")) | |
102 ((eq (car value) 'current-binding) | |
103 (let ((cb (nth 1 value)) | |
104 (db (nth 2 value)) | |
105 (key (nth 3 value)) | |
106 (where (nth 4 value)) | |
107 map | |
108 (maps (current-active-maps)) | |
109 mapsym) | |
110 ;; Look at the currently active keymaps and try to find | |
111 ;; first the keymap where the current binding occurs: | |
112 (while maps | |
113 (let* ((m (car maps)) | |
114 (mb (lookup-key m key t))) | |
115 (setq maps (cdr maps)) | |
116 (when (eq mb cb) | |
117 (setq map m) | |
118 (setq maps nil)))) | |
119 ;; Now, if a keymap was found we must found the symbol | |
120 ;; name for it to display to the user. This can not | |
121 ;; always be found since all keymaps does not have a | |
122 ;; symbol pointing to them, but here they should have | |
123 ;; that: | |
124 (when map | |
125 (mapatoms (lambda (s) | |
126 (and | |
127 ;; If not already found | |
128 (not mapsym) | |
129 ;; and if s is a keymap | |
130 (and (boundp s) | |
131 (keymapp (symbol-value s))) | |
132 ;; and not the local symbol map | |
133 (not (eq s 'map)) | |
134 ;; and the value of s is map | |
135 (eq map (symbol-value s)) | |
136 ;; then save this value in mapsym | |
137 (setq mapsym s))))) | |
138 (insert "The default Emacs binding for the key " | |
139 (key-description key) | |
140 " is the command `") | |
141 (insert (format "%s" db)) | |
142 (insert "'. " | |
143 "However, your customizations have rebound it to the command `") | |
144 (insert (format "%s" cb)) | |
145 (insert "'.") | |
146 (when mapsym | |
147 (insert " (For the more advanced user:" | |
148 " This binding is in the keymap `" | |
149 (format "%s" mapsym) | |
150 "'.)")) | |
151 (if (string= where "") | |
152 (unless (keymapp db) | |
153 (insert "\n\nYou can use M-x " | |
154 (format "%s" db) | |
155 " RET instead.")) | |
75069
49625651e125
(tutorial--describe-nonstandard-key): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
74797
diff
changeset
|
156 (insert "\n\nWith your current key bindings" |
73552 | 157 " you can use the key " |
158 where | |
159 " to get the function `" | |
160 (format "%s" db) | |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
161 "'."))) |
73552 | 162 (fill-region (point-min) (point))))) |
163 (print-help-return-message)))) | |
164 | |
165 (defun tutorial--sort-keys (left right) | |
166 "Sort predicate for use with `tutorial--default-keys'. | |
167 This is a predicate function to `sort'. | |
168 | |
169 The sorting is for presentation purpose only and is done on the | |
170 key sequence. | |
171 | |
172 LEFT and RIGHT are the elements to compare." | |
173 (let ((x (append (cadr left) nil)) | |
174 (y (append (cadr right) nil))) | |
175 ;; Skip the front part of the key sequences if they are equal: | |
176 (while (and x y | |
177 (listp x) (listp y) | |
178 (equal (car x) (car y))) | |
179 (setq x (cdr x)) | |
180 (setq y (cdr y))) | |
181 ;; Try to make a comparision that is useful for presentation (this | |
182 ;; could be made nicer perhaps): | |
183 (let ((cx (car x)) | |
184 (cy (car y))) | |
185 ;;(message "x=%s, y=%s;;;; cx=%s, cy=%s" x y cx cy) | |
186 (cond | |
187 ;; Lists? Then call this again | |
188 ((and cx cy | |
189 (listp cx) | |
190 (listp cy)) | |
191 (tutorial--sort-keys cx cy)) | |
192 ;; Are both numbers? Then just compare them | |
193 ((and (wholenump cx) | |
194 (wholenump cy)) | |
195 (> cx cy)) | |
196 ;; Is one of them a number? Let that be bigger then. | |
197 ((wholenump cx) | |
198 t) | |
199 ((wholenump cy) | |
200 nil) | |
201 ;; Are both symbols? Compare the names then. | |
202 ((and (symbolp cx) | |
203 (symbolp cy)) | |
204 (string< (symbol-name cy) | |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
205 (symbol-name cx))))))) |
73552 | 206 |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
207 (defconst tutorial--default-keys |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
208 ;; On window system, `suspend-emacs' is replaced in the default |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
209 ;; keymap |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
210 (let* ((suspend-emacs (if window-system |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
211 'iconify-or-deiconify-frame |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
212 'suspend-emacs)) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
213 (default-keys |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
214 `((ESC-prefix [27]) |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
215 (Control-X-prefix [?\C-x]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
216 (mode-specific-command-prefix [?\C-c]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
217 (save-buffers-kill-emacs [?\C-x ?\C-c]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
218 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
219 ;; * SUMMARY |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
220 (scroll-up [?\C-v]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
221 (scroll-down [?\M-v]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
222 (recenter [?\C-l]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
223 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
224 ;; * BASIC CURSOR CONTROL |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
225 (forward-char [?\C-f]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
226 (backward-char [?\C-b]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
227 (forward-word [?\M-f]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
228 (backward-word [?\M-b]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
229 (next-line [?\C-n]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
230 (previous-line [?\C-p]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
231 (move-beginning-of-line [?\C-a]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
232 (move-end-of-line [?\C-e]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
233 (backward-sentence [?\M-a]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
234 (forward-sentence [?\M-e]) |
74113
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
235 (newline "\r") |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
236 (beginning-of-buffer [?\M-<]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
237 (end-of-buffer [?\M->]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
238 (universal-argument [?\C-u]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
239 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
240 ;; * WHEN EMACS IS HUNG |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
241 (keyboard-quit [?\C-g]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
242 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
243 ;; * DISABLED COMMANDS |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
244 (downcase-region [?\C-x ?\C-l]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
245 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
246 ;; * WINDOWS |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
247 (delete-other-windows [?\C-x ?1]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
248 ;; C-u 0 C-l |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
249 ;; Type CONTROL-h k CONTROL-f. |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
250 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
251 ;; * INSERTING AND DELETING |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
252 ;; C-u 8 * to insert ********. |
74113
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
253 (delete-backward-char "\d") |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
254 (delete-char [?\C-d]) |
75471
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
255 (backward-kill-word [?\M-\d]) |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
256 (kill-word [?\M-d]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
257 (kill-line [?\C-k]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
258 (kill-sentence [?\M-k]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
259 (set-mark-command [?\C-@]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
260 (set-mark-command [?\C- ]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
261 (kill-region [?\C-w]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
262 (yank [?\C-y]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
263 (yank-pop [?\M-y]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
264 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
265 ;; * UNDO |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
266 (advertised-undo [?\C-x ?u]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
267 (advertised-undo [?\C-x ?u]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
268 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
269 ;; * FILES |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
270 (find-file [?\C-x ?\C-f]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
271 (save-buffer [?\C-x ?\C-s]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
272 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
273 ;; * BUFFERS |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
274 (list-buffers [?\C-x ?\C-b]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
275 (switch-to-buffer [?\C-x ?b]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
276 (save-some-buffers [?\C-x ?s]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
277 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
278 ;; * EXTENDING THE COMMAND SET |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
279 ;; C-x Character eXtend. Followed by one character. |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
280 (execute-extended-command [?\M-x]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
281 ;; C-x C-f Find file |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
282 ;; C-x C-s Save file |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
283 ;; C-x s Save some buffers |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
284 ;; C-x C-b List buffers |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
285 ;; C-x b Switch buffer |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
286 ;; C-x C-c Quit Emacs |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
287 ;; C-x 1 Delete all but one window |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
288 ;; C-x u Undo |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
289 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
290 ;; * MODE LINE |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
291 (describe-mode [?\C-h ?m]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
292 (set-fill-column [?\C-x ?f]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
293 (fill-paragraph [?\M-q]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
294 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
295 ;; * SEARCHING |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
296 (isearch-forward [?\C-s]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
297 (isearch-backward [?\C-r]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
298 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
299 ;; * MULTIPLE WINDOWS |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
300 (split-window-vertically [?\C-x ?2]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
301 (scroll-other-window [?\C-\M-v]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
302 (other-window [?\C-x ?o]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
303 (find-file-other-window [?\C-x ?4 ?\C-f]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
304 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
305 ;; * RECURSIVE EDITING LEVELS |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
306 (keyboard-escape-quit [27 27 27]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
307 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
308 ;; * GETTING MORE HELP |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
309 ;; The most basic HELP feature is C-h c |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
310 (describe-key-briefly [?\C-h ?c]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
311 (describe-key [?\C-h ?k]) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
312 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
313 ;; * MORE FEATURES |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
314 ;; F10 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
315 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
316 ;; * CONCLUSION |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
317 ;;(iconify-or-deiconify-frame [?\C-z]) |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
318 (,suspend-emacs [?\C-z])))) |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
319 (sort default-keys 'tutorial--sort-keys)) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
320 "Default Emacs key bindings that the tutorial depends on.") |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (defun tutorial--detailed-help (button) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 "Give detailed help about changed keys." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 (with-output-to-temp-buffer (help-buffer) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 (help-setup-xref (list #'tutorial--detailed-help button) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (interactive-p)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (with-current-buffer (help-buffer) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 (let* ((tutorial-buffer (button-get button 'tutorial-buffer)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 (explain-key-desc (button-get button 'explain-key-desc)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 (changed-keys (with-current-buffer tutorial-buffer |
74113
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
331 (save-excursion |
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
332 (goto-char (point-min)) |
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
333 (tutorial--find-changed-keys |
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
334 tutorial--default-keys))))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 (when changed-keys |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (insert |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 "The following key bindings used in the tutorial had been changed |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
338 from the Emacs default in the " (buffer-name tutorial-buffer) " buffer:\n\n" ) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 (let ((frm " %-9s %-27s %-11s %s\n")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 (insert (format frm "Key" "Standard Binding" "Is Now On" "Remark"))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (dolist (tk changed-keys) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (let* ((def-fun (nth 1 tk)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 (key (nth 0 tk)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (def-fun-txt (nth 2 tk)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (where (nth 3 tk)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 (remark (nth 4 tk)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 (rem-fun (command-remapping def-fun)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 (key-txt (key-description key)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (key-fun (with-current-buffer tutorial-buffer (key-binding key))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 tot-len) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (unless (eq def-fun key-fun) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 ;; Insert key binding description: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (when (string= key-txt explain-key-desc) |
74100
9b8e3f194cc1
(tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents:
73567
diff
changeset
|
354 (put-text-property 0 (length key-txt) |
9b8e3f194cc1
(tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents:
73567
diff
changeset
|
355 'face 'tutorial-warning-face key-txt)) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (insert " " key-txt " ") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 (setq tot-len (length key-txt)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 (when (> 9 tot-len) |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
359 (insert (make-string (- 9 tot-len) ?\s)) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 (setq tot-len 9)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 ;; Insert a link describing the old binding: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (insert-button def-fun-txt |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 'value def-fun |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 'action |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (lambda(button) (interactive) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 (describe-function |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (button-get button 'value))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 'follow-link t) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 (setq tot-len (+ tot-len (length def-fun-txt))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (when (> 36 tot-len) |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
371 (insert (make-string (- 36 tot-len) ?\s))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 (when (listp where) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 (setq where "list")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 ;; Tell where the old binding is now: |
74113
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
375 (insert (format " %-11s " |
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
376 (if (string= "" where) |
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
377 (format "M-x %s" def-fun-txt) |
3cc044eb98b7
(tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents:
74100
diff
changeset
|
378 where))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 ;; Insert a link with more information, for example |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 ;; current binding and keymap or information about |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 ;; cua-mode replacements: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (insert-button (car remark) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 'action |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 (lambda(b) (interactive) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 (let ((value (button-get b 'value))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 (tutorial--describe-nonstandard-key value))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 'value (cdr remark) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 'follow-link t) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (insert "\n"))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (insert " |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
392 It is OK to change key bindings, but changed bindings do not |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
393 correspond to what the tutorial says.\n\n") |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (print-help-return-message))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 (defun tutorial--find-changed-keys (default-keys) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
397 "Find the key bindings used in the tutorial that have changed. |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
398 Return a list with elements of the form |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
400 '(KEY DEF-FUN DEF-FUN-TXT WHERE REMARK QUIET) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
402 where |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 KEY is a key sequence whose standard binding has been changed |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 DEF-FUN is the standard binding of KEY |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 DEF-FUN-TXT is a short descriptive text for DEF-FUN |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 WHERE is a text describing the key sequences to which DEF-FUN is |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 bound now (or, if it is remapped, a key sequence |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 for the function it is remapped to) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 REMARK is a list with info about rebinding. It has either of these |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 formats: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 \(TEXT cua-mode) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 \(TEXT current-binding KEY-FUN DEF-FUN KEY WHERE) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 Here TEXT is a link text to show to the user. The |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 rest of the list is used to show information when |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 the user clicks the link. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
420 KEY-FUN is the actual binding for KEY. |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
421 QUIET is t if this changed keybinding should be handled quietly. |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
422 This is used by `tutorial--display-changes'." |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
423 (let (changed-keys remark) |
75471
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
424 ;; Look up the bindings in a Fundamental mode buffer |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
425 ;; so we do not get fooled by some other major mode. |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
426 (with-temp-buffer |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
427 (fundamental-mode) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
428 (dolist (kdf default-keys) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
429 ;; The variables below corresponds to those with the same names |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
430 ;; described in the doc string. |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
431 (let* ((key (nth 1 kdf)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
432 (def-fun (nth 0 kdf)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
433 (def-fun-txt (format "%s" def-fun)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
434 (rem-fun (command-remapping def-fun)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
435 (key-fun (if (eq def-fun 'ESC-prefix) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
436 (lookup-key global-map [27]) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
437 (key-binding key))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
438 (where (where-is-internal (if rem-fun rem-fun def-fun)))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
439 (if where |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
440 (progn |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
441 (setq where (key-description (car where))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
442 (when (and (< 10 (length where)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
443 (string= (substring where 0 (length "<menu-bar>")) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
444 "<menu-bar>")) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
445 (setq where "the menus"))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
446 (setq where "")) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
447 (setq remark nil) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
448 (unless |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
449 (cond ((eq key-fun def-fun) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
450 ;; No rebinding, return t |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
451 t) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
452 ((and key-fun |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
453 (eq key-fun (command-remapping def-fun))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
454 ;; Just a remapping, return t |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
455 t) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
456 ;; cua-mode specials: |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
457 ((and cua-mode |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
458 (or (and |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
459 (equal key [?\C-v]) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
460 (eq key-fun 'cua-paste)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
461 (and |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
462 (equal key [?\C-z]) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
463 (eq key-fun 'undo)))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
464 (setq remark (list "cua-mode, more info" 'cua-mode)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
465 nil) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
466 ((and cua-mode |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
467 (or (and (eq def-fun 'ESC-prefix) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
468 (equal key-fun |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
469 `(keymap |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
470 (118 . cua-repeat-replace-region))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
471 (setq def-fun-txt "\"ESC prefix\"")) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
472 (and (eq def-fun 'mode-specific-command-prefix) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
473 (equal key-fun |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
474 '(keymap |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
475 (timeout . copy-region-as-kill))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
476 (setq def-fun-txt "\"C-c prefix\"")) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
477 (and (eq def-fun 'Control-X-prefix) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
478 (equal key-fun |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
479 '(keymap (timeout . kill-region))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
480 (setq def-fun-txt "\"C-x prefix\"")))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
481 (setq remark (list "cua-mode replacement" 'cua-mode)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
482 (setq where "Same key") |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
483 nil) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
484 ;; viper-mode specials: |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
485 ((and (boundp 'viper-mode-string) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
486 (boundp 'viper-current-state) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
487 (eq viper-current-state 'vi-state) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
488 (or (and (eq def-fun 'isearch-forward) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
489 (eq key-fun 'viper-isearch-forward)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
490 (and (eq def-fun 'isearch-backward) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
491 (eq key-fun 'viper-isearch-backward)))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
492 ;; These bindings works as the default bindings, |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
493 ;; return t |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
494 t) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
495 ((when normal-erase-is-backspace |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
496 (or (and (equal key [C-delete]) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
497 (equal key-fun 'kill-word)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
498 (and (equal key [C-backspace]) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
499 (equal key-fun 'backward-kill-word)))) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
500 ;; This is the strange handling of C-delete and |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
501 ;; C-backspace, return t |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
502 t) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
503 (t |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
504 ;; This key has indeed been rebound. Put information |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
505 ;; in `remark' and return nil |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
506 (setq remark |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
507 (list "more info" 'current-binding |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
508 key-fun def-fun key where)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
509 nil)) |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
510 (add-to-list 'changed-keys |
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
511 (list key def-fun def-fun-txt where remark nil)))))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 changed-keys)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
514 (defun tutorial--key-description (key) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
515 (let ((desc (key-description key))) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
516 (cond ((string= "ESC" desc) "<ESC>") |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
517 ((string= "RET" desc) "<Return>") |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
518 ((string= "DEL" desc) "<Delback>") |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
519 (t desc)))) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
520 |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
521 (defun tutorial--display-changes () |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 "Display changes to some default key bindings. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 If some of the default key bindings that the tutorial depends on |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 have been changed then display the changes in the tutorial buffer |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
525 with some explanatory links." |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
526 (let* ((changed-keys (tutorial--find-changed-keys |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
527 tutorial--default-keys)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
528 ;; Alist of element (DESC . CK) where DESC is the |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
529 ;; key-description of a changed key and CK is the |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
530 ;; corresponding element in `changed-keys'. |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
531 (changed-keys-alist |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
532 (mapcar (lambda (ck) (cons (tutorial--key-description (car ck)) ck)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
533 changed-keys)) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
534 changed-key |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
535 (start (point)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
536 (case-fold-search nil) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
537 (keybindings-regexp |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
538 (concat "[[:space:]]\\(" |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
539 (mapconcat (lambda (kdf) (regexp-quote |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
540 (tutorial--key-description |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
541 (nth 1 kdf)))) |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
542 tutorial--default-keys |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
543 "\\|") |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
544 "\\)[[:punct:][:space:]]"))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 ;; Need the custom button face for viper buttons: |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
546 (if (boundp 'viper-mode-string) (require 'cus-edit)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
547 |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
548 (if (or changed-keys (boundp 'viper-mode-string)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
549 (let ((head (get-lang-string tutorial--lang 'tut-chgdhead)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
550 (head2 (get-lang-string tutorial--lang 'tut-chgdhead2))) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
551 (when (and head head2) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
552 (goto-char tutorial--point-before-chkeys) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
553 (insert head " [") |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
554 (insert-button head2 'tutorial-buffer (current-buffer) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
555 'action 'tutorial--detailed-help |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
556 'follow-link t 'face 'link) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
557 (insert "]\n\n") |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
558 (add-text-properties tutorial--point-before-chkeys (point) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
559 '(tutorial-remark remark |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
560 face tutorial-warning-face |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
561 read-only t))))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
563 ;; Scan the tutorial for all key sequences. |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
564 (goto-char (point-min)) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
565 (while (re-search-forward keybindings-regexp (point-max) t) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
566 ;; Then highlight each rebound key sequence. |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
567 ;; This avoids issuing a warning for, e.g., C-x C-b if C-b is rebound. |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
568 (setq changed-key (assoc (match-string 1) changed-keys-alist)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
569 (and changed-key |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
570 (not (get-text-property (match-beginning 1) 'tutorial-remark)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
571 (let* ((desc (car changed-key)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
572 (ck (cdr changed-key)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
573 (key (nth 0 ck)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
574 (def-fun (nth 1 ck)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
575 (where (nth 3 ck)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
576 s1 s2 help-string) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
577 (unless (string= where "Same key") |
75162
4ad75aa56c40
(tutorial--display-changes): Show M-x sequence if no
Chong Yidong <cyd@stupidchicken.com>
parents:
75069
diff
changeset
|
578 (when (string= where "") |
4ad75aa56c40
(tutorial--display-changes): Show M-x sequence if no
Chong Yidong <cyd@stupidchicken.com>
parents:
75069
diff
changeset
|
579 (setq where (format "M-x %s" def-fun))) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
580 (setq tutorial--point-after-chkeys (point-marker) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
581 s1 (get-lang-string tutorial--lang 'tut-chgdkey) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
582 s2 (get-lang-string tutorial--lang 'tut-chgdkey2) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
583 help-string (and s1 s2 (format s1 desc where))) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
584 (add-text-properties (match-beginning 1) (match-end 1) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
585 '(face tutorial-warning-face |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
586 tutorial-remark key-sequence)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
587 (if help-string |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
588 (if (nth 5 ck) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
589 ;; Put help string in the tooltip. |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
590 (put-text-property (match-beginning 1) (match-end 1) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
591 'help-echo help-string) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
592 ;; Put help string in the buffer. |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
593 (save-excursion |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
594 (setcar (nthcdr 5 ck) t) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
595 (forward-line) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
596 ;; Two or more changed keys were on the same line. |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
597 (while (eq (get-text-property (point) 'tutorial-remark) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
598 'remark) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
599 (forward-line)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
600 (setq start (point)) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
601 (insert "** " help-string " [") |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
602 (insert-button s2 'tutorial-buffer (current-buffer) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
603 'action 'tutorial--detailed-help |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
604 'explain-key-desc desc 'follow-link t |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
605 'face 'link) |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
606 (insert "] **\n") |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
607 (add-text-properties start (point) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
608 '(tutorial-remark remark |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
609 rear-nonsticky t |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
610 face tutorial-warning-face |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
611 read-only t))))))))))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 (defun tutorial--saved-dir () |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
614 "Directory to which tutorials are saved." |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
615 (expand-file-name "tutorial" |
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
616 (if (eq system-type 'ms-dos) "~/_emacs.d/" "~/.emacs.d/"))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 (defun tutorial--saved-file () |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 "File name in which to save tutorials." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 (let ((file-name tutorial--lang) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 (ext (file-name-extension tutorial--lang))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 (when (or (not ext) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 (string= ext "")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 (setq file-name (concat file-name ".tut"))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 (expand-file-name file-name (tutorial--saved-dir)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 |
75471
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
627 (defun tutorial--remove-remarks () |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 "Remove the remark lines that was added to the tutorial buffer." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 (save-excursion |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (goto-char (point-min)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 (let (prop-start |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 prop-end |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 prop-val) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 ;; Catch the case when we already are on a remark line |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (while (if (get-text-property (point) 'tutorial-remark) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 (setq prop-start (point)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 (setq prop-start (next-single-property-change (point) 'tutorial-remark))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 (setq prop-end (next-single-property-change prop-start 'tutorial-remark)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 (setq prop-val (get-text-property prop-start 'tutorial-remark)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 (unless prop-end |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 (setq prop-end (point-max))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 (goto-char prop-end) |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
643 (unless (eq prop-val 'key-sequence) |
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
644 (delete-region prop-start prop-end)))))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 (defun tutorial--save-tutorial () |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 "Save the tutorial buffer. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 This saves the part of the tutorial before and after the area |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 showing changed keys. It also saves the point position and the |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 position where the display of changed bindings was inserted." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
651 ;; This runs in a hook so protect it: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
652 (condition-case err |
74797
90a64762539d
(tutorial--save-tutorial): Prompt before saving tutorial state.
Chong Yidong <cyd@stupidchicken.com>
parents:
74795
diff
changeset
|
653 (if (y-or-n-p "Save your position in the tutorial? ") |
90a64762539d
(tutorial--save-tutorial): Prompt before saving tutorial state.
Chong Yidong <cyd@stupidchicken.com>
parents:
74795
diff
changeset
|
654 (tutorial--save-tutorial-to (tutorial--saved-file))) |
90a64762539d
(tutorial--save-tutorial): Prompt before saving tutorial state.
Chong Yidong <cyd@stupidchicken.com>
parents:
74795
diff
changeset
|
655 (error (message "Error saving tutorial state: %s" |
90a64762539d
(tutorial--save-tutorial): Prompt before saving tutorial state.
Chong Yidong <cyd@stupidchicken.com>
parents:
74795
diff
changeset
|
656 (error-message-string err))))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 (defun tutorial--save-tutorial-to (saved-file) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 "Save the tutorial buffer to SAVED-FILE. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 See `tutorial--save-tutorial' for more information." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 ;; Anything to save? |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 (when (or (buffer-modified-p) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 (< 1 (point))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
664 (let ((tutorial-dir (tutorial--saved-dir)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 save-err) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 ;; The tutorial is saved in a subdirectory in the user home |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 ;; directory. Create this subdirectory first. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 (unless (file-directory-p tutorial-dir) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 (condition-case err |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 (make-directory tutorial-dir nil) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 (error (setq save-err t) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 (warn "Could not create directory %s: %s" tutorial-dir |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 (error-message-string err))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 ;; Make sure we have that directory. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 (if (file-directory-p tutorial-dir) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 (let ((tut-point (if (= 0 tutorial--point-after-chkeys) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 ;; No info about changed keys is |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 ;; displayed. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 (point) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 (if (< (point) tutorial--point-after-chkeys) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 (- (point)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 (- (point) tutorial--point-after-chkeys)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 (old-point (point)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 ;; Use a special undo list so that we easily can undo |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 ;; the changes we make to the tutorial buffer. This is |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 ;; currently not needed since we now delete the buffer |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 ;; after saving, but kept for possible future use of |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 ;; this function. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 buffer-undo-list |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 (inhibit-read-only t)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 ;; Delete the area displaying info about changed keys. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 ;; (when (< 0 tutorial--point-after-chkeys) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 ;; (delete-region tutorial--point-before-chkeys |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 ;; tutorial--point-after-chkeys)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 ;; Delete the remarks: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (tutorial--remove-remarks) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 ;; Put the value of point first in the buffer so it will |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 ;; be saved with the tutorial. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (goto-char (point-min)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (insert (number-to-string tut-point) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 "\n" |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 (number-to-string (marker-position |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 tutorial--point-before-chkeys)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 "\n") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 (condition-case err |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 (write-region nil nil saved-file) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 (error (setq save-err t) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 (warn "Could not save tutorial to %s: %s" |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 saved-file |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 (error-message-string err)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 ;; An error is raised here?? Is this a bug? |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 (condition-case err |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (undo-only) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (error nil)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 ;; Restore point |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 (goto-char old-point) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 (if save-err |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 (message "Could not save tutorial state.") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 (message "Saved tutorial state."))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 (message "Can't save tutorial: %s is not a directory" |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 tutorial-dir))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 ;;;###autoload |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 (defun help-with-tutorial (&optional arg dont-ask-for-revert) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 "Select the Emacs learn-by-doing tutorial. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 If there is a tutorial version written in the language |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 of the selected language environment, that version is used. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 If there's no tutorial in that language, `TUTORIAL' is selected. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 With ARG, you are asked to choose which language. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 If DONT-ASK-FOR-REVERT is non-nil the buffer is reverted without |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 any question when restarting the tutorial. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 If any of the standard Emacs key bindings that are used in the |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 tutorial have been changed then an explanatory note about this is |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 shown in the beginning of the tutorial buffer. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 When the tutorial buffer is killed the content and the point |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 position in the buffer is saved so that the tutorial may be |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 resumed later." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 (interactive "P") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 (if (boundp 'viper-current-state) |
73551
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
743 (let ((prompt1 |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
744 "You can not run the Emacs tutorial directly because you have \ |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
745 enabled Viper.") |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
746 (prompt2 "\nThere is however a Viper tutorial you can run instead. |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
747 Run the Viper tutorial? ")) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
748 (if (fboundp 'viper-tutorial) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
749 (if (y-or-n-p (concat prompt1 prompt2)) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
750 (progn (message "") |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
751 (funcall 'viper-tutorial 0)) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
752 (message "Tutorial aborted by user")) |
8bd77d06776b
* tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents:
73550
diff
changeset
|
753 (message prompt1))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 (let* ((lang (if arg |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 (let ((minibuffer-setup-hook minibuffer-setup-hook)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 (add-hook 'minibuffer-setup-hook |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 'minibuffer-completion-help) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 (read-language-name 'tutorial "Language: " "English")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 (if (get-language-info current-language-environment 'tutorial) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 current-language-environment |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 "English"))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 (filename (get-language-info lang 'tutorial)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 ;; Choose a buffer name including the language so that |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 ;; several languages can be tested simultaneously: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 (tut-buf-name (concat "TUTORIAL (" lang ")")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 (old-tut-buf (get-buffer tut-buf-name)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (old-tut-win (when old-tut-buf (get-buffer-window old-tut-buf t))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 (old-tut-is-ok (when old-tut-buf |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (not (buffer-modified-p old-tut-buf)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 old-tut-file |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 (old-tut-point 1)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 (setq tutorial--point-after-chkeys (point-min)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 ;; Try to display the tutorial buffer before asking to revert it. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 ;; If the tutorial buffer is shown in some window make sure it is |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 ;; selected and displayed: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 (if old-tut-win |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 (raise-frame |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 (window-frame |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 (select-window (get-buffer-window old-tut-buf t)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 ;; Else, is there an old tutorial buffer? Then display it: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 (when old-tut-buf |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 (switch-to-buffer old-tut-buf))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 ;; Use whole frame for tutorial |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 (delete-other-windows) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 ;; If the tutorial buffer has been changed then ask if it should |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 ;; be reverted: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 (when (and old-tut-buf |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 (not old-tut-is-ok)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 (setq old-tut-is-ok |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (if dont-ask-for-revert |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 nil |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 (not (y-or-n-p |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 "You have changed the Tutorial buffer. Revert it? "))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 ;; (Re)build the tutorial buffer if it is not ok |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 (unless old-tut-is-ok |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 (switch-to-buffer (get-buffer-create tut-buf-name)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 (unless old-tut-buf (text-mode)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 (unless lang (error "Variable lang is nil")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (setq tutorial--lang lang) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 (setq old-tut-file (file-exists-p (tutorial--saved-file))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 (let ((inhibit-read-only t)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 (erase-buffer)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 (message "Preparing tutorial ...") (sit-for 0) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
805 ;; Do not associate the tutorial buffer with a file. Instead use |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 ;; a hook to save it when the buffer is killed. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 (setq buffer-auto-save-file-name nil) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 (add-hook 'kill-buffer-hook 'tutorial--save-tutorial nil t) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
809 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 ;; Insert the tutorial. First offer to resume last tutorial |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 ;; editing session. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 (when dont-ask-for-revert |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 (setq old-tut-file nil)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 (when old-tut-file |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
815 (setq old-tut-file |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 (y-or-n-p "Resume your last saved tutorial? "))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 (if old-tut-file |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 (progn |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 (insert-file-contents (tutorial--saved-file)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 (goto-char (point-min)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (setq old-tut-point |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 (string-to-number |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 (buffer-substring-no-properties |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 (line-beginning-position) (line-end-position)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 (forward-line) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 (setq tutorial--point-before-chkeys |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 (string-to-number |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 (buffer-substring-no-properties |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 (line-beginning-position) (line-end-position)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 (forward-line) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 (delete-region (point-min) (point)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 (goto-char tutorial--point-before-chkeys) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 (setq tutorial--point-before-chkeys (point-marker))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 (insert-file-contents (expand-file-name filename data-directory)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 (forward-line) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 (setq tutorial--point-before-chkeys (point-marker))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
838 (tutorial--display-changes) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 ;; Clear message: |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 (unless dont-ask-for-revert |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 (message "") (sit-for 0)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
844 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
845 (if old-tut-file |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
846 ;; Just move to old point in saved tutorial. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 (let ((old-point |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 (if (> 0 old-tut-point) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
849 (- old-tut-point) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 (+ old-tut-point tutorial--point-after-chkeys)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 (when (< old-point 1) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 (setq old-point 1)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 (goto-char old-point)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 (goto-char (point-min)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
855 (search-forward "\n<<") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 (beginning-of-line) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
857 ;; Convert the <<...>> line to the proper [...] line, |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
858 ;; or just delete the <<...>> line if a [...] line follows. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 (cond ((save-excursion |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
860 (forward-line 1) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 (looking-at "\\[")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 (delete-region (point) (progn (forward-line 1) (point)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 ((looking-at "<<Blank lines inserted.*>>") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 (replace-match "[Middle of page left blank for didactic purposes. Text continues below]")) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 (t |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
866 (looking-at "<<") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
867 (replace-match "[") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
868 (search-forward ">>") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
869 (replace-match "]"))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
870 (beginning-of-line) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
871 (let ((n (- (window-height (selected-window)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
872 (count-lines (point-min) (point)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 6))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
874 (if (< n 8) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
875 (progn |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 ;; For a short gap, we don't need the [...] line, |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 ;; so delete it. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
878 (delete-region (point) (progn (end-of-line) (point))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
879 (newline n)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 ;; Some people get confused by the large gap. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
881 (newline (/ n 2)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
882 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 ;; Skip the [...] line (don't delete it). |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 (forward-line 1) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
885 (newline (- n (/ n 2))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 (goto-char (point-min))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 (setq buffer-undo-list nil) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 (set-buffer-modified-p nil))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
891 ;; Below is some attempt to handle language specific strings. These |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
892 ;; are currently only used in the tutorial. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 (defconst lang-strings |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
895 '(("English" . |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
896 ((tut-chgdkey . "%s has been rebound, but you can use %s instead") |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
897 (tut-chgdkey2 . "More") |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
898 (tut-chgdhead . " |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 NOTICE: The main purpose of the Emacs tutorial is to teach you |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 the most important standard Emacs commands (key bindings). |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 However, your Emacs has been customized by changing some of |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 these basic editing commands, so it doesn't correspond to the |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 tutorial. We have inserted colored notices where the altered |
74795
4404b91f3a72
(tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents:
74789
diff
changeset
|
904 commands have been introduced.") |
74789
ecc3f98301f4
Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents:
74113
diff
changeset
|
905 (tut-chgdhead2 . "More")))) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
906 "Language specific strings for Emacs. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 This is an association list with the keys equal to the strings |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 that can be returned by `read-language-name'. The elements in |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 the list are themselves association lists with keys that are |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
910 string ids and values that are the language specific strings. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 See `get-lang-string' for more information.") |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 |
75471
afea84ac9ef8
(tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
914 (defun get-lang-string (lang stringid &optional no-eng-fallback) |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 "Get a language specific string for Emacs. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 In certain places Emacs can replace a string showed to the user with a language specific string. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 This function retrieves such strings. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
918 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 LANG is the language specification. It should be one of those |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 strings that can be returned by `read-language-name'. STRINGID |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 is a symbol that specifies the string to retrieve. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 If no string is found for STRINGID in the choosen language then |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 the English string is returned unless NO-ENG-FALLBACK is non-nil. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 See `lang-strings' for more information. |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 Currently this feature is only used in `help-with-tutorial'." |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 (let ((my-lang-strings (assoc lang lang-strings)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (found-string)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 (when my-lang-strings |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
932 (let ((entry (assoc stringid (cdr my-lang-strings)))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 (when entry |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
934 (setq found-string (cdr entry))))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
935 ;; Fallback to English strings |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 (unless (or found-string |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
937 no-eng-fallback) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 (setq found-string (get-lang-string "English" stringid t))) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 found-string)) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 ;;(get-lang-string "English" 'tut-chgdkey) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 (provide 'tutorial) |
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 |
73567 | 945 ;; arch-tag: c8e80aef-c3bb-4ffb-8af6-22171bf0c100 |
73550
6deaec97f21b
* help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 ;;; tutorial.el ends here |