From: Richard M. Stallman Date: Wed, 2 Aug 1995 18:36:20 +0000 (+0000) Subject: (fill-region-as-paragraph): Don't find adaptive-fill-regexp X-Git-Tag: emacs-19.34~3108 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=68152e8f81ab7140d9a00c0ae7c85aee7ccb4511;p=emacs.git (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. --- 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)