Mercurial > emacs
changeset 13586:292e11b5f9c6
(fill-context-prefix): New arg first-line-regexp.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 18 Nov 1995 16:42:57 +0000 |
parents | dc00b7be6593 |
children | a0c1c62e2c4a |
files | lisp/textmodes/fill.el |
diffstat | 1 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/fill.el Sat Nov 18 16:22:42 1995 +0000 +++ b/lisp/textmodes/fill.el Sat Nov 18 16:42:57 1995 +0000 @@ -130,24 +130,36 @@ (re-search-forward "[.?!][])}\"']*$" end t)) (insert-and-inherit ? )))) -(defun fill-context-prefix (from to) +(defun fill-context-prefix (from to &optional first-line-regexp) "Compute a fill prefix from the text between FROM and TO. -This uses the variables `adapive-fill-prefix' and `adaptive-fill-function'." +This uses the variables `adapive-fill-prefix' and `adaptive-fill-function'. +If FIRST-LINE-REGEXP is non-nil, then when taking a prefix from the +first line, insist it must match FIRST-LINE-REGEXP." (save-excursion (goto-char from) (if (eolp) (forward-line 1)) ;; Move to the second line unless there is just one. - (let ((firstline (point))) + (let ((firstline (point)) + ;; Non-nil if we are on the second line. + at-second + result) (forward-line 1) (if (>= (point) to) - (goto-char firstline))) - (move-to-left-margin) - (let ((start (point)) - (eol (save-excursion (end-of-line) (point)))) - (if (not (looking-at paragraph-start)) - (cond ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp)) - (buffer-substring-no-properties start (match-end 0))) - (adaptive-fill-function (funcall adaptive-fill-function))))))) + (goto-char firstline) + (setq at-second t)) + (move-to-left-margin) + (let ((start (point)) + (eol (save-excursion (end-of-line) (point)))) + (setq result + (if (not (looking-at paragraph-start)) + (cond ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp)) + (buffer-substring-no-properties start (match-end 0))) + (adaptive-fill-function (funcall adaptive-fill-function))))) + (and result + (or at-second + (null first-line-regexp) + (string-match first-line-regexp result)) + result))))) (defun fill-region-as-paragraph (from to &optional justify nosqueeze) "Fill the region as one paragraph.