]> code.delx.au - gnu-emacs/blobdiff - lispref/tips.texi
(Accepting Output): accept-process-output
[gnu-emacs] / lispref / tips.texi
index 331f0799e4b530f1fa76ac1ca911e334638b7249..254e1faf7fffcc61fd655f36ed183b06ab71a2f6 100644 (file)
@@ -6,7 +6,7 @@
 @setfilename ../info/tips
 @node Tips, GNU Emacs Internals, GPL, Top
 @appendix Tips and Conventions
-@cindex tips
+@cindex tips for writing Lisp
 @cindex standards of coding style
 @cindex coding standards
 
@@ -148,7 +148,7 @@ to store a list of functions (i.e., the variable is a hook), please
 follow the naming conventions for hooks.  @xref{Hooks}.
 
 @item
-@cindex unloading packages
+@cindex unloading packages, preparing for
 If loading the file adds functions to hooks, define a function
 @code{@var{feature}-unload-hook}, where @var{feature} is the name of
 the feature the package provides, and make it undo any such changes.
@@ -210,7 +210,8 @@ Constructs that define a function or variable should be macros,
 not functions, and their names should start with @samp{def}.
 
 @item
-Macros that define a function or variable should take the name to be
+A macro that defines a function or variable should have a name that
+starts with @samp{define-}.  The macro should receive the name to be
 defined as the first argument.  That will help various tools find the
 definition automatically.  Avoid constructing the names in the macro
 itself, since that would confuse these tools.
@@ -294,6 +295,7 @@ Otherwise, use your name.  See also @xref{Library Headers}.
 
 @node Key Binding Conventions
 @section Key Binding Conventions
+@cindex key binding, conventions for
 
 @itemize @bullet
 @item
