comparison lisp/newcomment.el @ 41286:6b56e476153d

(comment-column, comment-style, comment-multi-line) (comment-auto-fill-only-comments): Remove :group arg. (comment-padding): Add :type. (comment-indent-new-line): Ignore comment-auto-fill-only-comments if called interactively.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 19 Nov 2001 20:55:30 +0000
parents 87ae7a37e076
children 4e6f73fdeab0
comparison
equal deleted inserted replaced
41285:822980b416cf 41286:6b56e476153d
3 ;; Copyright (C) 1999, 2000 Free Software Foundation Inc. 3 ;; Copyright (C) 1999, 2000 Free Software Foundation Inc.
4 4
5 ;; Author: code extracted from Emacs-20's simple.el 5 ;; Author: code extracted from Emacs-20's simple.el
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 ;; Revision: $Id: newcomment.el,v 1.38 2001/11/13 20:17:26 monnier Exp $ 8 ;; Revision: $Id: newcomment.el,v 1.39 2001/11/19 06:08:38 monnier Exp $
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
89 (defcustom comment-column 32 89 (defcustom comment-column 32
90 "*Column to indent right-margin comments to. 90 "*Column to indent right-margin comments to.
91 Setting this variable automatically makes it local to the current buffer. 91 Setting this variable automatically makes it local to the current buffer.
92 Each mode establishes a different default value for this variable; you 92 Each mode establishes a different default value for this variable; you
93 can set the value for a particular mode using that mode's hook." 93 can set the value for a particular mode using that mode's hook."
94 :type 'integer 94 :type 'integer)
95 :group 'comment)
96 (make-variable-buffer-local 'comment-column) 95 (make-variable-buffer-local 'comment-column)
97 96
98 ;;;###autoload 97 ;;;###autoload
99 (defvar comment-start nil 98 (defvar comment-start nil
100 "*String to insert to start a new comment, or nil if no comment syntax.") 99 "*String to insert to start a new comment, or nil if no comment syntax.")
165 164
166 ;;;###autoload 165 ;;;###autoload
167 (defcustom comment-style 'plain 166 (defcustom comment-style 'plain
168 "*Style to be used for `comment-region'. 167 "*Style to be used for `comment-region'.
169 See `comment-styles' for a list of available styles." 168 See `comment-styles' for a list of available styles."
170 :group 'comment
171 :type (if (boundp 'comment-styles) 169 :type (if (boundp 'comment-styles)
172 `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles)) 170 `(choice ,@(mapcar (lambda (s) `(const ,(car s))) comment-styles))
173 'symbol)) 171 'symbol))
174 172
175 ;;;###autoload 173 ;;;###autoload
177 "Padding string that `comment-region' puts between comment chars and text. 175 "Padding string that `comment-region' puts between comment chars and text.
178 Can also be an integer which will be automatically turned into a string 176 Can also be an integer which will be automatically turned into a string
179 of the corresponding number of spaces. 177 of the corresponding number of spaces.
180 178
181 Extra spacing between the comment characters and the comment text 179 Extra spacing between the comment characters and the comment text
182 makes the comment easier to read. Default is 1. nil means 0.") 180 makes the comment easier to read. Default is 1. nil means 0."
181 :type '(choice string integer (const nil)))
183 182
184 ;;;###autoload 183 ;;;###autoload
185 (defcustom comment-multi-line nil 184 (defcustom comment-multi-line nil
186 "*Non-nil means \\[comment-indent-new-line] continues comments, with no new terminator or starter. 185 "*Non-nil means \\[comment-indent-new-line] continues comments, with no new terminator or starter.
187 This is obsolete because you might as well use \\[newline-and-indent]." 186 This is obsolete because you might as well use \\[newline-and-indent]."
188 :type 'boolean 187 :type 'boolean)
189 :group 'comment)
190 188
191 ;;;; 189 ;;;;
192 ;;;; Helpers 190 ;;;; Helpers
193 ;;;; 191 ;;;;
194 192
921 (indent-according-to-mode)))))) 919 (indent-according-to-mode))))))
922 920
923 (defcustom comment-auto-fill-only-comments nil 921 (defcustom comment-auto-fill-only-comments nil
924 "Non-nil means to only auto-fill inside comments. 922 "Non-nil means to only auto-fill inside comments.
925 This has no effect in modes that do not define a comment syntax." 923 This has no effect in modes that do not define a comment syntax."
926 :type 'boolean 924 :type 'boolean)
927 :group 'comment)
928 925
929 (defun comment-valid-prefix (prefix compos) 926 (defun comment-valid-prefix (prefix compos)
930 (or 927 (or
931 ;; Accept any prefix if the current comment is not EOL-terminated. 928 ;; Accept any prefix if the current comment is not EOL-terminated.
932 (save-excursion (goto-char compos) (comment-forward) (not (bolp))) 929 (save-excursion (goto-char compos) (comment-forward) (not (bolp)))
954 (let (compos comin) 951 (let (compos comin)
955 ;; If we are not inside a comment and we only auto-fill comments, 952 ;; If we are not inside a comment and we only auto-fill comments,
956 ;; don't do anything (unless no comment syntax is defined). 953 ;; don't do anything (unless no comment syntax is defined).
957 (unless (and comment-start 954 (unless (and comment-start
958 comment-auto-fill-only-comments 955 comment-auto-fill-only-comments
956 (not (interactive-p))
959 (not (save-excursion 957 (not (save-excursion
960 (prog1 (setq compos (comment-beginning)) 958 (prog1 (setq compos (comment-beginning))
961 (setq comin (point)))))) 959 (setq comin (point))))))
962 960
963 ;; Now we know we should auto-fill. 961 ;; Now we know we should auto-fill.