]> code.delx.au - gnu-emacs/blobdiff - lisp/newcomment.el
(menu-bar-tools-menu): Call read-mail-command
[gnu-emacs] / lisp / newcomment.el
index f73b69618884fb92581ead617e07aed147923221..a09f9b1fbc9a2c2570b9f555bbd98cee958bd09f 100644 (file)
@@ -6,7 +6,7 @@
 ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu>
 ;; Keywords: comment uncomment
 ;; Version: $Name:  $
-;; Revision: $Id: newcomment.el,v 1.12 2000/05/21 00:27:31 monnier Exp $
+;; Revision: $Id: newcomment.el,v 1.16 2000/06/04 22:02:11 monnier Exp $
 
 ;; This file is part of GNU Emacs.
 
 ;; - comment-box in TeXinfo generate bogus comments @ccccc@
 ;; - uncomment-region with a numeric argument can render multichar
 ;;   comment markers invalid.
+;; - comment-indent or comment-region when called inside a comment
+;;   will happily break the surrounding comment.
+;; - comment-quote-nested will not (un)quote properly all nested comment
+;;   markers if there are more than just comment-start and comment-end.
+;;   For example, in Pascal where {...*) and (*...} are possible.
 
 ;;; Todo:
 
 
 ;;; Code:
 
+;;;###autoload
 (defalias 'indent-for-comment 'comment-indent)
+;;;###autoload
 (defalias 'set-comment-column 'comment-set-column)
+;;;###autoload
 (defalias 'kill-comment 'comment-kill)
+;;;###autoload
 (defalias 'indent-new-comment-line 'comment-indent-new-line)
 
+;;;###autoload
 (defgroup comment nil
   "Indenting and filling of comments."
   :prefix "comment-"
+  :version "21.1"
   :group 'fill)
 
 (defvar comment-use-syntax 'undecided
@@ -69,6 +80,7 @@ be used to try to determine whether syntax-tables should be trusted
 to understand comments or not in the given buffer.
 Major modes should set this variable.")
 
+;;;###autoload
 (defcustom comment-column 32
   "*Column to indent right-margin comments to.
 Setting this variable automatically makes it local to the current buffer.
@@ -78,26 +90,26 @@ can set the value for a particular mode using that mode's hook."
   :group 'comment)
 (make-variable-buffer-local 'comment-column)
 
+;;;###autoload
 (defvar comment-start nil
   "*String to insert to start a new comment, or nil if no comment syntax.")
 
+;;;###autoload
 (defvar comment-start-skip nil
   "*Regexp to match the start of a comment plus everything up to its body.
 If there are any \\(...\\) pairs, the comment delimiter text is held to begin
 at the place matched by the close of the first pair.")
 
+;;;###autoload
 (defvar comment-end-skip nil
   "Regexp to match the end of a comment plus everything up to its body.")
 
+;;;###autoload
 (defvar comment-end ""
   "*String to insert to end a new comment.
 Should be an empty string if comments are terminated by end-of-line.")
 
-(defvar comment-indent-hook nil
-  "Obsolete variable for function to compute desired indentation for a comment.
-This function is called with no args with point at the beginning of
-the comment's starting delimiter.")
-
+;;;###autoload
 (defvar comment-indent-function
   (lambda () comment-column)
   "Function to compute desired indentation for a comment.
@@ -145,13 +157,17 @@ EXTRA specifies that an extra line should be used before and after the
 INDENT specifies that the `comment-start' markers should not be put at the
   left margin but at the current indentation of the region to comment.")
 
+;;;###autoload
 (defcustom comment-style 'plain
   "*Style to be used for `comment-region'.
 See `comment-styles' for a list of available styles."
   :group 'comment
-  :type `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles)))
+  :type (if (boundp 'comment-styles)
+           `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles))
+         'symbol))
 
-(defcustom comment-padding 1
+;;;###autoload
+(defcustom comment-padding " "
   "Padding string that `comment-region' puts between comment chars and text.
 Can also be an integer which will be automatically turned into a string
 of the corresponding number of spaces.
@@ -159,9 +175,9 @@ of the corresponding number of spaces.
 Extra spacing between the comment characters and the comment text
 makes the comment easier to read.  Default is 1.  nil means 0.")
 
+;;;###autoload
 (defcustom comment-multi-line nil
-  "*Non-nil means \\[indent-new-comment-line] should continue same comment
-on new line, with no new terminator or starter.
+  "*Non-nil means \\[comment-indent-new-line] continues comments, with no new terminator or starter.
 This is obsolete because you might as well use \\[newline-and-indent]."
   :type 'boolean
   :group 'comment)
@@ -374,6 +390,7 @@ Point is assumed to be just at the end of a comment."
 ;;;; Commands
 ;;;;
 
+;;;###autoload
 (defun comment-indent (&optional continue)
   "Indent this line's comment to comment column, or insert an empty comment.
 If CONTINUE is non-nil, use the `comment-continuation' markers if any."
@@ -397,9 +414,7 @@ If CONTINUE is non-nil, use the `comment-continuation' markers if any."
            (goto-char begpos))
           ;; Compute desired indent.
           (if (= (current-column)
-                 (setq indent (if comment-indent-hook
-                                  (funcall comment-indent-hook)
-                                (funcall comment-indent-function))))
+                 (setq indent (funcall comment-indent-function)))
               (goto-char begpos)
             ;; If that's different from current, change it.
             (skip-chars-backward " \t")
@@ -413,6 +428,7 @@ If CONTINUE is non-nil, use the `comment-continuation' markers if any."
             (save-excursion
               (insert ender))))))))
 
+;;;###autoload
 (defun comment-set-column (arg)
   "Set the comment column based on point.
 With no ARG, set the comment column to the current column.
@@ -434,6 +450,7 @@ With any other arg, set comment column to indentation of the previous comment
    (t (setq comment-column (current-column))
       (message "Comment column set to %d" comment-column))))
 
+;;;###autoload
 (defun comment-kill (arg)
   "Kill the comment on this line, if any.
 With prefix ARG, kill comments on that many lines starting with this one."
@@ -524,6 +541,7 @@ If N is `re', a regexp is returned instead, that would match
                (if multi (concat (regexp-quote (string c)) "*"))
                (regexp-quote s))))))
 
+;;;###autoload
 (defun uncomment-region (beg end &optional arg)
   "Uncomment each line in the BEG..END region.
 The numeric prefix ARG can specify a number of chars to remove from the
@@ -621,12 +639,12 @@ This is used for `extra-line' style (or `box' style if BLOCK is specified)."
             (e (concat ccs "a=m" ce))
             (c (if (string-match ".*\\S-\\S-" cs)
                    (aref cs (1- (match-end 0))) ?=))
-            (_ (assert (string-match "\\s-*a=m\\s-*" s)))
+            (_ (string-match "\\s-*a=m\\s-*" s))
             (fill
              (make-string (+ width (- (match-end 0)
                                       (match-beginning 0) (length cs) 3)) c)))
        (setq cs (replace-match fill t t s))
-       (assert (string-match "\\s-*a=m\\s-*" e))
+       (string-match "\\s-*a=m\\s-*" e)
        (setq ce (replace-match fill t t e))))
     (cons (concat cs "\n" (make-string min-indent ? ) ccs)
          (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce))))
