annotate man/new-users-guide/custom1.texi @ 5044:e84a30b0e4a2

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