Mercurial > emacs
comparison lispref/tips.texi @ 38043:3577e0c41a1e
Give advice about how to default position args and region args.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 14 Jun 2001 21:05:55 +0000 |
parents | 0c60b76ea2ee |
children | 40606e2d6b31 |
comparison
equal
deleted
inserted
replaced
38042:cafa56a542ab | 38043:3577e0c41a1e |
---|---|
287 @item | 287 @item |
288 An error message should start with a capital letter but should not end | 288 An error message should start with a capital letter but should not end |
289 with a period. | 289 with a period. |
290 | 290 |
291 @item | 291 @item |
292 In @code{interactive}, if you use a Lisp expression to produce a list | |
293 of arguments, don't try to provide the ``correct'' default values for | |
294 region or position arguments. Instead, provide @code{nil} for those | |
295 arguments if they were not specified, and have the function body | |
296 compute the default value when the argument is @code{nil}. For | |
297 instance, write this: | |
298 | |
299 @example | |
300 (defun foo (pos) | |
301 (interactive | |
302 (list (if @var{specified} @var{specified-pos}))) | |
303 (unless pos (setq pos @var{default-pos})) | |
304 ...) | |
305 @end example | |
306 | |
307 @noindent | |
308 rather than this: | |
309 | |
310 @example | |
311 (defun foo (pos) | |
312 (interactive | |
313 (list (if @var{specified} @var{specified-pos} | |
314 @var{default-pos}))) | |
315 ...) | |
316 @end example | |
317 | |
318 @noindent | |
319 This is so that repetition of the command will recompute | |
320 these defaults based on the current circumstances. | |
321 | |
322 You do not need to take such precautions when you use interactive | |
323 specs @samp{d}, @samp{m} and @samp{r}, because they make special | |
324 arrangements to recompute the argument values on repetition of the | |
325 command. | |
326 | |
327 @item | |
292 Many commands that take a long time to execute display a message that | 328 Many commands that take a long time to execute display a message that |
293 says @samp{Operating...} when they start, and change it to | 329 says something like @samp{Operating...} when they start, and change it to |
294 @samp{Operating...done} when they finish. Please keep the style of | 330 @samp{Operating...done} when they finish. Please keep the style of |
295 these messages uniform: @emph{no} space around the ellipsis, and | 331 these messages uniform: @emph{no} space around the ellipsis, and |
296 @emph{no} period at the end. | 332 @emph{no} period after @samp{done}. |
297 | 333 |
298 @item | 334 @item |
299 Try to avoid using recursive edits. Instead, do what the Rmail @kbd{e} | 335 Try to avoid using recursive edits. Instead, do what the Rmail @kbd{e} |
300 command does: use a new local keymap that contains one command defined | 336 command does: use a new local keymap that contains one command defined |
301 to switch back to the old local keymap. Or do what the | 337 to switch back to the old local keymap. Or do what the |