@@ -373,6 +375,7 @@ after @key{ESC}.  In these states, you should define @kbd{@key{ESC}
 
 @node Programming Tips
 @section Emacs Programming Tips
+@cindex programming conventions
 
   Following these conventions will make your program fit better
 into Emacs when it runs.
@@ -558,6 +561,7 @@ the speed.  @xref{Inline Functions}.
 
 @node Warning Tips
 @section Tips for Avoiding Compiler Warnings
+@cindex byte compiler warnings, how to avoid
 
 @itemize @bullet
 @item
@@ -598,6 +602,7 @@ is to put a call to @code{with-no-warnings} around it.
 
 @node Documentation Tips
 @section Tips for Documentation Strings
+@cindex documentation strings, conventions and tips
 
 @findex checkdoc-minor-mode
   Here are some tips and conventions for the writing of documentation
@@ -642,52 +647,6 @@ Don't limit the documentation string to one line; use as many lines as
 you need to explain the details of how to use the function or
 variable.  Please use complete sentences for the rest of the text too.
 
-@item
-The first line should mention all the important arguments of the
-function, and should mention them in the order that they are written
-in a function call.  If the function has many arguments, then it is
-not feasible to mention them all in the first line; in that case, the
-first line should mention the first few arguments, including the most
-important arguments.
-
-@item
-For consistency, phrase the verb in the first sentence of a function's
-documentation string as an imperative---for instance, use ``Return the
-cons of A and B.'' in preference to ``Returns the cons of A and B@.''
-Usually it looks good to do likewise for the rest of the first
-paragraph.  Subsequent paragraphs usually look better if each sentence
-is indicative and has a proper subject.
-
-@item
-Write documentation strings in the active voice, not the passive, and in
-the present tense, not the future.  For instance, use ``Return a list
-containing A and B.'' instead of ``A list containing A and B will be
-returned.''
-
-@item
-Avoid using the word ``cause'' (or its equivalents) unnecessarily.
-Instead of, ``Cause Emacs to display text in boldface,'' write just
-``Display text in boldface.''
-
-@item
-When a command is meaningful only in a certain mode or situation,
-do mention that in the documentation string.  For example,
-the documentation of @code{dired-find-file} is:
-
-@example
-In Dired, visit the file or directory named on this line.
-@end example
-
-@item
-Do not start or end a documentation string with whitespace.
-
-@item
-@strong{Do not} indent subsequent lines of a documentation string so
-that the text is lined up in the source code with the text of the first
-line.  This looks nice in the source code, but looks bizarre when users
-view the documentation.  Remember that the indentation before the
-starting double-quote is not part of the string!
-
 @item
 When the user tries to use a disabled command, Emacs displays just the
 first paragraph of its documentation string---everything through the
@@ -695,23 +654,12 @@ first blank line.  If you wish, you can choose which information to
 include before the first blank line so as to make this display useful.
 
 @item
-When you define a variable that users ought to set interactively, you
-normally should use @code{defcustom}.  However, if for some reason you
-use @code{defvar} instead, start the doc string with a @samp{*}.
-@xref{Defining Variables}.
-
-@item
-The documentation string for a variable that is a yes-or-no flag should
-start with words such as ``Non-nil means,'' to make it clear that
-all non-@code{nil} values are equivalent and indicate explicitly what
-@code{nil} and non-@code{nil} mean.
-
-@item
-The documentation string for a function that is a yes-or-no predicate
-should start with words such as ``Return t if,'' to indicate
-explicitly what constitutes ``truth.''  The word ``return'' avoids
-starting the sentence with lower-case ``t,'' which could be somewhat
-distracting.
+The first line should mention all the important arguments of the
+function, and should mention them in the order that they are written
+in a function call.  If the function has many arguments, then it is
+not feasible to mention them all in the first line; in that case, the
+first line should mention the first few arguments, including the most
+important arguments.
 
 @item
 When a function's documentation string mentions the value of an argument
@@ -749,16 +697,14 @@ and that annoys you, rewrite the sentence so that the symbol
 is not at the start of it.
 
 @item
-If a line in a documentation string begins with an open-parenthesis,
-write a backslash before the open-parenthesis, like this:
-
-@example
-The argument FOO can be either a number
-\(a buffer position) or a string (a file name).
-@end example
+Do not start or end a documentation string with whitespace.
 
-This prevents the open-parenthesis from being treated as the start of a
-defun (@pxref{Defuns,, Defuns, emacs, The GNU Emacs Manual}).
+@item
+@strong{Do not} indent subsequent lines of a documentation string so
+that the text is lined up in the source code with the text of the first
+line.  This looks nice in the source code, but looks bizarre when users
+view the documentation.  Remember that the indentation before the
+starting double-quote is not part of the string!
 
 @anchor{Docstring hyperlinks}
 @item
@@ -776,6 +722,7 @@ t and nil without single-quotes.  (In this manual, we use a different
 convention, with single-quotes for all symbols.)
 @end ifnottex
 
+@cindex hyperlinks in documentation strings
 Help mode automatically creates a hyperlink when a documentation string
 uses a symbol name inside single quotes, if the symbol has either a
 function or a variable definition.  You do not need to do anything
@@ -858,10 +805,70 @@ It is not practical to use @samp{\\[@dots{}]} very many times, because
 display of the documentation string will become slow.  So use this to
 describe the most important commands in your major mode, and then use
 @samp{\\@{@dots{}@}} to display the rest of the mode's keymap.
+
+@item
+For consistency, phrase the verb in the first sentence of a function's
+documentation string as an imperative---for instance, use ``Return the
+cons of A and B.'' in preference to ``Returns the cons of A and B@.''
+Usually it looks good to do likewise for the rest of the first
+paragraph.  Subsequent paragraphs usually look better if each sentence
+is indicative and has a proper subject.
+
+@item
+The documentation string for a function that is a yes-or-no predicate
+should start with words such as ``Return t if,'' to indicate
+explicitly what constitutes ``truth.''  The word ``return'' avoids
+starting the sentence with lower-case ``t,'' which could be somewhat
+distracting.
+
+@item
+If a line in a documentation string begins with an open-parenthesis,
+write a backslash before the open-parenthesis, like this:
+
+@example
+The argument FOO can be either a number
+\(a buffer position) or a string (a file name).
+@end example
+
+This prevents the open-parenthesis from being treated as the start of a
+defun (@pxref{Defuns,, Defuns, emacs, The GNU Emacs Manual}).
+
+@item
+Write documentation strings in the active voice, not the passive, and in
+the present tense, not the future.  For instance, use ``Return a list
+containing A and B.'' instead of ``A list containing A and B will be
+returned.''
+
+@item
+Avoid using the word ``cause'' (or its equivalents) unnecessarily.
+Instead of, ``Cause Emacs to display text in boldface,'' write just
+``Display text in boldface.''
+
+@item
+When a command is meaningful only in a certain mode or situation,
+do mention that in the documentation string.  For example,
+the documentation of @code{dired-find-file} is:
+
+@example
+In Dired, visit the file or directory named on this line.
+@end example
+
+@item
+When you define a variable that users ought to set interactively, you
+normally should use @code{defcustom}.  However, if for some reason you
+use @code{defvar} instead, start the doc string with a @samp{*}.
+@xref{Defining Variables}.
+
+@item
+The documentation string for a variable that is a yes-or-no flag should
+start with words such as ``Non-nil means,'' to make it clear that
+all non-@code{nil} values are equivalent and indicate explicitly what
+@code{nil} and non-@code{nil} mean.
 @end itemize
 
 @node Comment Tips
 @section Tips on Writing Comments
+@cindex comments, Lisp convention for
 
   We recommend these conventions for where to put comments and how to
 indent them: