annotate lisp/tutorial.el @ 112446:f60dc8d74215

mm-decode.el (mm-inline-media-tests): Change text/org to text/x-org. mm-uu.el (mm-uu-org-src-code-block-extract): Change text/org to text/x-org.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sun, 23 Jan 2011 11:21:04 +0000
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 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
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109722
diff changeset
7 ;; Package: emacs
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; 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
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92679
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92679
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92679
diff changeset
14 ;; (at your option) any later version.
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; 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
17 ;; 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
18 ;; 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
19 ;; 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
20
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92679
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; 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
27
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;; History:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; File was created 2006-09.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;;; Code:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 (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
35
74100
9b8e3f194cc1 (tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents: 73567
diff changeset
36 (defface tutorial-warning-face
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
37 '((t :inherit font-lock-warning-face))
74100
9b8e3f194cc1 (tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents: 73567
diff changeset
38 "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
39 :group 'help)
74100
9b8e3f194cc1 (tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents: 73567
diff changeset
40
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
41 (defvar tutorial--point-before-chkeys 0
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
42 "Point before display of key changes.")
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
43 (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
44
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
45 (defvar tutorial--point-after-chkeys 0
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
46 "Point after display of key changes.")
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
47 (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
48
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
49 (defvar tutorial--lang nil
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
50 "Tutorial language.")
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
51 (make-variable-buffer-local 'tutorial--lang)
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
52
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
53 (defun tutorial--describe-nonstandard-key (value)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
54 "Give more information about a changed key binding.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
55 This is used in `help-with-tutorial'. The information includes
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
56 the key sequence that no longer has a default binding, the
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
57 default binding and the current binding. It also tells in what
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
58 keymap the new binding has been done and how to access the
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
59 function in the default binding from the keyboard.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
60
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
61 For `cua-mode' key bindings that try to combine CUA key bindings
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
62 with default Emacs bindings information about this is shown.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
63
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
64 VALUE should have either of these formats:
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
65
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
66 \(cua-mode)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
67 \(current-binding KEY-FUN DEF-FUN KEY WHERE)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
68
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
69 Where
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
70 KEY is a key sequence whose standard binding has been changed
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
71 KEY-FUN is the actual binding for KEY
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
72 DEF-FUN is the standard binding of KEY
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
73 WHERE is a text describing the key sequences to which DEF-FUN is
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
74 bound now (or, if it is remapped, a key sequence
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
75 for the function it is remapped to)"
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
76 (with-output-to-temp-buffer (help-buffer)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
77 (help-setup-xref (list #'tutorial--describe-nonstandard-key value)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104922
diff changeset
78 (called-interactively-p 'interactive))
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
79 (with-current-buffer (help-buffer)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
80 (insert
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
81 "Your Emacs customizations override the default binding for this key:"
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
82 "\n\n")
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
83 (let ((inhibit-read-only t))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
84 (cond
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
85 ((eq (car value) 'cua-mode)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
86 (insert
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
87 "CUA mode is enabled.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
88
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
89 When CUA mode is enabled, you can use C-z, C-x, C-c, and C-v to
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
90 undo, cut, copy, and paste in addition to the normal Emacs
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
91 bindings. The C-x and C-c keys only do cut and copy when the
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
92 region is active, so in most cases, they do not conflict with the
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
93 normal function of these prefix keys.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
94
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
95 If you really need to perform a command which starts with one of
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
96 the prefix keys even when the region is active, you have three
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
97 options:
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
98 - press the prefix key twice very quickly (within 0.2 seconds),
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
99 - press the prefix key and the following key within 0.2 seconds, or
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
100 - use the SHIFT key with the prefix key, i.e. C-S-x or C-S-c."))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
101 ((eq (car value) 'current-binding)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
102 (let ((cb (nth 1 value))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
103 (db (nth 2 value))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
104 (key (nth 3 value))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
105 (where (nth 4 value))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
106 map
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
107 (maps (current-active-maps))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
108 mapsym)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
109 ;; Look at the currently active keymaps and try to find
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
110 ;; first the keymap where the current binding occurs:
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
111 (while maps
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
112 (let* ((m (car maps))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
113 (mb (lookup-key m key t)))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
114 (setq maps (cdr maps))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
115 (when (eq mb cb)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
116 (setq map m)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
117 (setq maps nil))))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
118 ;; Now, if a keymap was found we must found the symbol
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
119 ;; name for it to display to the user. This can not
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
120 ;; always be found since all keymaps does not have a
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
121 ;; symbol pointing to them, but here they should have
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
122 ;; that:
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
123 (when map
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
124 (mapatoms (lambda (s)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
125 (and
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
126 ;; If not already found
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
127 (not mapsym)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
128 ;; and if s is a keymap
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
129 (and (boundp s)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
130 (keymapp (symbol-value s)))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
131 ;; and not the local symbol map
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
132 (not (eq s 'map))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
133 ;; and the value of s is map
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
134 (eq map (symbol-value s))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
135 ;; then save this value in mapsym
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
136 (setq mapsym s)))))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
137 (insert "The default Emacs binding for the key "
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
138 (key-description key)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
139 " is the command `")
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
140 (insert (format "%s" db))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
141 (insert "'. "
103768
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
142 "However, your customizations have "
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
143 (if cb
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
144 (format "rebound it to the command `%s'" cb)
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
145 "unbound it"))
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
146 (insert ".")
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
147 (when mapsym
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
148 (insert " (For the more advanced user:"
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
149 " This binding is in the keymap `"
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
150 (format "%s" mapsym)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
151 "'.)"))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
152 (if (string= where "")
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
153 (unless (keymapp db)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
154 (insert "\n\nYou can use M-x "
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
155 (format "%s" db)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
156 " RET instead."))
75069
49625651e125 (tutorial--describe-nonstandard-key): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 74797
diff changeset
157 (insert "\n\nWith your current key bindings"
76210
ef62cc69bfdd (tutorial--describe-nonstandard-key): Tweak text in the menus case.
Glenn Morris <rgm@gnu.org>
parents: 75557
diff changeset
158 " you can use "
81215
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
159 (if (string-match "^the .*menus?$" where)
76210
ef62cc69bfdd (tutorial--describe-nonstandard-key): Tweak text in the menus case.
Glenn Morris <rgm@gnu.org>
parents: 75557
diff changeset
160 ""
81215
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
161 "the key")
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
162 where
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
163 " to get the function `"
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
164 (format "%s" db)
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
165 "'.")))
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
166 (fill-region (point-min) (point)))))
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 103768
diff changeset
167 (help-print-return-message))))
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
168
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
169 (defun tutorial--sort-keys (left right)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
170 "Sort predicate for use with `tutorial--default-keys'.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
171 This is a predicate function to `sort'.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
172
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
173 The sorting is for presentation purpose only and is done on the
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
174 key sequence.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
175
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
176 LEFT and RIGHT are the elements to compare."
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
177 (let ((x (append (cadr left) nil))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
178 (y (append (cadr right) nil)))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
179 ;; Skip the front part of the key sequences if they are equal:
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
180 (while (and x y
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
181 (listp x) (listp y)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
182 (equal (car x) (car y)))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
183 (setq x (cdr x))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
184 (setq y (cdr y)))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
185 ;; Try to make a comparision that is useful for presentation (this
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
186 ;; could be made nicer perhaps):
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
187 (let ((cx (car x))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
188 (cy (car y)))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
189 ;;(message "x=%s, y=%s;;;; cx=%s, cy=%s" x y cx cy)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
190 (cond
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
191 ;; Lists? Then call this again
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
192 ((and cx cy
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
193 (listp cx)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
194 (listp cy))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
195 (tutorial--sort-keys cx cy))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
196 ;; Are both numbers? Then just compare them
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
197 ((and (wholenump cx)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
198 (wholenump cy))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
199 (> cx cy))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
200 ;; Is one of them a number? Let that be bigger then.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
201 ((wholenump cx)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
202 t)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
203 ((wholenump cy)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
204 nil)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
205 ;; Are both symbols? Compare the names then.
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
206 ((and (symbolp cx)
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
207 (symbolp cy))
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
208 (string< (symbol-name cy)
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
209 (symbol-name cx)))))))
73552
7063b0e05658 Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 73551
diff changeset
210
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
211 (defconst tutorial--default-keys
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
212 ;; 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
213 ;; keymap
85071
7ad3fd2afe10 (tutorial--default-keys): Replace fill-paragraph
Juri Linkov <juri@jurta.org>
parents: 84792
diff changeset
214 (let* ((suspend-emacs 'suspend-frame)
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
215 (default-keys
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
216 `((ESC-prefix [27])
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
217 (Control-X-prefix [?\C-x])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
218 (mode-specific-command-prefix [?\C-c])
84792
8ba01ffe2626 (tutorial--default-keys): Update standard bindings:
Juri Linkov <juri@jurta.org>
parents: 82729
diff changeset
219 (save-buffers-kill-terminal [?\C-x ?\C-c])
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
220
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
221 ;; * SUMMARY
107853
de5ba6f3514c Bind `C-v' to `scroll-up-command' and `M-v' to `scroll-down-command'.
Juri Linkov <juri@jurta.org>
parents: 106815
diff changeset
222 (scroll-up-command [?\C-v])
de5ba6f3514c Bind `C-v' to `scroll-up-command' and `M-v' to `scroll-down-command'.
Juri Linkov <juri@jurta.org>
parents: 106815
diff changeset
223 (scroll-down-command [?\M-v])
92679
af85aa43295d (tutorial--default-keys): Update `C-l' binding.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 87649
diff changeset
224 (recenter-top-bottom [?\C-l])
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
225
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
226 ;; * BASIC CURSOR CONTROL
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
227 (forward-char [?\C-f])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
228 (backward-char [?\C-b])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
229 (forward-word [?\M-f])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
230 (backward-word [?\M-b])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
231 (next-line [?\C-n])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
232 (previous-line [?\C-p])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
233 (move-beginning-of-line [?\C-a])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
234 (move-end-of-line [?\C-e])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
235 (backward-sentence [?\M-a])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
236 (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
237 (newline "\r")
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
238 (beginning-of-buffer [?\M-<])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
239 (end-of-buffer [?\M->])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
240 (universal-argument [?\C-u])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
241
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
242 ;; * WHEN EMACS IS HUNG
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
243 (keyboard-quit [?\C-g])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
244
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
245 ;; * DISABLED COMMANDS
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
246 (downcase-region [?\C-x ?\C-l])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
247
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
248 ;; * WINDOWS
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
249 (delete-other-windows [?\C-x ?1])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
250 ;; C-u 0 C-l
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
251 ;; Type CONTROL-h k CONTROL-f.
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
252
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
253 ;; * INSERTING AND DELETING
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
254 ;; 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
255 (delete-backward-char "\d")
109722
028db67bd5dd * tutorial.el (tutorial--default-keys): C-d is now bound to delete-forward-char.
Chong Yidong <cyd@stupidchicken.com>
parents: 109674
diff changeset
256 (delete-forward-char [?\C-d])
75471
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
257 (backward-kill-word [?\M-\d])
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
258 (kill-word [?\M-d])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
259 (kill-line [?\C-k])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
260 (kill-sentence [?\M-k])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
261 (set-mark-command [?\C-@])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
262 (set-mark-command [?\C- ])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
263 (kill-region [?\C-w])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
264 (yank [?\C-y])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
265 (yank-pop [?\M-y])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
266
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
267 ;; * UNDO
104922
c603ee2aac17 * keymap.c (QCadvertised_binding): New constant.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104386
diff changeset
268 (undo [?\C-x ?u])
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
269
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
270 ;; * FILES
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
271 (find-file [?\C-x ?\C-f])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
272 (save-buffer [?\C-x ?\C-s])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
273
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
274 ;; * BUFFERS
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
275 (list-buffers [?\C-x ?\C-b])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
276 (switch-to-buffer [?\C-x ?b])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
277 (save-some-buffers [?\C-x ?s])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
278
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
279 ;; * EXTENDING THE COMMAND SET
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
280 ;; 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
281 (execute-extended-command [?\M-x])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
282 ;; C-x C-f Find file
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
283 ;; C-x C-s Save file
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
284 ;; C-x s Save some buffers
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
285 ;; C-x C-b List buffers
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
286 ;; C-x b Switch buffer
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
287 ;; C-x C-c Quit Emacs
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
288 ;; 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
289 ;; C-x u Undo
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
290
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
291 ;; * MODE LINE
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
292 (describe-mode [?\C-h ?m])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
293 (set-fill-column [?\C-x ?f])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
294 (fill-paragraph [?\M-q])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
295
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
296 ;; * SEARCHING
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
297 (isearch-forward [?\C-s])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
298 (isearch-backward [?\C-r])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
299
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
300 ;; * MULTIPLE WINDOWS
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
301 (split-window-vertically [?\C-x ?2])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
302 (scroll-other-window [?\C-\M-v])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
303 (other-window [?\C-x ?o])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
304 (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
305
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
306 ;; * RECURSIVE EDITING LEVELS
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
307 (keyboard-escape-quit [27 27 27])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
308
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
309 ;; * GETTING MORE HELP
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
310 ;; 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
311 (describe-key-briefly [?\C-h ?c])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
312 (describe-key [?\C-h ?k])
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
313
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
314 ;; * MORE FEATURES
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
315 ;; F10
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
316
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
317 ;; * CONCLUSION
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
318 ;;(iconify-or-deiconify-frame [?\C-z])
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
319 (,suspend-emacs [?\C-z]))))
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
320 (sort default-keys 'tutorial--sort-keys))
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
321 "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
322
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (defun tutorial--detailed-help (button)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 "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
325 (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
326 (help-setup-xref (list #'tutorial--detailed-help button)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104922
diff changeset
327 (called-interactively-p 'interactive))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (with-current-buffer (help-buffer)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (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
330 (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
331 (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
332 (save-excursion
3cc044eb98b7 (tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents: 74100
diff changeset
333 (goto-char (point-min))
3cc044eb98b7 (tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents: 74100
diff changeset
334 (tutorial--find-changed-keys
3cc044eb98b7 (tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents: 74100
diff changeset
335 tutorial--default-keys)))))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (when changed-keys
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (insert
75557
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
338 "The following key bindings used in the tutorial have been changed
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
339 from the Emacs default:\n\n" )
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
340 (let ((frm " %-14s %-27s %-16s\n"))
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
341 (insert (format frm
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
342 "Standard Key" "Command" "In Your Emacs")))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (dolist (tk changed-keys)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 (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
345 (key (nth 0 tk))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (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
347 (where (nth 3 tk))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (remark (nth 4 tk))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (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
350 (key-txt (key-description key))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (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
352 tot-len)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (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
354 ;; Insert key binding description:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (when (string= key-txt explain-key-desc)
74100
9b8e3f194cc1 (tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents: 73567
diff changeset
356 (put-text-property 0 (length key-txt)
9b8e3f194cc1 (tutorial-warning-face): New face.
Chong Yidong <cyd@stupidchicken.com>
parents: 73567
diff changeset
357 '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
358 (insert " " key-txt " ")
75557
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
359 (indent-to 18)
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 ;; 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
361 (insert-button def-fun-txt
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 'value def-fun
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 'action
75557
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
364 (lambda (button) (interactive)
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (describe-function
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (button-get button 'value)))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 'follow-link t)
75557
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
368 (indent-to 45)
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (when (listp where)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 (setq where "list"))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; Tell where the old binding is now:
75557
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
372 (insert (format " %-16s "
74113
3cc044eb98b7 (tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents: 74100
diff changeset
373 (if (string= "" where)
3cc044eb98b7 (tutorial--default-keys): Add newline and delete-backward-char bindings.
Chong Yidong <cyd@stupidchicken.com>
parents: 74100
diff changeset
374 (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
375 where)))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 ;; 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
377 ;; 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
378 ;; cua-mode replacements:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (insert-button (car remark)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 'action
75557
21cbf755a07c (tutorial--detailed-help): Make the list of changed keys look nicer.
Richard M. Stallman <rms@gnu.org>
parents: 75471
diff changeset
381 (lambda (b) (interactive)
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (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
383 (tutorial--describe-nonstandard-key value)))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 'value (cdr remark)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 'follow-link t)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (insert "\n")))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (insert "
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
389 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
390 correspond to what the tutorial says.\n\n")
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 103768
diff changeset
391 (help-print-return-message)))))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (defun tutorial--find-changed-keys (default-keys)
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
394 "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
395 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
396
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
397 '(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
398
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
399 where
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 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
402 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
403 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
404 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
405 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
406 for the function it is remapped to)
81215
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
407 REMARK is a list with info about rebinding. It has either of
77717
88eb7407b1e4 (get-lang-string, tutorial--find-changed-keys): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 76210
diff changeset
408 these formats:
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 \(TEXT cua-mode)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 \(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
412
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 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
414 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
415 the user clicks the link.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
417 KEY-FUN is the actual binding for KEY.
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
418 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
419 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
420 (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
421 ;; 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
422 ;; 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
423 (with-temp-buffer
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
424 (fundamental-mode)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
425 (dolist (kdf default-keys)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
426 ;; 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
427 ;; 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
428 (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
429 (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
430 (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
431 (rem-fun (command-remapping def-fun))
78136
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
432 ;; Handle prefix definitions specially
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
433 ;; so that a mode that rebinds some subcommands
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
434 ;; won't make it appear that the whole prefix is gone.
75471
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])
78136
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
437 (if (eq def-fun 'Control-X-prefix)
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
438 (lookup-key global-map [24])
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
439 (key-binding key))))
81215
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
440 (where (where-is-internal (if rem-fun rem-fun def-fun)))
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
441 cwhere)
78136
35849fc29fa6 (tutorial--find-changed-keys): Handle C-x specially like ESC.
Richard M. Stallman <rms@gnu.org>
parents: 77717
diff changeset
442
75471
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
443 (if where
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
444 (progn
81215
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
445 (setq cwhere (car where)
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
446 where (key-description cwhere))
75471
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
447 (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
448 (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
449 "<menu-bar>"))
81215
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
450 (setq where
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
451 (if (and (vectorp cwhere)
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
452 (setq cwhere (elt cwhere 1))
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
453 (setq cwhere
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
454 (cadr
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
455 (assoc cwhere
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
456 (lookup-key global-map
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
457 [menu-bar]))))
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
458 (stringp cwhere))
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
459 (format "the `%s' menu" cwhere)
569dae55f278 (tutorial--describe-nonstandard-key): Adjust for new
Glenn Morris <rgm@gnu.org>
parents: 77717
diff changeset
460 "the menus"))))
75471
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
461 (setq where ""))
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
462 (setq remark nil)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
463 (unless
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
464 (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
465 ;; No rebinding, return t
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
466 t)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
467 ((and key-fun
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
468 (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
469 ;; 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
470 t)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
471 ;; cua-mode specials:
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
472 ((and cua-mode
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
473 (or (and
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
474 (equal key [?\C-v])
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
475 (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
476 (and
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
477 (equal key [?\C-z])
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
478 (eq key-fun 'undo))))
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
479 (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
480 nil)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
481 ((and cua-mode
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
482 (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
483 (equal key-fun
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
484 `(keymap
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
485 (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
486 (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
487 (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
488 (equal key-fun
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
489 '(keymap
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
490 (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
491 (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
492 (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
493 (equal key-fun
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
494 '(keymap (timeout . kill-region)))
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
495 (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
496 (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
497 (setq where "Same key")
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
498 nil)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
499 ;; viper-mode specials:
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
500 ((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
501 (boundp 'viper-current-state)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
502 (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
503 (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
504 (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
505 (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
506 (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
507 ;; 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
508 ;; return t
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
509 t)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
510 ((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
511 (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
512 (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
513 (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
514 (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
515 ;; 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
516 ;; C-backspace, return t
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
517 t)
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
518 (t
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
519 ;; 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
520 ;; 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
521 (setq remark
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
522 (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
523 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
524 nil))
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
525 (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
526 (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
527 changed-keys))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
529 (defun tutorial--key-description (key)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
530 (let ((desc (key-description key)))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
531 (cond ((string= "ESC" desc) "<ESC>")
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
532 ((string= "RET" desc) "<Return>")
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
533 ((string= "DEL" desc) "<Delback>")
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
534 (t desc))))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
535
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
536 (defun tutorial--display-changes ()
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 "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
538 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
539 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
540 with some explanatory links."
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
541 (let* ((changed-keys (tutorial--find-changed-keys
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 ;; 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
544 ;; 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
545 ;; corresponding element in `changed-keys'.
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
546 (changed-keys-alist
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
547 (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
548 changed-keys))
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
549 changed-key
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
550 (start (point))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
551 (case-fold-search nil)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
552 (keybindings-regexp
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
553 (concat "[[:space:]]\\("
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
554 (mapconcat (lambda (kdf) (regexp-quote
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
555 (tutorial--key-description
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
556 (nth 1 kdf))))
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
557 tutorial--default-keys
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
558 "\\|")
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
559 "\\)[[:punct:][:space:]]")))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 ;; 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
561 (if (boundp 'viper-mode-string) (require 'cus-edit))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
562
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
563 (if (or changed-keys (boundp 'viper-mode-string))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
564 (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
565 (head2 (get-lang-string tutorial--lang 'tut-chgdhead2)))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
566 (when (and head head2)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
567 (goto-char tutorial--point-before-chkeys)
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
568 (insert head " [")
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
569 (insert-button head2 'tutorial-buffer (current-buffer)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
570 'action 'tutorial--detailed-help
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
571 'follow-link t 'face 'link)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
572 (insert "]\n\n")
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
573 (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
574 '(tutorial-remark remark
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
575 face tutorial-warning-face
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
576 read-only t)))))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
578 ;; Scan the tutorial for all key sequences.
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
579 (goto-char (point-min))
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
580 (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
581 ;; Then highlight each rebound key sequence.
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
582 ;; 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
583 (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
584 (and changed-key
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
585 (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
586 (let* ((desc (car changed-key))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
587 (ck (cdr changed-key))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
588 (key (nth 0 ck))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
589 (def-fun (nth 1 ck))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
590 (where (nth 3 ck))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
591 s1 s2 help-string)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
592 (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
593 (when (string= where "")
4ad75aa56c40 (tutorial--display-changes): Show M-x sequence if no
Chong Yidong <cyd@stupidchicken.com>
parents: 75069
diff changeset
594 (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
595 (setq tutorial--point-after-chkeys (point-marker)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
596 s1 (get-lang-string tutorial--lang 'tut-chgdkey)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
597 s2 (get-lang-string tutorial--lang 'tut-chgdkey2)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
598 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
599 (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
600 '(face tutorial-warning-face
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
601 tutorial-remark key-sequence))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
602 (if help-string
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
603 (if (nth 5 ck)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
604 ;; Put help string in the tooltip.
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
605 (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
606 'help-echo help-string)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
607 ;; Put help string in the buffer.
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
608 (save-excursion
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
609 (setcar (nthcdr 5 ck) t)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
610 (forward-line)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
611 ;; 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
612 (while (eq (get-text-property (point) 'tutorial-remark)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
613 'remark)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
614 (forward-line))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
615 (setq start (point))
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
616 (insert "** " help-string " [")
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
617 (insert-button s2 'tutorial-buffer (current-buffer)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
618 'action 'tutorial--detailed-help
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
619 'explain-key-desc desc 'follow-link t
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
620 'face 'link)
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
621 (insert "] **\n")
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
622 (add-text-properties start (point)
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
623 '(tutorial-remark remark
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
624 rear-nonsticky t
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
625 face tutorial-warning-face
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
626 read-only t)))))))))))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 (defun tutorial--saved-dir ()
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
629 "Directory to which tutorials are saved."
99106
814d2d823dd7 New function `locate-user-emacs-file'.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
630 (locate-user-emacs-file "tutorial/"))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 (defun tutorial--saved-file ()
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 "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
634 (let ((file-name tutorial--lang)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (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
636 (when (or (not ext)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 (string= ext ""))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 (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
639 (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
640
75471
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
641 (defun tutorial--remove-remarks ()
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 "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
643 (save-excursion
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (goto-char (point-min))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 (let (prop-start
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 prop-end
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 prop-val)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 ;; 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
649 (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
650 (setq prop-start (point))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 (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
652 (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
653 (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
654 (unless prop-end
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 (setq prop-end (point-max)))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (goto-char prop-end)
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
657 (unless (eq prop-val 'key-sequence)
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
658 (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
659
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 (defun tutorial--save-tutorial ()
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 "Save the tutorial buffer.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 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
663 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
664 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
665 ;; 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
666 (condition-case err
74797
90a64762539d (tutorial--save-tutorial): Prompt before saving tutorial state.
Chong Yidong <cyd@stupidchicken.com>
parents: 74795
diff changeset
667 (if (y-or-n-p "Save your position in the tutorial? ")
79129
2d9343a3760e Display message when tutorial position is not saved
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78236
diff changeset
668 (tutorial--save-tutorial-to (tutorial--saved-file))
2d9343a3760e Display message when tutorial position is not saved
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78236
diff changeset
669 (message "Tutorial position not saved"))
74797
90a64762539d (tutorial--save-tutorial): Prompt before saving tutorial state.
Chong Yidong <cyd@stupidchicken.com>
parents: 74795
diff changeset
670 (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
671 (error-message-string err)))))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 (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
674 "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
675 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
676 ;; Anything to save?
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (when (or (buffer-modified-p)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 (< 1 (point)))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 (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
680 save-err)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 ;; 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
682 ;; directory. Create this subdirectory first.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 (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
684 (condition-case err
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (make-directory tutorial-dir nil)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (error (setq save-err t)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 (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
688 (error-message-string err)))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 ;; 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
690 (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
691 (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
692 ;; 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
693 ;; displayed.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 (point)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 (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
696 (- (point))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 (- (point) tutorial--point-after-chkeys))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 (old-point (point))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 ;; 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
700 ;; 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
701 ;; 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
702 ;; 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
703 ;; this function.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 buffer-undo-list
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 (inhibit-read-only t))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 ;; 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
707 ;; (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
708 ;; (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
709 ;; tutorial--point-after-chkeys))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 ;; Delete the remarks:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 (tutorial--remove-remarks)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 ;; 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
713 ;; be saved with the tutorial.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (goto-char (point-min))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 (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
716 "\n"
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 (number-to-string (marker-position
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 tutorial--point-before-chkeys))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 "\n")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 (condition-case err
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 (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
722 (error (setq save-err t)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 (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
724 saved-file
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 (error-message-string err))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 ;; 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
727 (condition-case err
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 (undo-only)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 (error nil))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 ;; Restore point
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 (goto-char old-point)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 (if save-err
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 (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
734 (message "Saved tutorial state.")))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 (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
736 tutorial-dir)))))
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
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 ;;;###autoload
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740 (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
741 "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
742 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
743 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
744 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
745 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
746 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
747 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
748
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
749 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
750 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
751 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
752
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 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
754 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
755 resumed later."
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 (interactive "P")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 (if (boundp 'viper-current-state)
73551
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
758 (let ((prompt1
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
759 "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
760 enabled Viper.")
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
761 (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
762 Run the Viper tutorial? "))
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
763 (if (fboundp 'viper-tutorial)
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
764 (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
765 (progn (message "")
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
766 (funcall 'viper-tutorial 0))
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
767 (message "Tutorial aborted by user"))
8bd77d06776b * tutorial.el: Move defvars to avoid bytecomp warnings.
Chong Yidong <cyd@stupidchicken.com>
parents: 73550
diff changeset
768 (message prompt1)))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 (let* ((lang (if arg
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 (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
771 (add-hook 'minibuffer-setup-hook
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772 'minibuffer-completion-help)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 (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
774 (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
775 current-language-environment
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 "English")))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 (filename (get-language-info lang 'tutorial))
103214
51502f108f8e * tutorial.el (help-with-tutorial): Use TUTORIAL.xx for the tutorial
Chong Yidong <cyd@stupidchicken.com>
parents: 103213
diff changeset
778 (tut-buf-name filename)
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 (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
780 (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
781 (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
782 (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
783 old-tut-file
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 (old-tut-point 1))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 (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
786 ;; 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
787 ;; 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
788 ;; selected and displayed:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 (if old-tut-win
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 (raise-frame
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
791 (window-frame
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 (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
793 ;; 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
794 (when old-tut-buf
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 (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
796 ;; Use whole frame for tutorial
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 (delete-other-windows)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 ;; 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
799 ;; be reverted:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 (when (and old-tut-buf
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 (not old-tut-is-ok))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 (setq old-tut-is-ok
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 (if dont-ask-for-revert
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 nil
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 (not (y-or-n-p
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 "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
807 ;; (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
808 (unless old-tut-is-ok
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809 (switch-to-buffer (get-buffer-create tut-buf-name))
103213
9dae7d399c7d * tutorial.el (help-with-tutorial): Don't use text mode, since the
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
810 ;; (unless old-tut-buf (text-mode))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811 (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
812 (setq tutorial--lang lang)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
813 (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
814 (let ((inhibit-read-only t))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (erase-buffer))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
816 (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
817
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
818 ;; 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
819 ;; 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
820 (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
821 (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
822
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
823 ;; 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
824 ;; editing session.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
825 (when dont-ask-for-revert
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
826 (setq old-tut-file nil))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
827 (when old-tut-file
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
828 (setq old-tut-file
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
829 (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
830 (if old-tut-file
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
831 (progn
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 (insert-file-contents (tutorial--saved-file))
109674
cef075b11b25 Evaluate file-local variables in tutorials.
Eli Zaretskii <eliz@gnu.org>
parents: 107853
diff changeset
833 (let ((enable-local-variables :safe))
cef075b11b25 Evaluate file-local variables in tutorials.
Eli Zaretskii <eliz@gnu.org>
parents: 107853
diff changeset
834 (hack-local-variables))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
835 (goto-char (point-min))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
836 (setq old-tut-point
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
837 (string-to-number
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
838 (buffer-substring-no-properties
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
839 (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
840 (forward-line)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
841 (setq tutorial--point-before-chkeys
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
842 (string-to-number
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
843 (buffer-substring-no-properties
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
844 (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
845 (forward-line)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
846 (delete-region (point-min) (point))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 (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
848 (setq tutorial--point-before-chkeys (point-marker)))
82729
10439b0bb602 (help-with-tutorial): Tutorials now in tutorial-directory.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
849 (insert-file-contents (expand-file-name filename tutorial-directory))
109674
cef075b11b25 Evaluate file-local variables in tutorials.
Eli Zaretskii <eliz@gnu.org>
parents: 107853
diff changeset
850 (let ((enable-local-variables :safe))
cef075b11b25 Evaluate file-local variables in tutorials.
Eli Zaretskii <eliz@gnu.org>
parents: 107853
diff changeset
851 (hack-local-variables))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
852 (forward-line)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853 (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
854
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
855 (tutorial--display-changes)
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
856
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 ;; Clear message:
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
858 (unless dont-ask-for-revert
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
859 (message "") (sit-for 0))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
861
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
862 (if old-tut-file
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
863 ;; 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
864 (let ((old-point
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
865 (if (> 0 old-tut-point)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
866 (- old-tut-point)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
867 (+ 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
868 (when (< old-point 1)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 (setq old-point 1))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
870 (goto-char old-point))
103768
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
871 ;; Delete the arch-tag line, so as not to confuse readers.
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
872 (goto-char (point-max))
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
873 (if (search-backward ";;; arch-tag: " nil t)
ed7c4b27122a (tutorial--describe-nonstandard-key):
Glenn Morris <rgm@gnu.org>
parents: 103214
diff changeset
874 (delete-region (point) (point-max)))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
875 (goto-char (point-min))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
876 (search-forward "\n<<")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
877 (beginning-of-line)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 ;; 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
879 ;; 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
880 (cond ((save-excursion
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
881 (forward-line 1)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
882 (looking-at "\\["))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 (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
884 ((looking-at "<<Blank lines inserted.*>>")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 (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
886 (t
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 (looking-at "<<")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888 (replace-match "[")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
889 (search-forward ">>")
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
890 (replace-match "]")))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891 (beginning-of-line)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
892 (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
893 (count-lines (point-min) (point))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 6)))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 (if (< n 8)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 (progn
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 ;; 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
898 ;; so delete it.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 (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
900 (newline n))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901 ;; 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
902 (newline (/ n 2))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 ;; 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
905 (forward-line 1)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
906 (newline (- n (/ n 2)))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 (goto-char (point-min)))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 (setq buffer-undo-list nil)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 (set-buffer-modified-p nil)))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
910
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 ;; 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
913 ;; 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
914
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915 (defconst lang-strings
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
916 '(("English" .
74795
4404b91f3a72 (tutorial--detailed-help): Remove unnecessary link
Chong Yidong <cyd@stupidchicken.com>
parents: 74789
diff changeset
917 ((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
918 (tut-chgdkey2 . "More")
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
919 (tut-chgdhead . "
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
920 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
921 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
922 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
923 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
924 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
925 commands have been introduced.")
74789
ecc3f98301f4 Remove `cl' requirement. Clean up whitespace.
Chong Yidong <cyd@stupidchicken.com>
parents: 74113
diff changeset
926 (tut-chgdhead2 . "More"))))
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927 "Language specific strings for Emacs.
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 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
929 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
930 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
931 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
932
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
933 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
934
75471
afea84ac9ef8 (tutorial--default-keys): Check M-DEL, not `M-backspace'.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
935 (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
936 "Get a language specific string for Emacs.
77717
88eb7407b1e4 (get-lang-string, tutorial--find-changed-keys): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 76210
diff changeset
937 In certain places Emacs can replace a string shown to the user with
88eb7407b1e4 (get-lang-string, tutorial--find-changed-keys): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 76210
diff changeset
938 a language specific string. This function retrieves such strings.
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939
99116
2e0e3e5cbd97 * completion.el (add-completion-to-head, add-completion): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 99106
diff changeset
940 LANG is the language specification. It should be one of those
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941 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
942 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
943
77717
88eb7407b1e4 (get-lang-string, tutorial--find-changed-keys): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 76210
diff changeset
944 If no string is found for STRINGID in the chosen language then
73550
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
945 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
946
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 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
948
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 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
950 (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
951 (found-string))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 (when my-lang-strings
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 (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
954 (when entry
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 (setq found-string (cdr entry)))))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 ;; Fallback to English strings
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957 (unless (or found-string
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 no-eng-fallback)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959 (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
960 found-string))
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
962 ;;(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
963
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 (provide 'tutorial)
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
965
6deaec97f21b * help-fns.el (help-with-tutorial): Moved to tutorial.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
966 ;;; tutorial.el ends here