aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes/fill.el
diff options
context:
space:
mode:
authorKaroly Lorentey2005-06-15 12:57:51 +0000
committerKaroly Lorentey2005-06-15 12:57:51 +0000
commitef85512e51f043d73788f00a2aed13cccde0682c (patch)
treefc1fa1378533250f260ef8eaa9a84ae882d9df84 /lisp/textmodes/fill.el
parent8736257554f49445f7b4402ac7a9436b38ce6452 (diff)
parentef88a9999004e6c26148c8d280d6a41f623d7249 (diff)
downloademacs-ef85512e51f043d73788f00a2aed13cccde0682c.tar.gz
emacs-ef85512e51f043d73788f00a2aed13cccde0682c.zip
Merged from miles@gnu.org--gnu-2005 (patch 80-82, 350-422)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-350 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-352 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-353 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-354 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-355 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-356 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-357 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-358 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-359 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-360 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-362 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-363 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-364 Remove "-face" suffix from widget faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-365 Remove "-face" suffix from custom faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-366 Remove "-face" suffix from change-log faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-367 Remove "-face" suffix from compilation faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368 Remove "-face" suffix from diff-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-369 lisp/longlines.el (longlines-visible-face): Face removed * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370 Remove "-face" suffix from woman faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371 Remove "-face" suffix from whitespace-highlight face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372 Remove "-face" suffix from ruler-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-373 Remove "-face" suffix from show-paren faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-374 Remove "-face" suffix from log-view faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375 Remove "-face" suffix from smerge faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-376 Remove "-face" suffix from show-tabs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-377 Remove "-face" suffix from highlight-changes faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-378 Remove "-face" suffix from and downcase info faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-379 Remove "-face" suffix from pcvs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-380 Update uses of renamed pcvs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-381 Tweak ChangeLog * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-382 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-383 Remove "-face" suffix from strokes-char face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-384 Remove "-face" suffix from compare-windows face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-385 Remove "-face" suffix from calendar faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-386 Remove "-face" suffix from diary-button face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-387 Remove "-face" suffix from testcover faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-388 Remove "-face" suffix from viper faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-389 Remove "-face" suffix from org faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-390 Remove "-face" suffix from sgml-namespace face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391 Remove "-face" suffix from table-cell face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392 Remove "-face" suffix from tex-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-393 Remove "-face" suffix from texinfo-heading face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-394 Remove "-face" suffix from flyspell faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-396 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-397 Remove "-face" suffix from gomoku faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398 Remove "-face" suffix from mpuz faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-399 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-401 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-403 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-404 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-405 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-406 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-407 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-408 Remove "-face" suffix from Buffer-menu-buffer face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409 Remove "-face" suffix from antlr-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-410 Remove "-face" suffix from ebrowse faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-411 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-412 Remove "-face" suffix from flymake faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-413 Remove "-face" suffix from idlwave faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-414 Remove "-face" suffix from sh-script faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-415 Remove "-face" suffix from vhdl-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-416 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-417 Remove "-face" suffix from which-func face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-418 Remove "-face" suffix from cperl-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-419 Remove "-face" suffix from ld-script faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-420 Fix cperl-mode font-lock problem * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-421 Tweak which-func face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-422 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-80 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-81 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-82 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-350
Diffstat (limited to 'lisp/textmodes/fill.el')
-rw-r--r--lisp/textmodes/fill.el96
1 files changed, 47 insertions, 49 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 1615da60910..7d4ee6ec00d 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -1,7 +1,7 @@
1;;; fill.el --- fill commands for Emacs -*- coding: iso-2022-7bit -*- 1;;; fill.el --- fill commands for Emacs -*- coding: iso-2022-7bit -*-
2 2
3;; Copyright (C) 1985,86,92,94,95,96,97,1999,2001,02,03,2004 3;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1999, 2001, 2002,
4;; Free Software Foundation, Inc. 4;; 2003, 2004, 2005 Free Software Foundation, Inc.
5 5
6;; Maintainer: FSF 6;; Maintainer: FSF
7;; Keywords: wp 7;; Keywords: wp
@@ -115,7 +115,7 @@ if it would act as a paragraph-starter on the second line."
115 115
116(defcustom adaptive-fill-function nil 116(defcustom adaptive-fill-function nil
117 "*Function to call to choose a fill prefix for a paragraph, or nil. 117 "*Function to call to choose a fill prefix for a paragraph, or nil.
118This function is used when `adaptive-fill-regexp' does not match." 118nil means the function has not determined the fill prefix."
119 :type '(choice (const nil) function) 119 :type '(choice (const nil) function)
120 :group 'fill) 120 :group 'fill)
121 121
@@ -205,6 +205,16 @@ Remove indentation from each line."
205 (unless (zerop cmp) 205 (unless (zerop cmp)
206 (substring s1 0 cmp))))) 206 (substring s1 0 cmp)))))
207 207
208(defun fill-match-adaptive-prefix ()
209 (let ((str (or
210 (and adaptive-fill-function (funcall adaptive-fill-function))
211 (and adaptive-fill-regexp (looking-at adaptive-fill-regexp)
212 (match-string-no-properties 0)))))
213 (if (>= (+ (current-left-margin) (length str)) (current-fill-column))
214 ;; Death to insanely long prefixes.
215 nil
216 str)))
217
208(defun fill-context-prefix (from to &optional first-line-regexp) 218(defun fill-context-prefix (from to &optional first-line-regexp)
209 "Compute a fill prefix from the text between FROM and TO. 219 "Compute a fill prefix from the text between FROM and TO.
210This uses the variables `adaptive-fill-regexp' and `adaptive-fill-function' 220This uses the variables `adaptive-fill-regexp' and `adaptive-fill-function'
@@ -218,55 +228,45 @@ act as a paragraph-separator."
218 (if (eolp) (forward-line 1)) 228 (if (eolp) (forward-line 1))
219 ;; Move to the second line unless there is just one. 229 ;; Move to the second line unless there is just one.
220 (move-to-left-margin) 230 (move-to-left-margin)
221 (let ((firstline (point)) 231 (let (first-line-prefix
222 first-line-prefix
223 ;; Non-nil if we are on the second line. 232 ;; Non-nil if we are on the second line.
224 second-line-prefix 233 second-line-prefix)
225 start)
226 (setq start (point))
227 (setq first-line-prefix 234 (setq first-line-prefix
228 ;; We don't need to consider `paragraph-start' here since it 235 ;; We don't need to consider `paragraph-start' here since it
229 ;; will be explicitly checked later on. 236 ;; will be explicitly checked later on.
230 ;; Also setting first-line-prefix to nil prevents 237 ;; Also setting first-line-prefix to nil prevents
231 ;; second-line-prefix from being used. 238 ;; second-line-prefix from being used.
232 (cond ;; ((looking-at paragraph-start) nil) 239 ;; ((looking-at paragraph-start) nil)
233 ((and adaptive-fill-regexp (looking-at adaptive-fill-regexp)) 240 (fill-match-adaptive-prefix))
234 (match-string-no-properties 0))
235 (adaptive-fill-function (funcall adaptive-fill-function))))
236 (forward-line 1) 241 (forward-line 1)
237 (if (< (point) to) 242 (if (< (point) to)
238 (progn 243 (progn
239 (move-to-left-margin) 244 (move-to-left-margin)
240 (setq start (point)) 245 (setq second-line-prefix
241 (setq second-line-prefix 246 (cond ((looking-at paragraph-start) nil) ;Can it happen? -Stef
242 (cond ((looking-at paragraph-start) nil) ;Can it happen ? -stef 247 (t (fill-match-adaptive-prefix))))
243 ((and adaptive-fill-regexp 248 ;; If we get a fill prefix from the second line,
244 (looking-at adaptive-fill-regexp)) 249 ;; make sure it or something compatible is on the first line too.
245 (buffer-substring-no-properties start (match-end 0))) 250 (when second-line-prefix
246 (adaptive-fill-function 251 (unless first-line-prefix (setq first-line-prefix ""))
247 (funcall adaptive-fill-function)))) 252 ;; If the non-whitespace chars match the first line,
248 ;; If we get a fill prefix from the second line, 253 ;; just use it (this subsumes the 2 checks used previously).
249 ;; make sure it or something compatible is on the first line too. 254 ;; Used when first line is `/* ...' and second-line is
250 (when second-line-prefix 255 ;; ` * ...'.
251 (unless first-line-prefix (setq first-line-prefix "")) 256 (let ((tmp second-line-prefix)
252 ;; If the non-whitespace chars match the first line, 257 (re "\\`"))
253 ;; just use it (this subsumes the 2 checks used previously). 258 (while (string-match "\\`[ \t]*\\([^ \t]+\\)" tmp)
254 ;; Used when first line is `/* ...' and second-line is 259 (setq re (concat re ".*" (regexp-quote (match-string 1 tmp))))
255 ;; ` * ...'. 260 (setq tmp (substring tmp (match-end 0))))
256 (let ((tmp second-line-prefix) 261 ;; (assert (string-match "\\`[ \t]*\\'" tmp))
257 (re "\\`")) 262
258 (while (string-match "\\`[ \t]*\\([^ \t]+\\)" tmp) 263 (if (string-match re first-line-prefix)
259 (setq re (concat re ".*" (regexp-quote (match-string 1 tmp)))) 264 second-line-prefix
260 (setq tmp (substring tmp (match-end 0)))) 265
261 ;; (assert (string-match "\\`[ \t]*\\'" tmp)) 266 ;; Use the longest common substring of both prefixes,
262 267 ;; if there is one.
263 (if (string-match re first-line-prefix) 268 (fill-common-string-prefix first-line-prefix
264 second-line-prefix 269 second-line-prefix)))))
265
266 ;; Use the longest common substring of both prefixes,
267 ;; if there is one.
268 (fill-common-string-prefix first-line-prefix
269 second-line-prefix)))))
270 ;; If we get a fill prefix from a one-line paragraph, 270 ;; If we get a fill prefix from a one-line paragraph,
271 ;; maybe change it to whitespace, 271 ;; maybe change it to whitespace,
272 ;; and check that it isn't a paragraph starter. 272 ;; and check that it isn't a paragraph starter.
@@ -333,7 +333,7 @@ be tested. If it returns t, fill commands do not break the line there."
333Can be customized with the variables `fill-nobreak-predicate' 333Can be customized with the variables `fill-nobreak-predicate'
334and `fill-nobreak-invisible'." 334and `fill-nobreak-invisible'."
335 (or 335 (or
336 (and fill-nobreak-invisible (line-move-invisible (point))) 336 (and fill-nobreak-invisible (line-move-invisible-p (point)))
337 (unless (bolp) 337 (unless (bolp)
338 (or 338 (or
339 ;; Don't break after a period followed by just one space. 339 ;; Don't break after a period followed by just one space.
@@ -1128,8 +1128,6 @@ otherwise it is made canonical."
1128 ncols ; new indent point or offset 1128 ncols ; new indent point or offset
1129 (nspaces 0) ; number of spaces between words 1129 (nspaces 0) ; number of spaces between words
1130 ; in line (not space characters) 1130 ; in line (not space characters)
1131 fracspace ; fractional amount of space to be
1132 ; added between each words
1133 (curr-fracspace 0) ; current fractional space amount 1131 (curr-fracspace 0) ; current fractional space amount
1134 count) 1132 count)
1135 (end-of-line) 1133 (end-of-line)
@@ -1338,7 +1336,7 @@ Also, if CITATION-REGEXP is non-nil, don't fill header lines."
1338 (forward-line 1)))) 1336 (forward-line 1))))
1339 (narrow-to-region (point) max) 1337 (narrow-to-region (point) max)
1340 ;; Loop over paragraphs. 1338 ;; Loop over paragraphs.
1341 (while (let ((here (point))) 1339 (while (progn
1342 ;; Skip over all paragraph-separating lines 1340 ;; Skip over all paragraph-separating lines
1343 ;; so as to not include them in any paragraph. 1341 ;; so as to not include them in any paragraph.
1344 (while (and (not (eobp)) 1342 (while (and (not (eobp))
@@ -1446,5 +1444,5 @@ Also, if CITATION-REGEXP is non-nil, don't fill header lines."
1446 "") 1444 "")
1447 string)) 1445 string))
1448 1446
1449;;; arch-tag: 727ad455-1161-4fa9-8df5-0f74b179216d 1447;; arch-tag: 727ad455-1161-4fa9-8df5-0f74b179216d
1450;;; fill.el ends here 1448;;; fill.el ends here