summaryrefslogtreecommitdiff
path: root/lisp/textmodes/fill.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-08-02 18:36:20 +0000
committerRichard M. Stallman <rms@gnu.org>1995-08-02 18:36:20 +0000
commit5469e7b881a5efc4300b68bf98dd9a16112adb47 (patch)
tree479f35e62c6db1b835a5639c28bd9ed3ab84053e /lisp/textmodes/fill.el
parent261115eda5ab7954afe510e0fd620424814fca50 (diff)
downloademacs-5469e7b881a5efc4300b68bf98dd9a16112adb47.tar.gz
(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.
Diffstat (limited to 'lisp/textmodes/fill.el')
-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.")
(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 @@ on the second line of a paragraph is used as the standard indentation
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 @@ Remove indentation from each line."
(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 @@ space does not end a sentence, so don't break a line there."
(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)