diff options
| author | Stefan Monnier | 2000-05-25 19:05:46 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-05-25 19:05:46 +0000 |
| commit | be83ecb2d79c045cb6cc9c0ceee749d14e392c64 (patch) | |
| tree | 8bb1272e414b84e0f13f1480c461a05191d58d17 | |
| parent | 6fc596cf10244953a218ac1eab578317c6f9b487 (diff) | |
| download | emacs-be83ecb2d79c045cb6cc9c0ceee749d14e392c64.tar.gz emacs-be83ecb2d79c045cb6cc9c0ceee749d14e392c64.zip | |
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.
| -rw-r--r-- | lisp/newcomment.el | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index c13a5d89826..889f888b595 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> | 6 | ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> |
| 7 | ;; Keywords: comment uncomment | 7 | ;; Keywords: comment uncomment |
| 8 | ;; Version: $Name: $ | 8 | ;; Version: $Name: $ |
| 9 | ;; Revision: $Id: newcomment.el,v 1.13 2000/05/22 04:23:37 monnier Exp $ | 9 | ;; Revision: $Id: newcomment.el,v 1.14 2000/05/23 20:06:10 monnier Exp $ |
| 10 | 10 | ||
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | 12 | ||
| @@ -57,11 +57,16 @@ | |||
| 57 | 57 | ||
| 58 | ;;; Code: | 58 | ;;; Code: |
| 59 | 59 | ||
| 60 | ;;;###autoload | ||
| 60 | (defalias 'indent-for-comment 'comment-indent) | 61 | (defalias 'indent-for-comment 'comment-indent) |
| 62 | ;;;###autoload | ||
| 61 | (defalias 'set-comment-column 'comment-set-column) | 63 | (defalias 'set-comment-column 'comment-set-column) |
| 64 | ;;;###autoload | ||
| 62 | (defalias 'kill-comment 'comment-kill) | 65 | (defalias 'kill-comment 'comment-kill) |
| 66 | ;;;###autoload | ||
| 63 | (defalias 'indent-new-comment-line 'comment-indent-new-line) | 67 | (defalias 'indent-new-comment-line 'comment-indent-new-line) |
| 64 | 68 | ||
| 69 | ;;;###autoload | ||
| 65 | (defgroup comment nil | 70 | (defgroup comment nil |
| 66 | "Indenting and filling of comments." | 71 | "Indenting and filling of comments." |
| 67 | :prefix "comment-" | 72 | :prefix "comment-" |
| @@ -74,6 +79,7 @@ be used to try to determine whether syntax-tables should be trusted | |||
| 74 | to understand comments or not in the given buffer. | 79 | to understand comments or not in the given buffer. |
| 75 | Major modes should set this variable.") | 80 | Major modes should set this variable.") |
| 76 | 81 | ||
| 82 | ;;;###autoload | ||
| 77 | (defcustom comment-column 32 | 83 | (defcustom comment-column 32 |
| 78 | "*Column to indent right-margin comments to. | 84 | "*Column to indent right-margin comments to. |
| 79 | Setting this variable automatically makes it local to the current buffer. | 85 | Setting this variable automatically makes it local to the current buffer. |
| @@ -83,26 +89,26 @@ can set the value for a particular mode using that mode's hook." | |||
| 83 | :group 'comment) | 89 | :group 'comment) |
| 84 | (make-variable-buffer-local 'comment-column) | 90 | (make-variable-buffer-local 'comment-column) |
| 85 | 91 | ||
| 92 | ;;;###autoload | ||
| 86 | (defvar comment-start nil | 93 | (defvar comment-start nil |
| 87 | "*String to insert to start a new comment, or nil if no comment syntax.") | 94 | "*String to insert to start a new comment, or nil if no comment syntax.") |
| 88 | 95 | ||
| 96 | ;;;###autoload | ||
| 89 | (defvar comment-start-skip nil | 97 | (defvar comment-start-skip nil |
| 90 | "*Regexp to match the start of a comment plus everything up to its body. | 98 | "*Regexp to match the start of a comment plus everything up to its body. |
| 91 | If there are any \\(...\\) pairs, the comment delimiter text is held to begin | 99 | If there are any \\(...\\) pairs, the comment delimiter text is held to begin |
| 92 | at the place matched by the close of the first pair.") | 100 | at the place matched by the close of the first pair.") |
| 93 | 101 | ||
| 102 | ;;;###autoload | ||
| 94 | (defvar comment-end-skip nil | 103 | (defvar comment-end-skip nil |
| 95 | "Regexp to match the end of a comment plus everything up to its body.") | 104 | "Regexp to match the end of a comment plus everything up to its body.") |
| 96 | 105 | ||
| 106 | ;;;###autoload | ||
| 97 | (defvar comment-end "" | 107 | (defvar comment-end "" |
| 98 | "*String to insert to end a new comment. | 108 | "*String to insert to end a new comment. |
| 99 | Should be an empty string if comments are terminated by end-of-line.") | 109 | Should be an empty string if comments are terminated by end-of-line.") |
| 100 | 110 | ||
| 101 | (defvar comment-indent-hook nil | 111 | ;;;###autoload |
| 102 | "Obsolete variable for function to compute desired indentation for a comment. | ||
| 103 | This function is called with no args with point at the beginning of | ||
| 104 | the comment's starting delimiter.") | ||
| 105 | |||
| 106 | (defvar comment-indent-function | 112 | (defvar comment-indent-function |
| 107 | (lambda () comment-column) | 113 | (lambda () comment-column) |
| 108 | "Function to compute desired indentation for a comment. | 114 | "Function to compute desired indentation for a comment. |
| @@ -150,13 +156,17 @@ EXTRA specifies that an extra line should be used before and after the | |||
| 150 | INDENT specifies that the `comment-start' markers should not be put at the | 156 | INDENT specifies that the `comment-start' markers should not be put at the |
| 151 | left margin but at the current indentation of the region to comment.") | 157 | left margin but at the current indentation of the region to comment.") |
| 152 | 158 | ||
| 159 | ;;;###autoload | ||
| 153 | (defcustom comment-style 'plain | 160 | (defcustom comment-style 'plain |
| 154 | "*Style to be used for `comment-region'. | 161 | "*Style to be used for `comment-region'. |
| 155 | See `comment-styles' for a list of available styles." | 162 | See `comment-styles' for a list of available styles." |
| 156 | :group 'comment | 163 | :group 'comment |
| 157 | :type `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles))) | 164 | :type (if (boundp 'comment-styles) |
| 165 | `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles)) | ||
| 166 | 'symbol)) | ||
| 158 | 167 | ||
| 159 | (defcustom comment-padding 1 | 168 | ;;;###autoload |
| 169 | (defcustom comment-padding " " | ||
| 160 | "Padding string that `comment-region' puts between comment chars and text. | 170 | "Padding string that `comment-region' puts between comment chars and text. |
| 161 | Can also be an integer which will be automatically turned into a string | 171 | Can also be an integer which will be automatically turned into a string |
| 162 | of the corresponding number of spaces. | 172 | of the corresponding number of spaces. |
| @@ -164,6 +174,7 @@ of the corresponding number of spaces. | |||
| 164 | Extra spacing between the comment characters and the comment text | 174 | Extra spacing between the comment characters and the comment text |
| 165 | makes the comment easier to read. Default is 1. nil means 0.") | 175 | makes the comment easier to read. Default is 1. nil means 0.") |
| 166 | 176 | ||
| 177 | ;;;###autoload | ||
| 167 | (defcustom comment-multi-line nil | 178 | (defcustom comment-multi-line nil |
| 168 | "*Non-nil means \\[indent-new-comment-line] should continue same comment | 179 | "*Non-nil means \\[indent-new-comment-line] should continue same comment |
| 169 | on new line, with no new terminator or starter. | 180 | on new line, with no new terminator or starter. |
| @@ -379,6 +390,7 @@ Point is assumed to be just at the end of a comment." | |||
| 379 | ;;;; Commands | 390 | ;;;; Commands |
| 380 | ;;;; | 391 | ;;;; |
| 381 | 392 | ||
| 393 | ;;;###autoload | ||
| 382 | (defun comment-indent (&optional continue) | 394 | (defun comment-indent (&optional continue) |
| 383 | "Indent this line's comment to comment column, or insert an empty comment. | 395 | "Indent this line's comment to comment column, or insert an empty comment. |
| 384 | If CONTINUE is non-nil, use the `comment-continuation' markers if any." | 396 | If CONTINUE is non-nil, use the `comment-continuation' markers if any." |
| @@ -402,9 +414,9 @@ If CONTINUE is non-nil, use the `comment-continuation' markers if any." | |||
| 402 | (goto-char begpos)) | 414 | (goto-char begpos)) |
| 403 | ;; Compute desired indent. | 415 | ;; Compute desired indent. |
| 404 | (if (= (current-column) | 416 | (if (= (current-column) |
| 405 | (setq indent (if comment-indent-hook | 417 | (setq indent (funcall (or (and (boundp 'comment-indent-hook) |
| 406 | (funcall comment-indent-hook) | 418 | comment-indent-hook) |
| 407 | (funcall comment-indent-function)))) | 419 | comment-indent-function)))) |
| 408 | (goto-char begpos) | 420 | (goto-char begpos) |
| 409 | ;; If that's different from current, change it. | 421 | ;; If that's different from current, change it. |
| 410 | (skip-chars-backward " \t") | 422 | (skip-chars-backward " \t") |
| @@ -418,6 +430,7 @@ If CONTINUE is non-nil, use the `comment-continuation' markers if any." | |||
| 418 | (save-excursion | 430 | (save-excursion |
| 419 | (insert ender)))))))) | 431 | (insert ender)))))))) |
| 420 | 432 | ||
| 433 | ;;;###autoload | ||
| 421 | (defun comment-set-column (arg) | 434 | (defun comment-set-column (arg) |
| 422 | "Set the comment column based on point. | 435 | "Set the comment column based on point. |
| 423 | With no ARG, set the comment column to the current column. | 436 | With no ARG, set the comment column to the current column. |
| @@ -439,6 +452,7 @@ With any other arg, set comment column to indentation of the previous comment | |||
| 439 | (t (setq comment-column (current-column)) | 452 | (t (setq comment-column (current-column)) |
| 440 | (message "Comment column set to %d" comment-column)))) | 453 | (message "Comment column set to %d" comment-column)))) |
| 441 | 454 | ||
| 455 | ;;;###autoload | ||
| 442 | (defun comment-kill (arg) | 456 | (defun comment-kill (arg) |
| 443 | "Kill the comment on this line, if any. | 457 | "Kill the comment on this line, if any. |
| 444 | With prefix ARG, kill comments on that many lines starting with this one." | 458 | With prefix ARG, kill comments on that many lines starting with this one." |
| @@ -529,6 +543,7 @@ If N is `re', a regexp is returned instead, that would match | |||
| 529 | (if multi (concat (regexp-quote (string c)) "*")) | 543 | (if multi (concat (regexp-quote (string c)) "*")) |
| 530 | (regexp-quote s)))))) | 544 | (regexp-quote s)))))) |
| 531 | 545 | ||
| 546 | ;;;###autoload | ||
| 532 | (defun uncomment-region (beg end &optional arg) | 547 | (defun uncomment-region (beg end &optional arg) |
| 533 | "Uncomment each line in the BEG..END region. | 548 | "Uncomment each line in the BEG..END region. |
| 534 | The numeric prefix ARG can specify a number of chars to remove from the | 549 | The numeric prefix ARG can specify a number of chars to remove from the |
| @@ -744,13 +759,15 @@ rather than at left margin." | |||
| 744 | (end-of-line) | 759 | (end-of-line) |
| 745 | (not (or (eobp) (progn (forward-line) nil)))))))))) | 760 | (not (or (eobp) (progn (forward-line) nil)))))))))) |
| 746 | 761 | ||
| 762 | ;;;###autoload | ||
| 747 | (defun comment-region (beg end &optional arg) | 763 | (defun comment-region (beg end &optional arg) |
| 748 | "Comment or uncomment each line in the region. | 764 | "Comment or uncomment each line in the region. |
| 749 | With just \\[universal-prefix] prefix arg, uncomment each line in region BEG..END. | 765 | With just \\[universal-prefix] prefix arg, uncomment each line in region BEG..END. |
| 750 | Numeric prefix arg ARG means use ARG comment characters. | 766 | Numeric prefix arg ARG means use ARG comment characters. |
| 751 | If ARG is negative, delete that many comment characters instead. | 767 | If ARG is negative, delete that many comment characters instead. |
| 752 | Comments are terminated on each line, even for syntax in which newline does | 768 | By default, comments start at the left margin, are terminated on each line, |
| 753 | not end the comment. Blank lines do not get comments. | 769 | even for syntax in which newline does not end the comment and blank lines |
| 770 | do not get comments. This can be changed with `comment-style'. | ||
| 754 | 771 | ||
| 755 | The strings used as comment starts are built from | 772 | The strings used as comment starts are built from |
| 756 | `comment-start' without trailing spaces and `comment-padding'." | 773 | `comment-start' without trailing spaces and `comment-padding'." |
| @@ -817,6 +834,7 @@ end- comment markers additionally to what `comment-add' already specifies." | |||
| 817 | 'box-multi 'box))) | 834 | 'box-multi 'box))) |
| 818 | (comment-region beg end (+ comment-add arg)))) | 835 | (comment-region beg end (+ comment-add arg)))) |
| 819 | 836 | ||
| 837 | ;;;###autoload | ||
| 820 | (defun comment-dwim (arg) | 838 | (defun comment-dwim (arg) |
| 821 | "Call the comment command you want (Do What I Mean). | 839 | "Call the comment command you want (Do What I Mean). |
| 822 | If the region is active and `transient-mark-mode' is on, call | 840 | If the region is active and `transient-mark-mode' is on, call |
| @@ -854,6 +872,7 @@ This has no effect in modes that do not define a comment syntax." | |||
| 854 | :type 'boolean | 872 | :type 'boolean |
| 855 | :group 'comment) | 873 | :group 'comment) |
| 856 | 874 | ||
| 875 | ;;;###autoload | ||
| 857 | (defun comment-indent-new-line (&optional soft) | 876 | (defun comment-indent-new-line (&optional soft) |
| 858 | "Break line at point and indent, continuing comment if within one. | 877 | "Break line at point and indent, continuing comment if within one. |
| 859 | This indents the body of the continued comment | 878 | This indents the body of the continued comment |
| @@ -944,6 +963,9 @@ unless optional argument SOFT is non-nil." | |||
| 944 | 963 | ||
| 945 | ;;; Change Log: | 964 | ;;; Change Log: |
| 946 | ;; $Log: newcomment.el,v $ | 965 | ;; $Log: newcomment.el,v $ |
| 966 | ;; Revision 1.14 2000/05/23 20:06:10 monnier | ||
| 967 | ;; (comment-make-extra-lines): Don't use `assert'. | ||
| 968 | ;; | ||
| 947 | ;; Revision 1.13 2000/05/22 04:23:37 monnier | 969 | ;; Revision 1.13 2000/05/22 04:23:37 monnier |
| 948 | ;; (comment-region-internal): Go back to BEG after quoting | 970 | ;; (comment-region-internal): Go back to BEG after quoting |
| 949 | ;; the nested comment markers. | 971 | ;; the nested comment markers. |