[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to use ;?
- To: bep@argv.org
- Subject: Re: how to use ;?
- From: Naoto Takahashi <ntakahas@m17n.org>
- Date: Fri, 30 Mar 2001 14:18:38 +0900 (JST)
- Delivered-To: mailing list bep@argv.org
- Mailing-List: contact bep-help@argv.org; run by ezmlm
- User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.0.97 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)
> 坂本です。
> emacs-lispでコメントに;をつける場合、ある程度の規則なんぞ在るのでしょう
> か?
あります。Emacs Lisp の info の中に tips という項があり、その中に書い
てあるんですが、下に付けておきます。
----------------------------------------------------------------------
Tips on Writing Comments
========================
We recommend these conventions for where to put comments and how to
indent them:
`;'
Comments that start with a single semicolon, `;', should all be
aligned to the same column on the right of the source code. Such
comments usually explain how the code on the same line does its
job. In Lisp mode and related modes, the `M-;'
(`indent-for-comment') command automatically inserts such a `;' in
the right place, or aligns such a comment if it is already present.
This and following examples are taken from the Emacs sources.
(setq base-version-list ; there was a base
(assoc (substring fn 0 start-vn) ; version to which
file-version-assoc-list)) ; this looks like
; a subversion
`;;'
Comments that start with two semicolons, `;;', should be aligned to
the same level of indentation as the code. Such comments usually
describe the purpose of the following lines or the state of the
program at that point. For example:
(prog1 (setq auto-fill-function
...
...
;; update mode line
(force-mode-line-update)))
We also normally use two semicolons for comments outside functions.
;; This Lisp code is run in Emacs
;; when it is to operate as a server
;; for other processes.
Every function that has no documentation string (presumably one
that is used only internally within the package it belongs to),
should instead have a two-semicolon comment right before the
function, explaining what the function does and how to call it
properly. Explain precisely what each argument means and how the
function interprets its possible values.
`;;;'
Comments that start with three semicolons, `;;;', should start at
the left margin. These are used, occasionally, for comments within
functions that should start at the margin. We also use them
sometimes for comments that are between functions--whether to use
two or three semicolons there is a matter of style.
Another use for triple-semicolon comments is for commenting out
lines within a function. We use three semicolons for this
precisely so that they remain at the left margin.
(defun foo (a)
;;; This is no longer necessary.
;;; (force-mode-line-update)
(message "Finished with %s" a))
`;;;;'
Comments that start with four semicolons, `;;;;', should be aligned
to the left margin and are used for headings of major sections of a
program. For example:
;;;; The kill ring
The indentation commands of the Lisp modes in Emacs, such as `M-;'
(`indent-for-comment') and <TAB> (`lisp-indent-line'), automatically
indent comments according to these conventions, depending on the number
of semicolons. *Note Manipulating Comments: (emacs)Comments.
--
TAKAHASHI Naoto
ntakahas@...
http://www.m17n.org/ntakahas/