annotate man/new-users-guide/custom1.texi @ 104:cf808b4c4290 r20-1b4

Import from CVS: tag r20-1b4
author cvs
date Mon, 13 Aug 2007 09:16:51 +0200
parents 376386a54a3c
children c9fe270a4101
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 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @node Customization Basics, Help, Edit, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @chapter Customize key bindings and menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @cindex .emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @cindex customize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @findex eval-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 When you start Emacs, it reads the file @file{~/.emacs} in your home
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 directory. You can use this file to initialize and customize Emacs to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 your liking. This file should contain lisp-code. You can customize your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 @file{.emacs} file to create new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 menus, disable menus, change key bindings, enable a minor mode, etc. Any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 kind of customization affects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 only a particular Emacs job that you do them in. If you want to save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 your customizations `permanently' i.e. for future use also, you have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 put it in your @samp{.emacs} file. After you make changes to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @file{.emacs} file and save it, the changes will be effective only after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 you start Emacs again i.e. for a new Emacs process. To try out some of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the examples in this section, highlight that region and evaluate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 region by giving the command @kbd{M-x eval-region}. You will be able to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 see the results of your customizations in that Emacs session only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (@pxref{Lisp Eval,,,,XEmacs User's Manual}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 * Customizing key Bindings:: Changing Key Bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 * Customizing Menus:: Adding, Deleting, Enabling and Disabling Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 @node Customizing key Bindings, Customizing Menus, Customization Basics, Customization Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @section Customize key bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 @cindex key bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 @cindex keystrokes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 Most of Emacs commands use key sequences. @xref{Keystrokes,,,,XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Manual}, for more information about Keys and Commands. In Emacs, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 keys themselves carry no meaning unless they are bound to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 function. For example, @kbd{C-n} moves the cursor to the next line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 because its bound to the function @b{next-line}. Similarly, @kbd{C-p}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 moves to the previous line because its bound to the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 @b{previous-line}. The functions themselves define a particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 behavior. You can customize the key @kbd{C-n} to move to the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 line by binding it to @b{previous-line} and @kbd{C-p} to move to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 next line by binding it to @b{next-line}. To bind keys to globally run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 commands you need to use the following syntax in your @b{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 @cindex binding keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 @code{(global-set-key @var{keys} @var{cmd})}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Here, @code{global-set-key} is a function which will bind the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 @dfn{keys} to the specified @dfn{cmd}. For example, if you type the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 following in your @b{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (global-set-key "\C-p" 'next-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (global-set-key "\C-n" 'previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 then @kbd{C-p} will move to the next line and @kbd{C-n} to the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 You can also disable a key binding, by using @samp{nil} as the @var{cmd}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 in the syntax stated above. Here, @samp{nil} stands for @samp{false}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 which means disable a command or turn off a feature. If you want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 enable a command or turn on a particular feature use @samp{t}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 which stands for @samp{true}. For example, if you do not wish @kbd{C-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 C-c} to @samp{Exit Emacs} you can type the following expression in your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 @file{.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (global-set-key "\C-x\C-c" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 You might want to have this statement in your @file{.emacs} file because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 its easy to hit this command by mistake and it could be annoying to exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 Emacs unintentionally. There is a @b{Exit Emacs} option in the @b{File
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 menu} which you might want to use instead. To make a particular key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 undefined you can also use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (global-unset-key "\C-x\C-c")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Now if you use the command @kbd{C-x C-c}, you will get an error saying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 that the command is undefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Some other customizations you could try are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (global-set-key 'button3 'beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 Now when you press the third button of your mouse, the cursor will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 placed at the @code{beginning-of-buffer}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (global-set-key 'f1 'goto-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 If you press the @key{F1} key, you will be prompted for a line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 number. After you type the line number and hit @key{RET}, the cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 will be placed on that line number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (global-set-key 'f2 'undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 Pressing @key{F2} will undo the last command. If you have a @key{undo}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 key on your keyboard, try binding that key to the undo command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 Another syntax for customizing key bindings is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 @code{(define-key @var{keymap} @var{keys} @var{def})}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 It defines @var{keys} to run @var{def} in the keymap @var{keymap}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 @var{keymap} is a keymap object which records the bindings of keys to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 the commands that they run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 @var{keys} is the sequence of keystrokes to bind.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 @var{def} is anything that can be a key's definition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Look at the following two examples:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (define-key global-map "\C-xl" 'make-symbolic-link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (define-key c-mode-map "\C-xl" 'make-symbolic-link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 @end example
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 make-symbolic-link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 Both the examples bind the key @kbd{C-xl} to run the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 @code{make-symbolic-link} (@pxref{Misc File Ops,,,,XEmacs User's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Manual}). However, the second example will bind the key only for C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 mode. @xref{Major Modes,,,,XEmacs User's Manual}, for more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 information on Major Modes in XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 @node Customizing Menus, , Customizing key Bindings, Customization Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 @section Customizing Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 @cindex customize menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 @cindex delete menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 @cindex disable menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 @findex add-menu-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 @cindex add menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 You can customize any of the XEmacs Pull-down-Menus. You can create your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 own menu, delete an existing one, enable a menu or disable a menu. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 more information on the default menus available to you, @xref{Pull-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Menus}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 Some of the functions which are available to you for customization are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 @item add-menu-item: @var{(menu-name item-name function enabled-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 &optional before)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 This function will add a menu item to a menu, creating the menu first if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 necessary. If the named item already exists, the menu will remain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 unchanged. For example, if you add the following example to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 @file{.emacs} file or evaluate it (@pxref{Customization Basics}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (add-menu-item '("Edit") "Replace String" replace-string t "Clear")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 a sub-menu @b{Replace String} will be created under @b{Edit} menu before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 sub-menu @b{Clear}. The @b{Edit} menu will now look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 Undo C-x u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 Cut cut
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 Copy copy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 Paste paste
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Replace String
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 Clear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 Start Macro Recording C-x(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 End Macro Recording C-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 Execute Last Macro C-xe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 @b{Replace String} will now execute the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 @code{replace-string}. Select this menu item. Emacs will prompt you for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 a string name to be replaced. Type a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 string and hit @key{RET}. Now type a new string to replace the old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 string and hit @key{RET}. All occurrences of the old string will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 replaced by the new string. In this example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 @samp{Edit} is the @var{menu-name} which identifies the menu into which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 the new menu item should be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 @samp{Replace String} is the @var{item-name} which names the menu item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 to be added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @samp{replace-string} is the @var{function} i.e. the command to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 invoked when the menu item "Replace String" is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @samp{t} is the @var{enabled-p} parameter which controls whether the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 menu item is selectable or not. This parameter can be either @code{t} (selectable), @code{nil} (not selectable), or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 form to evaluate. This form is evaluated just before the menu is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 displayed, and the menu item will be selectable if the form returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 @samp{Clear} is the @var{&optional before} parameter which is the name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 of the menu before which the new menu or sub-menu should be added. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 @var{&optional} string means that this parameter is optional. You do not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 need to specify this parameter. If you do not specify this parameter in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 the example above, the @b{Replace String} menu item will be added at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 end of the list of sub-menus in the @b{Edit} menu i.e. after @b{Execute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 Last Macro}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 If you wish to add a new menu to the menubar, try:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (add-menu-item nil "Bot" 'end-of-buffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 This will create a new menu @b{Bot} on the menu bar. Selecting this menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 will take you to the end of the buffer. Using @code{nil} for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 parameter @var{menu-name} will create a new menu. Your menu-bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 will now look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 File Edit Options Buffers Bot Help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 The following example will illustrate how you can add sub-menus to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 submenus themselves:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (add-menu-item '("File" "Management") "Copy File" 'copy-file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (add-menu-item '("File" "Management") "Delete File" 'delete-file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (add-menu-item '("File" "Management") "Rename File" 'rename-file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 This will create a sub-menu @b{Management} under the @b{File}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 menu. When you select the submenu @b{Management}, it will contain three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 submenus: @b{Copy File}, @b{Delete File} and @b{Rename File}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 @findex delete-menu-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @cindex deleting menu items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 @item delete-menu-item: @var{(menu-path)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 This function will remove the menu item defined by @var{menu-name} from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 the menu hierarchy. Look at the following examples and the comments just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 above them which specify what the examples do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; deletes the "Replace String" menu item created earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (delete-menu-item '("Edit" "Replace String"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; deletes the "Bot" menu created earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (delete-menu-item '("Bot"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; deletes the sub-menu "Copy File" created earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (delete-menu-item '("File" "File Management" "Copy File"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; deletes the sub-menu "Delete File" created earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (delete-menu-item '("File" "Management" "Delete File"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; deletes the sub-menu "Rename File" created earlier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (delete-menu-item '("File" "Management" "Rename File"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 @findex disable-menu-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 @cindex disabling menu items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 @item disable-menu-item: @var{(menu-name)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 Disables the specified menu item. The following example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (disable-menu-item '("File" "Management" "Copy File"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 will make the @b{Copy File} item unselectable. This menu-item would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 still be there but it will appear faded which would mean that it cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 be selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 @findex enable-menu-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 @cindex enabling menu items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @item enable-menu-item: @var{(menu-name)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Enables the specified previously disabled menu item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (enable-menu-item '("File" "Management" "Copy File"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 This will enable the sub-menu @b{Copy File}, which was disabled by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 earlier command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 @findex relabel-menu-items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 @cindex relabelling menu items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 @item relabel-menu-item: @var{(menu-name new-name)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 Change the string of the menu item specified by @var{menu-name} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 @var{new-name}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (relabel-menu-item '("File" "Open...") "Open File")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 This example will rename the @b{Open...} menu item from the @b{File}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 menu to @b{Open File}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324