[ < ] | [ > ] | [ << ] | [Plus haut] | [ >> ] | [Top] | [Table des matières] | [Index] | [ ? ] |
Following these conventions will make your program fit better into Emacs when it runs.
next-line
or previous-line
in programs; nearly
always, forward-line
is more convenient as well as more predictable
and robust. Voir la section Motion by Text Lines.
In particular, don't use any of these functions:
beginning-of-buffer
, end-of-buffer
replace-string
, replace-regexp
insert-file
, insert-buffer
If you just want to move point, or replace a certain string, or insert a file or buffer's contents, without any of the other features intended for interactive users, you can replace these functions with one or two lines of simple Lisp code.
Vectors are advantageous for tables that are substantial in size and are accessed in random order (not searched front to back), provided there is no need to insert or delete elements (only lists allow that).
message
function, not princ
. Voir la section The Echo Area.
error
(or
signal
). The function error
does not return. Voir la section How to Signal an Error.
Do not use message
, throw
, sleep-for
, or beep
to
report errors.
y-or-n-p
or
yes-or-no-p
should start with a capital letter and end with ‘?
’.
Enter the answer (default 42): |
interactive
, if you use a Lisp expression to produce a list of
arguments, don't try to provide the “correct” default values for region or
position arguments. Instead, provide nil
for those arguments if they
were not specified, and have the function body compute the default value
when the argument is nil
. For instance, write this:
(defun foo (pos) (interactive (list (if specified specified-pos))) (unless pos (setq pos default-pos)) ...) |
rather than this:
(defun foo (pos) (interactive (list (if specified specified-pos default-pos))) ...) |
This is so that repetition of the command will recompute these defaults based on the current circumstances.
You do not need to take such precautions when you use interactive specs ‘d’, ‘m’ and ‘r’, because they make special arrangements to recompute the argument values on repetition of the command.
edit-options
command does: switch to another buffer and let the user switch back at
will. Voir la section Recursive Editing.
[ < ] | [ > ] | [ << ] | [Plus haut] | [ >> ] | [Top] | [Table des matières] | [Index] | [ ? ] |
Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.