aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-08-02 18:36:20 +0000
committerRichard M. Stallman1995-08-02 18:36:20 +0000
commit68152e8f81ab7140d9a00c0ae7c85aee7ccb4511 (patch)
tree0411842233558d2fb450af3a9541a2ae270921e5
parenta5c31fa1f037f82b7a914c33e0fe77f31a7ddd26 (diff)
downloademacs-68152e8f81ab7140d9a00c0ae7c85aee7ccb4511.tar.gz
emacs-68152e8f81ab7140d9a00c0ae7c85aee7ccb4511.zip
(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.
-rw-r--r--lisp/textmodes/fill.el24
1 files changed, 18 insertions, 6 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index a384125db90..991ca8a1933 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -37,6 +37,9 @@ A value of nil means that any change in indentation starts a new paragraph.")
37(defconst sentence-end-double-space t 37(defconst sentence-end-double-space t
38 "*Non-nil means a single space does not end a sentence.") 38 "*Non-nil means a single space does not end a sentence.")
39 39
40(defconst colon-double-space nil
41 "*Non-nil means put two spaces after a colon when filling.")
42
40(defvar fill-paragraph-function nil 43(defvar fill-paragraph-function nil
41 "Mode-specific function to fill a paragraph.") 44 "Mode-specific function to fill a paragraph.")
42 45
@@ -64,6 +67,10 @@ on the second line of a paragraph is used as the standard indentation
64for the paragraph. If the paragraph has just one line, the indentation 67for the paragraph. If the paragraph has just one line, the indentation
65is taken from that line.") 68is taken from that line.")
66 69
70(defun adaptive-fill-function nil
71 "*Function to call to choose a fill prefix for a paragraph.
72This function is used when `adaptive-fill-regexp' does not match.")
73
67(defun current-fill-column () 74(defun current-fill-column ()
68 "Return the fill-column to use for this line. 75 "Return the fill-column to use for this line.
69The fill-column to use for a buffer is stored in the variable `fill-column', 76The fill-column to use for a buffer is stored in the variable `fill-column',
@@ -111,6 +118,8 @@ Remove indentation from each line."
111 (skip-chars-backward " ]})\"'") 118 (skip-chars-backward " ]})\"'")
112 (cond ((and sentence-end-double-space 119 (cond ((and sentence-end-double-space
113 (memq (preceding-char) '(?. ?? ?!))) 2) 120 (memq (preceding-char) '(?. ?? ?!))) 2)
121 ((and colon-double-space
122 (= (preceding-char) ?:)) 2)
114 ((char-equal (preceding-char) ?\n) 0) 123 ((char-equal (preceding-char) ?\n) 0)
115 (t 1)))) 124 (t 1))))
116 (match-end 0))) 125 (match-end 0)))
@@ -187,12 +196,15 @@ space does not end a sentence, so don't break a line there."
187 (if (>= (point) to) 196 (if (>= (point) to)
188 (goto-char firstline))) 197 (goto-char firstline)))
189 (move-to-left-margin) 198 (move-to-left-margin)
190 (let ((start (point))) 199 (let ((start (point))
191 (re-search-forward adaptive-fill-regexp) 200 (eol (save-excursion (end-of-line) (point)))
192 (setq fill-prefix (buffer-substring start (point))) 201 temp)
193 (set-text-properties 0 (length fill-prefix) nil 202 (if (not (looking-at paragraph-start))
194 fill-prefix)) 203 (cond ((re-search-forward adaptive-fill-regexp nil t)
195 )) 204 (setq fill-prefix
205 (buffer-substring-no-properties start (point))))
206 ((setq temp (funcall adaptive-fill-function))
207 (setq fill-prefix temp)))))))
196 208
197 (save-restriction 209 (save-restriction
198 (goto-char from) 210 (goto-char from)