(paragraph-separate): Doc fix.
[bpt/emacs.git] / lisp / textmodes / paragraphs.el
index 683845a..4f37376 100644 (file)
@@ -1,6 +1,7 @@
 ;;; paragraphs.el --- paragraph and sentence parsing.
 
-;; Copyright (C) 1985, 86, 87, 91, 94, 95 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 86, 87, 91, 94, 95, 96, 1997
+;;    Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: wp
 
 ;;; Code:
 
+(defgroup paragraphs nil
+  "Paragraph and sentence parsing."
+  :group 'editing)
+
+;; It isn't useful to use defcustom for this variable
+;; because it is always buffer-local.
 (defvar use-hard-newlines nil
     "Non-nil means to distinguish hard and soft newlines.
-See documentation for the `use-hard-newlines' function.")
+See also the documentation for the function `use-hard-newlines'.")
 (make-variable-buffer-local 'use-hard-newlines)
 
 (defun use-hard-newlines (&optional arg insert)
@@ -85,7 +92,7 @@ to paragraphs.  The fill functions insert and delete only soft newlines."
                               (point) (1+ (point))))))))))))
     (setq use-hard-newlines t)))
 
-(defconst paragraph-start "[ \t\n\f]" "\
+(defcustom paragraph-start "[ \t\n\f]" "\
 *Regexp for beginning of a line that starts OR separates paragraphs.
 This regexp should match lines that separate paragraphs
 and should also match lines that start a paragraph
@@ -100,7 +107,9 @@ The variable `paragraph-separate' specifies how to distinguish
 lines that start paragraphs from lines that separate them.
 
 If the variable `use-hard-newlines' is nonnil, then only lines following a
-hard newline are considered to match.")
+hard newline are considered to match."
+  :group 'paragraphs
+  :type 'regexp)
 
 ;; paragraph-start requires a hard newline, but paragraph-separate does not:
 ;; It is assumed that paragraph-separate is distinctive enough to be believed
@@ -108,33 +117,42 @@ hard newline are considered to match.")
 ;; something very minimal, even including "." (which makes every hard newline
 ;; start a new paragraph).
 
-(defconst paragraph-separate "[ \t\f]*$" "\
-*Regexp for beginning of a line that separates paragraphs.
-If you change this, you may have to change paragraph-start also.
+(defcustom paragraph-separate "[ \t\f]*$"
+  "*Regexp for beginning of a line that separates paragraphs.
+If you change this, you may have to change `paragraph-start' also.
 
 This is matched against the text at the left margin, which is not necessarily
 the beginning of the line, so it should not use \"^\" as an anchor.  This
 ensures that the paragraph functions will work equally within a region of
-text indented by a margin setting.")
+text indented by a margin setting."
+  :group 'paragraphs
+  :type 'regexp)
 
-(defconst sentence-end (purecopy "[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*") "\
-*Regexp describing the end of a sentence.
+(defcustom sentence-end (purecopy "[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*")
+  "*Regexp describing the end of a sentence.
 All paragraph boundaries also end sentences, regardless.
 
 In order to be recognized as the end of a sentence, the ending period,
 question mark, or exclamation point must be followed by two spaces,
-unless it's inside some sort of quotes or parenthesis.")
+unless it's inside some sort of quotes or parenthesis."
+  :group 'paragraphs
+  :type 'regexp)
 
-(defconst page-delimiter "^\014" "\
-*Regexp describing line-beginnings that separate pages.")
+(defcustom page-delimiter "^\014"
+  "*Regexp describing line-beginnings that separate pages."
+  :group 'paragraphs
+  :type 'regexp)
 
-(defvar paragraph-ignore-fill-prefix nil "\
-Non-nil means the paragraph commands are not affected by `fill-prefix'.
-This is desirable in modes where blank lines are the paragraph delimiters.")
+(defcustom paragraph-ignore-fill-prefix nil
+  "*Non-nil means the paragraph commands are not affected by `fill-prefix'.
+This is desirable in modes where blank lines are the paragraph delimiters."
+  :group 'paragraphs
+  :type 'boolean)
 
 (defun forward-paragraph (&optional arg)
   "Move forward to end of paragraph.
-With arg N, do it N times; negative arg -N means move backward N paragraphs.
+With argument ARG, do it ARG times;
+a negative argument ARG = -N means move backward N paragraphs.
 
 A line which `paragraph-start' matches either separates paragraphs
 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
@@ -155,9 +173,9 @@ to which the end of the previous line belongs, or the end of the buffer."
                                   (equal ?^ (aref paragraph-start 0)))
                              (substring paragraph-start 1)
                            paragraph-start))
-        (paragraph-separate (if (and (not (equal "" paragraph-start))
+        (paragraph-separate (if (and (not (equal "" paragraph-separate))
                                      (equal ?^ (aref paragraph-separate 0)))
-                             (substring paragraph-separate 1)
+                                (substring paragraph-separate 1)
                            paragraph-separate))
         (paragraph-separate
          (if fill-prefix-regexp
@@ -166,7 +184,7 @@ to which the end of the previous line belongs, or the end of the buffer."
            paragraph-separate))
         ;; This is used for searching.
         (sp-paragraph-start (concat "^[ \t]*\\(" paragraph-start "\\)"))
-        start)
+        start found-start)
     (while (and (< arg 0) (not (bobp)))
       (if (and (not (looking-at paragraph-separate))
               (re-search-backward "^\n" (max (1- (point)) (point-min)) t)
@@ -195,26 +213,31 @@ to which the end of the previous line belongs, or the end of the buffer."
                          (setq multiple-lines t))
                      (forward-line -1))
                    (move-to-left-margin)
-                   ;; Don't move back over a line before the paragraph
-                   ;; which doesn't start with fill-prefix
-                   ;; unless that is the only line we've moved over.
-                   (and (not (looking-at fill-prefix-regexp))
-                        multiple-lines
-                        (forward-line 1))
+;;; This deleted code caused a long hanging-indent line
+;;; not to be filled together with the following lines.
+;;;                ;; Don't move back over a line before the paragraph
+;;;                ;; which doesn't start with fill-prefix
+;;;                ;; unless that is the only line we've moved over.
+;;;                (and (not (looking-at fill-prefix-regexp))
+;;;                     multiple-lines
+;;;                     (forward-line 1))
                    (not (bobp)))
                (while (and (re-search-backward sp-paragraph-start nil 1)
+                           (setq found-start t)
                            ;; Found a candidate, but need to check if it is a
                            ;; REAL paragraph-start.
-                           (not (bobp))
                            (progn (setq start (point))
                                   (move-to-left-margin)
                                   (not (looking-at paragraph-separate)))
-                           (or (not (looking-at paragraph-start))
-                               (and use-hard-newlines
-                                    (not (get-text-property (1- start)
-                                                            'hard)))))
+                           (not (and (looking-at paragraph-start)
+                                     (not
+                                      (and use-hard-newlines
+                                           (not (bobp))
+                                           (not (get-text-property (1- start)
+                                                                   'hard)))))))
+                 (setq found-start nil)
                  (goto-char start))
-               (> (point) (point-min)))
+               found-start)
              ;; Found one.
              (progn
                ;; Move forward over paragraph separators.
@@ -263,7 +286,8 @@ to which the end of the previous line belongs, or the end of the buffer."
 
 (defun backward-paragraph (&optional arg)
   "Move backward to start of paragraph.
-With arg N, do it N times; negative arg -N means move forward N paragraphs.
+With argument ARG, do it ARG times;
+a negative argument ARG = -N means move forward N paragraphs.
 
 A paragraph start is the beginning of a line which is a
 `first-line-of-paragraph' or which is ordinary text and follows a