diff options
| author | Richard M. Stallman | 2001-06-14 21:05:55 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-06-14 21:05:55 +0000 |
| commit | 01e3636e3546e3a15e6d237dc7c54b60fb7a5d7f (patch) | |
| tree | bf95805023b6eb5a305084c0784d34cbb8412956 /lispref | |
| parent | e4cdc335f37ff8ed88a315508cdf27c7c640e9c6 (diff) | |
| download | emacs-01e3636e3546e3a15e6d237dc7c54b60fb7a5d7f.tar.gz emacs-01e3636e3546e3a15e6d237dc7c54b60fb7a5d7f.zip | |
Give advice about how to default position args and region args.
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/tips.texi | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/lispref/tips.texi b/lispref/tips.texi index 031f6b41166..50499e20569 100644 --- a/lispref/tips.texi +++ b/lispref/tips.texi | |||
| @@ -289,11 +289,47 @@ 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} |