Mercurial > emacs
comparison lispref/tips.texi @ 34305:0c60b76ea2ee
Why no package system.
Rationale for loading without effect.
Defining compatibility aliases.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 06 Dec 2000 20:48:43 +0000 |
parents | a0af1af4aabf |
children | 3577e0c41a1e |
comparison
equal
deleted
inserted
replaced
34304:dd613770eb0f | 34305:0c60b76ea2ee |
---|---|
37 | 37 |
38 @itemize @bullet | 38 @itemize @bullet |
39 @item | 39 @item |
40 Since all global variables share the same name space, and all functions | 40 Since all global variables share the same name space, and all functions |
41 share another name space, you should choose a short word to distinguish | 41 share another name space, you should choose a short word to distinguish |
42 your program from other Lisp programs. Then take care to begin the | 42 your program from other Lisp programs.@footnote{The benefits of a Common |
43 names of all global variables, constants, and functions with the chosen | 43 Lisp-style package system are considered not to outweigh the costs.} |
44 prefix. This helps avoid name conflicts. | 44 Then take care to begin the names of all global variables, constants, |
45 and functions with the chosen prefix. This helps avoid name conflicts. | |
45 | 46 |
46 This recommendation applies even to names for traditional Lisp | 47 This recommendation applies even to names for traditional Lisp |
47 primitives that are not primitives in Emacs Lisp---even to | 48 primitives that are not primitives in Emacs Lisp---even to |
48 @code{copy-list}. Believe it or not, there is more than one plausible | 49 @code{copy-list}. Believe it or not, there is more than one plausible |
49 way to define @code{copy-list}. Play it safe; append your name prefix | 50 way to define @code{copy-list}. Play it safe; append your name prefix |
184 shift key held down. These events include @kbd{S-mouse-1}, | 185 shift key held down. These events include @kbd{S-mouse-1}, |
185 @kbd{M-S-mouse-1}, @kbd{C-S-mouse-1}, and so on. They are reserved for | 186 @kbd{M-S-mouse-1}, @kbd{C-S-mouse-1}, and so on. They are reserved for |
186 users. | 187 users. |
187 | 188 |
188 @item | 189 @item |
190 @cindex mouse-2 | |
191 @cindex references, following | |
189 Special major modes used for read-only text should usually redefine | 192 Special major modes used for read-only text should usually redefine |
190 @kbd{mouse-2} and @key{RET} to trace some sort of reference in the text. | 193 @kbd{mouse-2} and @key{RET} to trace some sort of reference in the text. |
191 Modes such as Dired, Info, Compilation, and Occur redefine it in this | 194 Modes such as Dired, Info, Compilation, and Occur redefine it in this |
192 way. | 195 way. |
193 | 196 |
195 When a package provides a modification of ordinary Emacs behavior, it is | 198 When a package provides a modification of ordinary Emacs behavior, it is |
196 good to include a command to enable and disable the feature, Provide a | 199 good to include a command to enable and disable the feature, Provide a |
197 command named @code{@var{whatever}-mode} which turns the feature on or | 200 command named @code{@var{whatever}-mode} which turns the feature on or |
198 off, and make it autoload (@pxref{Autoload}). Design the package so | 201 off, and make it autoload (@pxref{Autoload}). Design the package so |
199 that simply loading it has no visible effect---that should not enable | 202 that simply loading it has no visible effect---that should not enable |
200 the feature. Users will request the feature by invoking the command. | 203 the feature.@footnote{Consider that the package may be loaded |
204 arbitrarily by Custom for instance.} Users will request the feature by | |
205 invoking the command. | |
201 | 206 |
202 @item | 207 @item |
203 It is a bad idea to define aliases for the Emacs primitives. Use the | 208 It is a bad idea to define aliases for the Emacs primitives. Use the |
204 standard names instead. | 209 standard names instead. |
210 | |
211 @item | |
212 If a package needs to define an alias or a new function for | |
213 compatibility with some other version of Emacs, name if with the package | |
214 prefix, not with the raw name with which it occurs in the other version. | |
215 Here is an example from Gnus, which provides many examples of such | |
216 compatibility issues. | |
217 | |
218 @example | |
219 (defalias 'gnus-point-at-bol | |
220 (if (fboundp 'point-at-bol) | |
221 'point-at-bol | |
222 'line-beginning-position)) | |
223 @end example | |
205 | 224 |
206 @item | 225 @item |
207 Redefining (or advising) an Emacs primitive is discouraged. It may do | 226 Redefining (or advising) an Emacs primitive is discouraged. It may do |
208 the right thing for a particular program, but there is no telling what | 227 the right thing for a particular program, but there is no telling what |
209 other programs might break as a result. | 228 other programs might break as a result. |