;;; newcomment.el --- (un)comment regions of buffers
-;; Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation Inc.
+;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
;; Author: code extracted from Emacs-20's simple.el
-;; Maintainer: Stefan Monnier <monnier@cs.yale.edu>
+;; Maintainer: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: comment uncomment
;; This file is part of GNU Emacs.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(defcustom comment-fill-column nil
"Column to use for `comment-indent'. If nil, use `fill-column' instead."
- :type '(choice (const nil) integer))
+ :type '(choice (const nil) integer)
+ :group 'comment)
;;;###autoload
(defcustom comment-column 32
can set the value for a particular mode using that mode's hook.
Comments might be indented to a value smaller than this in order
not to go beyond `comment-fill-column'."
- :type 'integer)
+ :type 'integer
+ :group 'comment)
(make-variable-buffer-local 'comment-column)
;;;###autoload
See `comment-styles' for a list of available styles."
:type (if (boundp 'comment-styles)
`(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles))
- 'symbol))
+ 'symbol)
+ :group 'comment)
;;;###autoload
(defcustom comment-padding " "
Extra spacing between the comment characters and the comment text
makes the comment easier to read. Default is 1. nil means 0."
- :type '(choice string integer (const nil)))
+ :type '(choice string integer (const nil))
+ :group 'comment)
;;;###autoload
(defcustom comment-multi-line nil
- "*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)
+ "*Non-nil means `comment-indent-new-line' continues comments.
+That is, it inserts no new terminator or starter.
+This affects `auto-fill-mode', which is the main reason to
+customize this variable.
+
+It also affects \\[indent-new-comment-line]. However, if you want this
+behavior for explicit filling, you might as well use \\[newline-and-indent]."
+ :type 'boolean
+ :group 'comment)
(defcustom comment-empty-lines nil
"If nil, `comment-region' does not comment out empty lines.
terminated by the end of line (i.e. `comment-end' is empty)."
:type '(choice (const :tag "Never" nil)
(const :tag "Always" t)
- (const :tag "EOl-terminated" 'eol)))
+ (const :tag "EOl-terminated" 'eol))
+ :group 'comment)
;;;;
;;;; Helpers
(defun comment-beginning ()
"Find the beginning of the enclosing comment.
Returns nil if not inside a comment, else moves point and returns
-the same as `comment-search-forward'."
+the same as `comment-search-backward'."
;; HACK ATTACK!
;; We should really test `in-string-p' but that can be expensive.
(unless (eq (get-text-property (point) 'face) 'font-lock-string-face)
(and
;; For modes where comment-start and comment-end are the same,
;; the search above may have found a `ce' rather than a `cs'.
- (or (not (looking-at comment-end-skip))
+ (or (if comment-end-skip (not (looking-at comment-end-skip)))
;; Maybe font-lock knows that it's a `cs'?
(eq (get-text-property (match-end 0) 'face)
'font-lock-comment-face)
(or (match-end 1) (/= (current-column) (current-indentation))))
0
(when (or (/= (current-column) (current-indentation))
- (and (> comment-add 0) (looking-at "\\s<\\S<")))
+ (and (> comment-add 0) (looking-at "\\s<\\(\\S<\\|\\'\\)")))
comment-column)))
;;;###autoload
(insert (comment-padleft comment-end add)))
(indent-according-to-mode))))))
+;;;###autoload
(defcustom comment-auto-fill-only-comments nil
"Non-nil means to only auto-fill inside comments.
This has no effect in modes that do not define a comment syntax."
- :type 'boolean)
+ :type 'boolean
+ :group 'comment)
(defun comment-valid-prefix-p (prefix compos)
(or