Mercurial > emacs
comparison lispref/tips.texi @ 71036:2a973dfbccc2
(Coding Conventions): Better explain reasons not to
advise other packages or use `eval-after-load'.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 29 May 2006 00:18:44 +0000 |
parents | 044c7ca7a4ff |
children | b4f82229f064 a8190f7e546e |
comparison
equal
deleted
inserted
replaced
71035:3574bac9e172 | 71036:2a973dfbccc2 |
---|---|
172 'point-at-bol | 172 'point-at-bol |
173 'line-beginning-position)) | 173 'line-beginning-position)) |
174 @end example | 174 @end example |
175 | 175 |
176 @item | 176 @item |
177 Redefining (or advising) an Emacs primitive is discouraged. It may do | 177 Redefining (or advising) an Emacs primitive is a bad idea. It may do |
178 the right thing for a particular program, but there is no telling what | 178 the right thing for a particular program, but there is no telling what |
179 other programs might break as a result. In any case, it is a | 179 other programs might break as a result. In any case, it is a problem |
180 maintenance burden because the two packages become highly dependent on | 180 for debugging, because the two advised function doesn't do what its |
181 each other. | 181 source code says it does. If the programmer investigating the problem |
182 is unaware that there is advice on the function, the experience can be | |
183 very frustrating. | |
184 | |
185 We hope to remove all the places in Emacs that advise primitives. | |
186 In the mean time, please don't add any more. | |
187 | |
188 @item | |
189 It is likewise a bad idea for one Lisp package to advise a function | |
190 in another Lisp package. | |
182 | 191 |
183 @item | 192 @item |
184 Likewise, avoid using @code{eval-after-load} (@pxref{Hooks for | 193 Likewise, avoid using @code{eval-after-load} (@pxref{Hooks for |
185 Loading}) in libraries and packages. This feature is meant for | 194 Loading}) in libraries and packages. This feature is meant for |
186 personal customizations; using it in a Lisp package increases the | 195 personal customizations; using it in a Lisp program is unclean because |
187 coupling between it and the package mentioned in | 196 it modifies the behavior of another Lisp file in an invisible way. |
188 @code{eval-after-load}, and thus makes it harder to maintain the two | 197 This is an obstacle for debugging, much like advising a function in |
189 packages independently. | 198 the other package. |
190 | 199 |
191 @item | 200 @item |
192 If a file does replace any of the functions or library programs of | 201 If a file does replace any of the functions or library programs of |
193 standard Emacs, prominent comments at the beginning of the file should | 202 standard Emacs, prominent comments at the beginning of the file should |
194 say which functions are replaced, and how the behavior of the | 203 say which functions are replaced, and how the behavior of the |