@@ -739,13 +757,15 @@ rather than at left margin."
                (end-of-line)
                (not (or (eobp) (progn (forward-line) nil))))))))))
 
+;;;###autoload
 (defun comment-region (beg end &optional arg)
   "Comment or uncomment each line in the region.
 With just \\[universal-prefix] prefix arg, uncomment each line in region BEG..END.
 Numeric prefix arg ARG means use ARG comment characters.
 If ARG is negative, delete that many comment characters instead.
-Comments are terminated on each line, even for syntax in which newline does
-not end the comment.  Blank lines do not get comments.
+By default, comments start at the left margin, are terminated on each line,
+even for syntax in which newline does not end the comment and blank lines
+do not get comments.  This can be changed with `comment-style'.
 
 The strings used as comment starts are built from
 `comment-start' without trailing spaces and `comment-padding'."
@@ -812,6 +832,7 @@ end- comment markers additionally to what `comment-add' already specifies."
                           'box-multi 'box)))
     (comment-region beg end (+ comment-add arg))))
 
+;;;###autoload
 (defun comment-dwim (arg)
   "Call the comment command you want (Do What I Mean).
 If the region is active and `transient-mark-mode' is on, call
@@ -849,6 +870,7 @@ This has no effect in modes that do not define a comment syntax."
   :type 'boolean
   :group 'comment)
 
+;;;###autoload
 (defun comment-indent-new-line (&optional soft)
   "Break line at point and indent, continuing comment if within one.
 This indents the body of the continued comment
@@ -939,6 +961,23 @@ unless optional argument SOFT is non-nil."
 
 ;;; Change Log:
 ;; $Log: newcomment.el,v $
+;; Revision 1.16  2000/06/04 22:02:11  monnier
+;; (comment-indent): Ignore comment-indent-hook.
+;;
+;; Revision 1.15  2000/05/25 19:05:46  monnier
+;; Add abundant autoload cookies.
+;; (comment-style): Be careful not to depend on runtime data at compile-time.
+;; (comment-indent-hook): Remove.
+;; (comment-indent): Check if comment-indent-hook is bound.
+;; (comment-region): Docstring fix.
+;;
+;; Revision 1.14  2000/05/23 20:06:10  monnier
+;; (comment-make-extra-lines): Don't use `assert'.
+;;
+;; Revision 1.13  2000/05/22 04:23:37  monnier
+;; (comment-region-internal): Go back to BEG after quoting
+;; the nested comment markers.
+;;
 ;; Revision 1.12  2000/05/21 00:27:31  monnier
 ;; (comment-styles): New `box-multi'.
 ;; (comment-normalize-vars): Better default for comment-continue to