annotate man/xemacs/m-x.texi @ 337:fbbf69b4e8a7 r21-0-66

Import from CVS: tag r21-0-66
author cvs
date Mon, 13 Aug 2007 10:51:02 +0200
parents ac2d302a0011
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @node M-x, Help, Minibuffer, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @chapter Running Commands by Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 The Emacs commands that are used often or that must be quick to type are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 bound to keys---short sequences of characters---for convenient use. Other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 Emacs commands that are used more rarely are not bound to keys; to run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 them, you must refer to them by name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 A command name consists, by convention, of one or more words,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 separated by hyphens: for example, @code{auto-fill-mode} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 @code{manual-entry}. The use of English words makes the command name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 easier to remember than a key made up of obscure characters, even though
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 it results in more characters to type. You can run any command by name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 even if it can be run by keys as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @kindex M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 @cindex minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 To run a command by name, start with @kbd{M-x}, then type the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 command name, and finish with @key{RET}. @kbd{M-x} uses the minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 to read the command name. @key{RET} exits the minibuffer and runs the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 Emacs uses the minibuffer for reading input for many different purposes;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 on this occasion, the string @samp{M-x} is displayed at the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 the minibuffer as a @dfn{prompt} to remind you that your input should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 the name of a command to be run. @xref{Minibuffer}, for full information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 on the features of the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 You can use completion to enter a command name. For example, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 invoke the command @code{forward-char}, type:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 M-x forward-char @key{RET}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 M-x fo @key{TAB} c @key{RET}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 After you type in @code{M-x fo TAB} emacs will give you a possible list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 completions from which you can choose. Note that @code{forward-char} is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 same command that you invoke with the key @kbd{C-f}. You can call any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 command (interactively callable function) defined in Emacs by its name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 using @kbd{M-x} regardless of whether or not any keys are bound to it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 If you type @kbd{C-g} while Emacs reads the command name, you cancel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 the @kbd{M-x} command and get out of the minibuffer, ending up at top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 To pass a numeric argument to a command you are invoking with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @kbd{M-x}, specify the numeric argument before the @kbd{M-x}. @kbd{M-x}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 passes the argument along to the function that it calls. The argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 value appears in the prompt while the command name is being read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @findex interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 You can use the command @code{M-x interactive} to specify a way of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 parsing arguments for interactive use of a function. For example, write:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defun foo (arg) "Doc string" (interactive "p") ...use arg...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 to make @code{arg} be the prefix argument when @code{foo} is called as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 command. The call to @code{interactive} is actually a declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 rather than a function; it tells @code{call-interactively} how to read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 arguments to pass to the function. When actually called, @code{interactive}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 The argument of @var{interactive} is usually a string containing a code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 letter followed by a prompt. Some code letters do not use I/O to get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 the argument and do not need prompts. To prompt for multiple arguments,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 you must provide a code letter, its prompt, a newline, and another code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 letter, and so forth. If the argument is not a string, it is evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 to get a list of arguments to pass to the function. If you do not provide an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 argument to @code{interactive}, no arguments are passed when calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Available code letters are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 @item a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Function name: symbol with a function definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 @item b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Name of existing buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 @item B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Name of buffer, possibly nonexistent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 @item c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 @item C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 Command name: symbol with interactive function definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 @item d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Value of point as number (does not do I/O)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 @item D
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 Directory name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 @item e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Last mouse event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 @item f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Existing file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @item F
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 Possibly nonexistent file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @item k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Key sequence (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @item m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 Value of mark as number (does not do I/O)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 @item n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 Number read using minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @item N
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 Prefix arg converted to number, or if none, do like code @code{n}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 @item p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 Prefix arg converted to number (does not do I/O)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 @item P
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 Prefix arg in raw form (does not do I/O)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @item r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Region: point and mark as two numeric arguments, smallest first (does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 not do I/O)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 @item s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 Any string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 @item S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Any symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 @item v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 Variable name: symbol that is @code{user-variable-p}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 @item x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 Lisp expression read but not evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 @item X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Lisp expression read and evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 In addition, if the string begins with @samp{*}, an error is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 signaled if the buffer is read-only. This happens before reading any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 arguments. If the string begins with @samp{@@}, the window the mouse is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 over is selected before anything else is done. You may use both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 @samp{@@} and @samp{*}; they are processed in the order that they appear.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Normally, when describing a command that is run by name, we omit the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 @key{RET} that is needed to terminate the name. Thus we may refer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 @kbd{M-x auto-fill-mode} rather than @kbd{M-x auto-fill-mode} @key{RET}.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 We mention the @key{RET} only when it is necessary to emphasize its
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 presence, for example, when describing a sequence of input that contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 a command name and arguments that follow it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 @findex execute-extended-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 @kbd{M-x} is defined to run the command @code{execute-extended-command},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 which is responsible for reading the name of another command and invoking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 it.