[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/textmodes/fill.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/textmodes/fill.el |
Date: |
Mon, 13 Jun 2005 15:33:24 -0400 |
Index: emacs/lisp/textmodes/fill.el
diff -c emacs/lisp/textmodes/fill.el:1.177 emacs/lisp/textmodes/fill.el:1.178
*** emacs/lisp/textmodes/fill.el:1.177 Sat Jun 11 13:49:56 2005
--- emacs/lisp/textmodes/fill.el Mon Jun 13 19:33:21 2005
***************
*** 1,7 ****
;;; fill.el --- fill commands for Emacs -*- coding:
iso-2022-7bit -*-
! ;; Copyright (C) 1985,86,92,94,95,96,97,1999,2001,02,03,2004
! ;; Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: wp
--- 1,7 ----
;;; fill.el --- fill commands for Emacs -*- coding:
iso-2022-7bit -*-
! ;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1999, 2001, 2002,
! ;; 2003, 2004, 2005 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: wp
***************
*** 205,210 ****
--- 205,220 ----
(unless (zerop cmp)
(substring s1 0 cmp)))))
+ (defun fill-match-adaptive-prefix ()
+ (let ((str (or
+ (and adaptive-fill-function (funcall adaptive-fill-function))
+ (and adaptive-fill-regexp (looking-at adaptive-fill-regexp)
+ (match-string-no-properties 0)))))
+ (if (>= (+ (current-left-margin) (length str)) (current-fill-column))
+ ;; Death to insanely long prefixes.
+ nil
+ str)))
+
(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 `adaptive-fill-regexp' and `adaptive-fill-function'
***************
*** 218,272 ****
(if (eolp) (forward-line 1))
;; Move to the second line unless there is just one.
(move-to-left-margin)
! (let ((firstline (point))
! first-line-prefix
;; Non-nil if we are on the second line.
! second-line-prefix
! start)
! (setq start (point))
(setq first-line-prefix
;; We don't need to consider `paragraph-start' here since it
;; will be explicitly checked later on.
;; Also setting first-line-prefix to nil prevents
;; second-line-prefix from being used.
! (cond ;; ((looking-at paragraph-start) nil)
! ((and adaptive-fill-function (funcall
adaptive-fill-function)))
! ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp))
! (match-string-no-properties 0))))
(forward-line 1)
(if (< (point) to)
! (progn
! (move-to-left-margin)
! (setq start (point))
! (setq second-line-prefix
! (cond ((looking-at paragraph-start) nil) ;Can it happen ? -stef
! ((and adaptive-fill-function
! (funcall adaptive-fill-function)))
! ((and adaptive-fill-regexp
! (looking-at adaptive-fill-regexp))
! (buffer-substring-no-properties start (match-end 0)))))
! ;; If we get a fill prefix from the second line,
! ;; make sure it or something compatible is on the first line too.
! (when second-line-prefix
! (unless first-line-prefix (setq first-line-prefix ""))
! ;; If the non-whitespace chars match the first line,
! ;; just use it (this subsumes the 2 checks used previously).
! ;; Used when first line is `/* ...' and second-line is
! ;; ` * ...'.
! (let ((tmp second-line-prefix)
! (re "\\`"))
! (while (string-match "\\`[ \t]*\\([^ \t]+\\)" tmp)
! (setq re (concat re ".*" (regexp-quote (match-string 1 tmp))))
! (setq tmp (substring tmp (match-end 0))))
! ;; (assert (string-match "\\`[ \t]*\\'" tmp))
!
! (if (string-match re first-line-prefix)
! second-line-prefix
!
! ;; Use the longest common substring of both prefixes,
! ;; if there is one.
! (fill-common-string-prefix first-line-prefix
! second-line-prefix)))))
;; If we get a fill prefix from a one-line paragraph,
;; maybe change it to whitespace,
;; and check that it isn't a paragraph starter.
--- 228,272 ----
(if (eolp) (forward-line 1))
;; Move to the second line unless there is just one.
(move-to-left-margin)
! (let (first-line-prefix
;; Non-nil if we are on the second line.
! second-line-prefix)
(setq first-line-prefix
;; We don't need to consider `paragraph-start' here since it
;; will be explicitly checked later on.
;; Also setting first-line-prefix to nil prevents
;; second-line-prefix from being used.
! ;; ((looking-at paragraph-start) nil)
! (fill-match-adaptive-prefix))
(forward-line 1)
(if (< (point) to)
! (progn
! (move-to-left-margin)
! (setq second-line-prefix
! (cond ((looking-at paragraph-start) nil) ;Can it happen?
-Stef
! (t (fill-match-adaptive-prefix))))
! ;; If we get a fill prefix from the second line,
! ;; make sure it or something compatible is on the first line too.
! (when second-line-prefix
! (unless first-line-prefix (setq first-line-prefix ""))
! ;; If the non-whitespace chars match the first line,
! ;; just use it (this subsumes the 2 checks used previously).
! ;; Used when first line is `/* ...' and second-line is
! ;; ` * ...'.
! (let ((tmp second-line-prefix)
! (re "\\`"))
! (while (string-match "\\`[ \t]*\\([^ \t]+\\)" tmp)
! (setq re (concat re ".*" (regexp-quote (match-string 1
tmp))))
! (setq tmp (substring tmp (match-end 0))))
! ;; (assert (string-match "\\`[ \t]*\\'" tmp))
!
! (if (string-match re first-line-prefix)
! second-line-prefix
!
! ;; Use the longest common substring of both prefixes,
! ;; if there is one.
! (fill-common-string-prefix first-line-prefix
! second-line-prefix)))))
;; If we get a fill prefix from a one-line paragraph,
;; maybe change it to whitespace,
;; and check that it isn't a paragraph starter.
***************
*** 333,339 ****
Can be customized with the variables `fill-nobreak-predicate'
and `fill-nobreak-invisible'."
(or
! (and fill-nobreak-invisible (line-move-invisible (point)))
(unless (bolp)
(or
;; Don't break after a period followed by just one space.
--- 333,339 ----
Can be customized with the variables `fill-nobreak-predicate'
and `fill-nobreak-invisible'."
(or
! (and fill-nobreak-invisible (line-move-invisible-p (point)))
(unless (bolp)
(or
;; Don't break after a period followed by just one space.
***************
*** 1128,1135 ****
ncols ; new indent point or offset
(nspaces 0) ; number of spaces between words
; in line (not space characters)
- fracspace ; fractional amount of space to be
- ; added between each words
(curr-fracspace 0) ; current fractional space amount
count)
(end-of-line)
--- 1128,1133 ----
***************
*** 1338,1344 ****
(forward-line 1))))
(narrow-to-region (point) max)
;; Loop over paragraphs.
! (while (let ((here (point)))
;; Skip over all paragraph-separating lines
;; so as to not include them in any paragraph.
(while (and (not (eobp))
--- 1336,1342 ----
(forward-line 1))))
(narrow-to-region (point) max)
;; Loop over paragraphs.
! (while (progn
;; Skip over all paragraph-separating lines
;; so as to not include them in any paragraph.
(while (and (not (eobp))
***************
*** 1446,1450 ****
"")
string))
! ;;; arch-tag: 727ad455-1161-4fa9-8df5-0f74b179216d
;;; fill.el ends here
--- 1444,1448 ----
"")
string))
! ;; arch-tag: 727ad455-1161-4fa9-8df5-0f74b179216d
;;; fill.el ends here