changeset 12752:86c8fb2284de

(fill-region-as-paragraph): Don't find adaptive-fill-regexp on first line of paragraph if it's a paragraph-separate line. Don't look past the intended line. (adaptive-fill-function): New variable. (fill-region-as-paragraph): Use it. (colon-double-space): New variable. (canonically-space-region): Put two spaces after colon if necessary.
author Richard M. Stallman <rms@gnu.org>
date Wed, 02 Aug 1995 18:36:20 +0000
parents f442c14a79c4
children 8b24e2806602
files lisp/textmodes/fill.el
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/fill.el	Wed Aug 02 18:34:19 1995 +0000
+++ b/lisp/textmodes/fill.el	Wed Aug 02 18:36:20 1995 +0000
@@ -37,6 +37,9 @@
 (defconst sentence-end-double-space t
   "*Non-nil means a single space does not end a sentence.")
 
+(defconst colon-double-space nil
+  "*Non-nil means put two spaces after a colon when filling.")
+
 (defvar fill-paragraph-function nil
   "Mode-specific function to fill a paragraph.")
 
@@ -64,6 +67,10 @@
 for the paragraph.  If the paragraph has just one line, the indentation
 is taken from that line.")
 
+(defun adaptive-fill-function nil
+  "*Function to call to choose a fill prefix for a paragraph.
+This function is used when `adaptive-fill-regexp' does not match.")
+
 (defun current-fill-column ()
   "Return the fill-column to use for this line.
 The fill-column to use for a buffer is stored in the variable `fill-column',
@@ -111,6 +118,8 @@
 	    (skip-chars-backward " ]})\"'")
 	    (cond ((and sentence-end-double-space
 			(memq (preceding-char) '(?. ?? ?!)))  2)
+		  ((and colon-double-space
+			(= (preceding-char) ?:))  2)
 		  ((char-equal (preceding-char) ?\n)  0)
 		  (t 1))))
        (match-end 0)))
@@ -187,12 +196,15 @@
 	      (if (>= (point) to)
 		  (goto-char firstline)))
 	    (move-to-left-margin)
-	    (let ((start (point)))
-	      (re-search-forward adaptive-fill-regexp)
-	      (setq fill-prefix (buffer-substring start (point)))
-	      (set-text-properties 0 (length fill-prefix) nil
-				   fill-prefix))
-	    ))
+	    (let ((start (point))
+		  (eol (save-excursion (end-of-line) (point)))
+		  temp)
+	      (if (not (looking-at paragraph-start))
+		  (cond ((re-search-forward adaptive-fill-regexp nil t)
+			 (setq fill-prefix
+			       (buffer-substring-no-properties start (point))))
+			((setq temp (funcall adaptive-fill-function))
+			 (setq fill-prefix temp)))))))
 
       (save-restriction
 	(goto-char from)