annotate lisp/gnus/flow-fill.el @ 76033:471d2cef4c42

Unjustify.
author Glenn Morris <rgm@gnu.org>
date Tue, 20 Feb 2007 04:02:18 +0000
parents e3694f1cb928
children 24202b793a08 95d0cdf160ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
57243
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 57153
diff changeset
1 ;;; flow-fill.el --- interpret RFC2646 "flowed" text
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 70044
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Simon Josefsson <jas@pdc.kth.se>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Keywords: mail
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 59996
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 59996
diff changeset
24 ;; Boston, MA 02110-1301, USA.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; This implement decoding of RFC2646 formatted text, including the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; quoted-depth wins rules.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; Theory of operation: search for lines ending with SPC, save quote
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; length of line, remove SPC and concatenate line with the following
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; line if quote length of following line matches current line.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; When no further concatenations are possible, we've found a
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; paragraph and we let `fill-region' fill the long line into several
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; lines with the quote prefix as `fill-prefix'.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
39 ;; Todo: implement basic `fill-region' (Emacs and XEmacs
32923
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
40 ;; implementations differ..)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
42 ;;; History:
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; 2000-02-17 posted on ding mailing list
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; 2000-02-19 use `point-at-{b,e}ol' in XEmacs
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; 2000-03-11 no compile warnings for point-at-bol stuff
48588
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 32923
diff changeset
47 ;; 2000-03-26 committed to gnus cvs
32923
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
48 ;; 2000-10-23 don't flow "-- " lines, make "quote-depth wins" rule
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
49 ;; work when first line is at level 0.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
50 ;; 2002-01-12 probably incomplete encoding support
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
51 ;; 2003-12-08 started working on test harness.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
32923
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
55 (eval-when-compile (require 'cl))
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
56
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
57 (defcustom fill-flowed-display-column 'fill-column
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
58 "Column beyond which format=flowed lines are wrapped, when displayed.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
59 This can be a Lisp expression or an integer."
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 57243
diff changeset
60 :version "22.1"
57015
6d1f39d4f8e6 * nntp.el (nntp): New customization group.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 56927
diff changeset
61 :group 'mime-display
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
62 :type '(choice (const :tag "Standard `fill-column'" fill-column)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
63 (const :tag "Fit Window" (- (window-width) 5))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
64 (sexp)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
65 (integer)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
66
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
67 (defcustom fill-flowed-encode-column 66
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
68 "Column beyond which format=flowed lines are wrapped, in outgoing messages.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
69 This can be a Lisp expression or an integer.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
70 RFC 2646 suggests 66 characters for readability."
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 57243
diff changeset
71 :version "22.1"
57015
6d1f39d4f8e6 * nntp.el (nntp): New customization group.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 56927
diff changeset
72 :group 'mime-display
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
73 :type '(choice (const :tag "Standard fill-column" fill-column)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
74 (const :tag "RFC 2646 default (66)" 66)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
75 (sexp)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
76 (integer)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
77
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 (defalias 'fill-flowed-point-at-bol
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (if (fboundp 'point-at-bol)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 'point-at-bol
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 'line-beginning-position))
32923
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
83
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
84 (defalias 'fill-flowed-point-at-eol
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (if (fboundp 'point-at-eol)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 'point-at-eol
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 'line-end-position)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
89 ;;;###autoload
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
90 (defun fill-flowed-encode (&optional buffer)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
91 (with-current-buffer (or buffer (current-buffer))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
92 ;; No point in doing this unless hard newlines is used.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
93 (when use-hard-newlines
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
94 (let ((start (point-min)) end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
95 ;; Go through each paragraph, filling it and adding SPC
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
96 ;; as the last character on each line.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
97 (while (setq end (text-property-any start (point-max) 'hard 't))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
98 (let ((fill-column (eval fill-flowed-encode-column)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
99 (fill-region start end t 'nosqueeze 'to-eop))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
100 (goto-char start)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
101 ;; `fill-region' probably distorted end.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
102 (setq end (text-property-any start (point-max) 'hard 't))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
103 (while (and (< (point) end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
104 (re-search-forward "$" (1- end) t))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
105 (insert " ")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
106 (setq end (1+ end))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
107 (forward-char))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
108 (goto-char (setq start (1+ end)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
109 t)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
110
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
111 ;;;###autoload
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (defun fill-flowed (&optional buffer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (set-buffer (or (current-buffer) buffer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 (goto-char (point-min))
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
116 ;; Remove space stuffing.
70044
027c07dcdee5 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-225
Miles Bader <miles@gnu.org>
parents: 69195
diff changeset
117 (while (re-search-forward "^\\( \\|>+ $\\)" nil t)
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
118 (delete-char -1)
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
119 (forward-line 1))
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
120 (goto-char (point-min))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (while (re-search-forward " $" nil t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (when (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (beginning-of-line)
69195
477ba8c8d22c Revision: emacs@sv.gnu.org/emacs--devo--0--patch-126
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
124 (looking-at "^\\(>*\\)\\( ?\\)"))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
125 (let ((quote (match-string 1))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
126 sig)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (if (string= quote "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (setq quote nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (when (and quote (string= (match-string 2) ""))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 ;; insert SP after quote for pleasant reading of quoted lines
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (beginning-of-line)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (when (> (skip-chars-forward ">") 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (insert " "))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
135 ;; XXX slightly buggy handling of "-- "
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (while (and (save-excursion
32923
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
137 (ignore-errors (backward-char 3))
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
138 (setq sig (looking-at "-- "))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (looking-at "[^-][^-] "))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (unless (eobp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (forward-char 1)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
143 (looking-at (format "^\\(%s\\)\\([^>\n\r]\\)"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
144 (or quote " ?"))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (replace-match (if (string= (match-string 2) " ")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 "" "\\2")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (backward-delete-char -1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 (end-of-line))
32923
6d074bbd2bbb 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
150 (unless sig
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
151 (condition-case nil
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
152 (let ((fill-prefix (when quote (concat quote " ")))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
153 (fill-column (eval fill-flowed-display-column))
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
154 filladapt-mode
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
155 adaptive-fill-mode)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
156 (fill-region (fill-flowed-point-at-bol)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
157 (min (1+ (fill-flowed-point-at-eol))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
158 (point-max))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
159 'left 'nosqueeze))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
160 (error
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
161 (forward-line 1)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
162 nil))))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
163
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
164 ;; Test vectors.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
165
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
166 (eval-when-compile
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
167 (defvar show-trailing-whitespace))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
168
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
169 (defvar fill-flowed-encode-tests
66573
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
170 `(
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
171 ;; The syntax of each list element is:
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
172 ;; (INPUT . EXPECTED-OUTPUT)
66573
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
173 (,(concat
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
174 "> Thou villainous ill-breeding spongy dizzy-eyed \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
175 "> reeky elf-skinned pigeon-egg! \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
176 ">> Thou artless swag-bellied milk-livered \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
177 ">> dismal-dreaming idle-headed scut!\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
178 ">>> Thou errant folly-fallen spleeny reeling-ripe \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
179 ">>> unmuzzled ratsbane!\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
180 ">>>> Henceforth, the coding style is to be strictly \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
181 ">>>> enforced, including the use of only upper case.\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
182 ">>>>> I've noticed a lack of adherence to the coding \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
183 ">>>>> styles, of late.\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
184 ">>>>>> Any complaints?")
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
185 .
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
186 ,(concat
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
187 "> Thou villainous ill-breeding spongy dizzy-eyed reeky elf-skinned\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
188 "> pigeon-egg! \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
189 ">> Thou artless swag-bellied milk-livered dismal-dreaming idle-headed\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
190 ">> scut!\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
191 ">>> Thou errant folly-fallen spleeny reeling-ripe unmuzzled ratsbane!\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
192 ">>>> Henceforth, the coding style is to be strictly enforced,\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
193 ">>>> including the use of only upper case.\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
194 ">>>>> I've noticed a lack of adherence to the coding styles, of late.\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
195 ">>>>>> Any complaints?\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
196 ))
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
197 ;; (,(concat
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
198 ;; "\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
199 ;; "> foo\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
200 ;; "> \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
201 ;; "> \n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
202 ;; "> bar\n")
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
203 ;; .
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
204 ;; ,(concat
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
205 ;; "\n"
e65b759c6906 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
206 ;; "> foo bar\n"))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
207 ))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
208
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
209 (defun fill-flowed-test ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
210 (interactive "")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
211 (switch-to-buffer (get-buffer-create "*Format=Flowed test output*"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
212 (erase-buffer)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
213 (setq show-trailing-whitespace t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
214 (dolist (test fill-flowed-encode-tests)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
215 (let (start output)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
216 (insert "***** BEGIN TEST INPUT *****\n")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
217 (insert (car test))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
218 (insert "***** END TEST INPUT *****\n\n")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
219 (insert "***** BEGIN TEST OUTPUT *****\n")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
220 (setq start (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
221 (insert (car test))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
222 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
223 (narrow-to-region start (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
224 (fill-flowed))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
225 (setq output (buffer-substring start (point-max)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
226 (insert "***** END TEST OUTPUT *****\n")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
227 (unless (string= output (cdr test))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
228 (insert "\n***** BEGIN TEST EXPECTED OUTPUT *****\n")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
229 (insert (cdr test))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
230 (insert "***** END TEST EXPECTED OUTPUT *****\n"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
231 (insert "\n\n")))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
232 (goto-char (point-max)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (provide 'flow-fill)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48588
diff changeset
236 ;;; arch-tag: addc0040-bc53-4f17-b4bc-1eb44eed6f0b
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 ;;; flow-fill.el ends here