Mercurial > emacs
annotate lisp/gnus/flow-fill.el @ 112438:11f1b4757236
* image.c (x_create_bitmap_from_xpm_data): Add cast to fix type clash
when calling XpmCreatePixmapFromData.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 22 Jan 2011 20:33:12 -0800 |
parents | 27320025ed54 |
children |
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 | 2 |
112284
61f7601898b1
Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents:
112228
diff
changeset
|
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
61f7601898b1
Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents:
112228
diff
changeset
|
4 ;; 2009, 2010, 2011 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Simon Josefsson <jas@pdc.kth.se> | |
7 ;; Keywords: mail | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
31717 | 12 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
31717 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
31717 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; This implement decoding of RFC2646 formatted text, including the | |
27 ;; quoted-depth wins rules. | |
28 | |
29 ;; Theory of operation: search for lines ending with SPC, save quote | |
30 ;; length of line, remove SPC and concatenate line with the following | |
31 ;; line if quote length of following line matches current line. | |
32 | |
33 ;; When no further concatenations are possible, we've found a | |
34 ;; paragraph and we let `fill-region' fill the long line into several | |
35 ;; lines with the quote prefix as `fill-prefix'. | |
36 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
37 ;; Todo: implement basic `fill-region' (Emacs and XEmacs |
32923 | 38 ;; implementations differ..) |
31717 | 39 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
40 ;;; History: |
31717 | 41 |
42 ;; 2000-02-17 posted on ding mailing list | |
43 ;; 2000-02-19 use `point-at-{b,e}ol' in XEmacs | |
44 ;; 2000-03-11 no compile warnings for point-at-bol stuff | |
48588 | 45 ;; 2000-03-26 committed to gnus cvs |
32923 | 46 ;; 2000-10-23 don't flow "-- " lines, make "quote-depth wins" rule |
47 ;; 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
|
48 ;; 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
|
49 ;; 2003-12-08 started working on test harness. |
31717 | 50 |
51 ;;; Code: | |
52 | |
32923 | 53 (eval-when-compile (require 'cl)) |
54 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
55 (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
|
56 "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
|
57 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
|
58 :version "22.1" |
57015
6d1f39d4f8e6
* nntp.el (nntp): New customization group.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
56927
diff
changeset
|
59 :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
|
60 :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
|
61 (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
|
62 (sexp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
63 (integer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
64 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
65 (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
|
66 "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
|
67 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
|
68 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
|
69 :version "22.1" |
57015
6d1f39d4f8e6
* nntp.el (nntp): New customization group.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
56927
diff
changeset
|
70 :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
|
71 :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
|
72 (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
|
73 (sexp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
74 (integer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
75 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
76 ;;;###autoload |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
77 (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
|
78 (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
|
79 ;; 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
|
80 (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
|
81 (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
|
82 ;; 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
|
83 ;; 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
|
84 (while (setq end (text-property-any start (point-max) 'hard 't)) |
112108
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
85 (save-restriction |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
86 (narrow-to-region start end) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
87 (let ((fill-column (eval fill-flowed-encode-column))) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
88 (fill-flowed-fill-buffer)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
89 (goto-char (point-min)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
90 (while (re-search-forward "\n" nil t) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
91 (replace-match " \n" t t)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
92 (goto-char (setq start (1+ (point-max))))))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
93 t))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
94 |
112108
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
95 (defun fill-flowed-fill-buffer () |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
96 (let ((prefix nil) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
97 (prev-prefix nil) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
98 (start (point-min))) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
99 (goto-char (point-min)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
100 (while (not (eobp)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
101 (setq prefix (and (looking-at "[> ]+") |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
102 (match-string 0))) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
103 (if (equal prefix prev-prefix) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
104 (forward-line 1) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
105 (save-restriction |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
106 (narrow-to-region start (point)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
107 (let ((fill-prefix prev-prefix)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
108 (fill-region (point-min) (point-max) t 'nosqueeze 'to-eop)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
109 (goto-char (point-max))) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
110 (setq prev-prefix prefix |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
111 start (point)))) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
112 (save-restriction |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
113 (narrow-to-region start (point)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
114 (let ((fill-prefix prev-prefix)) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
115 (fill-region (point-min) (point-max) t 'nosqueeze 'to-eop))))) |
c24551a0cd95
flow-fill.el (fill-flowed-encode): Do encoding citation-aware.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
116 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
117 ;;;###autoload |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
118 (defun fill-flowed (&optional buffer delete-space) |
110410
f2e111723c3a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110102
diff
changeset
|
119 (with-current-buffer (or (current-buffer) buffer) |
31717 | 120 (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
|
121 ;; Remove space stuffing. |
70044
027c07dcdee5
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-225
Miles Bader <miles@gnu.org>
parents:
69195
diff
changeset
|
122 (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
|
123 (delete-char -1) |
12d289b6e5de
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
124 (forward-line 1)) |
12d289b6e5de
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
125 (goto-char (point-min)) |
31717 | 126 (while (re-search-forward " $" nil t) |
127 (when (save-excursion | |
128 (beginning-of-line) | |
69195
477ba8c8d22c
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-126
Miles Bader <miles@gnu.org>
parents:
69135
diff
changeset
|
129 (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
|
130 (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
|
131 sig) |
31717 | 132 (if (string= quote "") |
133 (setq quote nil)) | |
134 (when (and quote (string= (match-string 2) "")) | |
135 (save-excursion | |
136 ;; insert SP after quote for pleasant reading of quoted lines | |
137 (beginning-of-line) | |
138 (when (> (skip-chars-forward ">") 0) | |
139 (insert " ")))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
140 ;; XXX slightly buggy handling of "-- " |
31717 | 141 (while (and (save-excursion |
32923 | 142 (ignore-errors (backward-char 3)) |
143 (setq sig (looking-at "-- ")) | |
31717 | 144 (looking-at "[^-][^-] ")) |
145 (save-excursion | |
146 (unless (eobp) | |
147 (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
|
148 (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
|
149 (or quote " ?")))))) |
31717 | 150 (save-excursion |
151 (replace-match (if (string= (match-string 2) " ") | |
152 "" "\\2"))) | |
153 (backward-delete-char -1) | |
112432
27320025ed54
Merge chages made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
112284
diff
changeset
|
154 (when delete-space |
27320025ed54
Merge chages made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
112284
diff
changeset
|
155 (delete-char -1)) |
31717 | 156 (end-of-line)) |
32923 | 157 (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
|
158 (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
|
159 (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
|
160 (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
|
161 filladapt-mode |
12d289b6e5de
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
162 adaptive-fill-mode) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
163 (fill-region (point-at-bol) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
164 (min (1+ (point-at-eol)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
165 (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
166 'left 'nosqueeze)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
167 (error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
168 (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
|
169 nil)))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
170 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
171 ;; Test vectors. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
172 |
86154 | 173 (defvar show-trailing-whitespace) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
174 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
175 (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
|
176 `( |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
177 ;; 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
|
178 ;; (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
|
179 (,(concat |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
180 "> 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
|
181 "> 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
|
182 ">> 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
|
183 ">> 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
|
184 ">>> 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
|
185 ">>> 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
|
186 ">>>> 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
|
187 ">>>> 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
|
188 ">>>>> 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
|
189 ">>>>> 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
|
190 ">>>>>> Any complaints?") |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
191 . |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
192 ,(concat |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
193 "> 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
|
194 "> 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
|
195 ">> 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
|
196 ">> scut!\n" |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
197 ">>> 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
|
198 ">>>> 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
|
199 ">>>> 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
|
200 ">>>>> 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
|
201 ">>>>>> 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
|
202 )) |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
203 ;; (,(concat |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
204 ;; "\n" |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
205 ;; "> foo\n" |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
206 ;; "> \n" |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
207 ;; "> \n" |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
208 ;; "> bar\n") |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
209 ;; . |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
210 ;; ,(concat |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
211 ;; "\n" |
e65b759c6906
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
212 ;; "> 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
|
213 )) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
214 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
215 (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
|
216 (interactive "") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
217 (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
|
218 (erase-buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
219 (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
|
220 (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
|
221 (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
|
222 (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
|
223 (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
|
224 (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
|
225 (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
|
226 (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
|
227 (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
|
228 (save-restriction |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
229 (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
|
230 (fill-flowed)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
231 (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
|
232 (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
|
233 (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
|
234 (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
|
235 (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
|
236 (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
|
237 (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
|
238 (goto-char (point-max))) |
31717 | 239 |
240 (provide 'flow-fill) | |
241 | |
242 ;;; flow-fill.el ends here |