annotate lisp/packages/filladapt.el @ 120:cca96a509cfe r20-1b12

Import from CVS: tag r20-1b12
author cvs
date Mon, 13 Aug 2007 09:25:29 +0200
parents 360340f9fd5f
children 1856695b1fa9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
1 ;;; Adaptive fill
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
2 ;;; Copyright (C) 1989, 1995, 1996, 1997 Kyle E. Jones
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; A copy of the GNU General Public License can be obtained from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; program's author (send electronic mail to kyle@uunet.uu.net) or from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
19 ;;; Send bug reports to kyle_jones@wonderworks.com
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; filladapt|Kyle Jones|kyle_jones@wonderworks.com|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Minor mode to adaptively set fill-prefix and overload filling functions|
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
24 ;; 10-June-1996|2.10|~/packages/filladapt.el|
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; These functions enhance the default behavior of Emacs' Auto Fill
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
27 ;; mode and the commands fill-paragraph, lisp-fill-paragraph,
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
28 ;; fill-region-as-paragraph and fill-region.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; The chief improvement is that the beginning of a line to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; filled is examined and, based on information gathered, an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; appropriate value for fill-prefix is constructed. Also the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; boundaries of the current paragraph are located. This occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; only if the fill prefix is not already non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; The net result of this is that blurbs of text that are offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; from left margin by asterisks, dashes, and/or spaces, numbered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; examples, included text from USENET news articles, etc. are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; generally filled correctly with no fuss.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Since this package replaces existing Emacs functions, it cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; be autoloaded. Save this in a file named filladapt.el in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Lisp directory that Emacs knows about, byte-compile it and put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; (require 'filladapt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; in your .emacs file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; Note that in this release Filladapt mode is a minor mode and it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; _off_ by default. If you want it to be on by default, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; (setq-default filladapt-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; M-x filladapt-mode toggles Filladapt mode on/off in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; (add-hook 'text-mode-hook 'turn-on-filladapt-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; to have Filladapt always enabled in Text mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; to have Filladapt always disabled in C mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; In many cases, you can extend Filladapt by adding appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; entries to the following three `defvar's. See `postscript-comment'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; or `texinfo-comment' as a sample of what needs to be done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; filladapt-token-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; filladapt-token-match-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; filladapt-token-conversion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
70 (and (featurep 'filladapt)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
71 (error "filladapt cannot be loaded twice in the same Emacs session."))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
72
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (provide 'filladapt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
75 ;; BLOB to make custom stuff work even without customize
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
76 (eval-and-compile
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
77 (condition-case ()
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
78 (require 'custom)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
79 (error nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
80 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
81 nil ;; We've got what we needed
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
82 ;; We have the old custom-library, hack around it!
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
83 (defmacro defgroup (&rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
84 nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
85 (defmacro defcustom (var value doc &rest args)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
86 (` (defvar (, var) (, value) (, doc))))))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
87
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
88 (defgroup filladapt nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
89 "Enhanced filling"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
90 :group 'editing)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
91
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
92 (defvar filladapt-version "2.10"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Version string for filladapt.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
95 (defcustom filladapt-mode nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "*Non-nil means that Filladapt minor mode is enabled.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
97 Use the filladapt-mode command to toggle the mode on/off."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
98 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
99 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (make-variable-buffer-local 'filladapt-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
102 (defcustom filladapt-mode-line-string " Filladapt"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "*String to display in the modeline when Filladapt mode is active.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
104 Set this to nil if you don't want a modeline indicator for Filladapt."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
105 :type 'string
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
106 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
108 (defcustom filladapt-fill-column-tolerance nil
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
109 "*Tolerate filled paragraph lines ending this far from the fill column.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
110 If any lines other than the last paragraph line end at a column
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
111 less than fill-column - filladapt-fill-column-tolerance, fill-column will
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
112 be adjusted using the filladapt-fill-column-*-fuzz variables and
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
113 the paragraph will be re-filled until the tolerance is achieved
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
114 or filladapt runs out of fuzz values to try.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
115
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
116 A nil value means behave normally, that is, don't try refilling
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
117 paragraphs to make filled line lengths fit within any particular
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
118 range."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
119 :type '(choice (const nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
120 integer)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
121 :group 'filladapt)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
122
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
123 (defcustom filladapt-fill-column-forward-fuzz 5
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
124 "*Try values from fill-column to fill-column plus this variable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
125 when trying to make filled paragraph lines fall with the tolerance
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
126 range specified by filladapt-fill-column-tolerance."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
127 :type 'integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
128 :group 'filladapt)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
129
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
130 (defcustom filladapt-fill-column-backward-fuzz 5
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
131 "*Try values from fill-column to fill-column minus this variable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
132 when trying to make filled paragraph lines fall with the tolerance
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
133 range specified by filladapt-fill-column-tolerance."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
134 :type 'integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
135 :group 'filladapt)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
136
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; install on minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (or (assq 'filladapt-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq minor-mode-alist (cons (list 'filladapt-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 'filladapt-mode-line-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
143 (defcustom filladapt-token-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 '(
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
145 ;; this must be first
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
146 ("^" beginning-of-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; Included text in news or mail replies
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
148 (">+" citation->)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; Included text generated by SUPERCITE. We can't hope to match all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; the possible variations, your mileage may vary.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
151 ("[A-Za-z0-9][^'`\"< \t\n]*>[ \t]*" supercite-citation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; Lisp comments
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
153 (";+" lisp-comment)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; UNIX shell comments
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
155 ("#+" sh-comment)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; Postscript comments
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
157 ("%+" postscript-comment)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; C++ comments
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
159 ("///*" c++-comment)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; Texinfo comments
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
161 ("@c[ \t]" texinfo-comment)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
162 ("@comment[ \t]" texinfo-comment)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; Bullet types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
165 ;; LaTex \item
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
166 ;;
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
167 ("\\\\item[ \t]" bullet)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
168 ;;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; 1. xxxxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; xxxxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
172 ("[0-9]+\\.[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; 2.1.3 xxxxx xx x xx x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; xxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
177 ("[0-9]+\\(\\.[0-9]+\\)+[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; a. xxxxxx xx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; xxx xxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
182 ("[A-Za-z]\\.[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; 1) xxxx x xx x xx or (1) xx xx x x xx xx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; xx xx xxxx xxx xx x x xx x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
187 ("(?[0-9]+)[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; a) xxxx x xx x xx or (a) xx xx x x xx xx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; xx xx xxxx xxx xx x x xx x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
192 ("(?[A-Za-z])[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; 2a. xx x xxx x x xxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; xxx xx x xx x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
197 ("[0-9]+[A-Za-z]\\.[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; 1a) xxxx x xx x xx or (1a) xx xx x x xx xx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; xx xx xxxx xxx xx x x xx x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
202 ("(?[0-9]+[A-Za-z])[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; - xx xxx xxxx or * xx xx x xxx xxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; xxx xx xx x xxx x xx x x x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
207 ("[-~*+]+[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; o xx xxx xxxx xx x xx xxx x xxx xx x xxx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; xxx xx xx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
212 ("o[ \t]" bullet)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; don't touch
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
214 ("[ \t]+" space)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
215 ("$" end-of-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "Table of tokens filladapt knows about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Format is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
220 ((REGEXP SYM) ...)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 filladapt uses this table to build a tokenized representation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 the beginning of the current line. Each REGEXP is matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 against the beginning of the line until a match is found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 Matching is done case-sensitively. The corresponding SYM is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 added to the list, point is moved to (match-end 0) and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 process is repeated. The process ends when there is no REGEXP in
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
228 the table that matches what is at point."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
229 :type '(repeat (list regexp symbol))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
230 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
232 (defcustom filladapt-not-token-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "[Ee].g."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "[Ii].e."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; end-of-line isn't a token if whole line is empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "^$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "List of regexps that can never be a token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 Before trying the regular expressions in filladapt-token-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 the regexps in this list are tried. If any regexp in this list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 matches what is at point then the token generator gives up and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 doesn't try any of the regexps in filladapt-token-table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
245 Regexp matching is done case-sensitively."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
246 :type '(repeat regexp)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
247 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
249 (defcustom filladapt-token-match-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (citation-> citation->)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (supercite-citation supercite-citation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (lisp-comment lisp-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (sh-comment sh-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (postscript-comment postscript-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (c++-comment c++-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (texinfo-comment texinfo-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (bullet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (space bullet space)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
260 (beginning-of-line beginning-of-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "Table describing what tokens a certain token will match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 To decide whether a line belongs in the current paragraph,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 filladapt creates a token list for the fill prefix of both lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Tokens and the columns where tokens end are compared. This table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 specifies what a certain token will match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Table format is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (SYM [SYM1 [SYM2 ...]])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 The first symbol SYM is the token, subsequent symbols are the
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
274 tokens that SYM will match."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
275 :type '(repeat (repeat symbol))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
276 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
278 (defcustom filladapt-token-match-many-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "List of tokens that can match multiple tokens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 If one of these tokens appears in a token list, it will eat all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 matching tokens in a token list being matched against it until it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 encounters a token that doesn't match or a token that ends on
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
286 a greater column number."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
287 :type '(repeat symbol)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
288 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
290 (defcustom filladapt-token-paragraph-start-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "List of tokens that indicate the start of a paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 If parsing a line generates a token list containing one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 these tokens, then the line is considered to be the start of a
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
297 paragraph."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
298 :type '(repeat symbol)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
299 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
301 (defcustom filladapt-token-conversion-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (citation-> . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (supercite-citation . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (lisp-comment . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (sh-comment . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (postscript-comment . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (c++-comment . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (texinfo-comment . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (bullet . spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (space . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (end-of-line . exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Table that specifies how to convert a token into a fill prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 Table format is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ((SYM . HOWTO) ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 SYM is the symbol naming the token to be converted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 HOWTO specifies how to do the conversion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 `exact' means copy the token's string directly into the fill prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 `spaces' means convert all characters in the token string that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 not a TAB or a space into spaces and copy the resulting string into
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
324 the fill prefix."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
325 :type '(repeat (cons symbol (choice (const exact)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
326 (const spaces))))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
327 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defvar filladapt-function-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (let ((assoc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (list (cons 'fill-paragraph (symbol-function 'fill-paragraph))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
332 (cons 'fill-region (symbol-function 'fill-region))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (cons 'fill-region-as-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (symbol-function 'fill-region-as-paragraph))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (cons 'do-auto-fill (symbol-function 'do-auto-fill)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; v18 Emacs doesn't have lisp-fill-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (if (fboundp 'lisp-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (nconc assoc-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (list (cons 'lisp-fill-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (symbol-function 'lisp-fill-paragraph)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 assoc-list )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "Table containing the old function definitions that filladapt usurps.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
344 (defcustom filladapt-fill-paragraph-post-hook nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
345 "Hooks run after filladapt runs fill-paragraph."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
346 :type 'hook
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
347 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defvar filladapt-inside-filladapt nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Non-nil if the filladapt version of a fill function executing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 Currently this is only checked by the filladapt version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 fill-region-as-paragraph to avoid this infinite recursion:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 fill-region-as-paragraph -> fill-paragraph -> fill-region-as-paragraph ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
356 (defcustom filladapt-debug nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "Non-nil means filladapt debugging is enabled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 Use the filladapt-debug command to turn on debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 With debugging enabled, filladapt will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 a. display the proposed indentation with the tokens highlighted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 using filladapt-debug-indentation-face-1 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 filladapt-debug-indentation-face-2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 b. display the current paragraph using the face specified by
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
366 filladapt-debug-paragraph-face."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
367 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 108
diff changeset
368 :group 'filladapt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if filladapt-debug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (add-hook 'post-command-hook 'filladapt-display-debug-info-maybe))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defvar filladapt-debug-indentation-face-1 'highlight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "Face used to display the indentation when debugging is enabled.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defvar filladapt-debug-indentation-face-2 'secondary-selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "Another face used to display the indentation when debugging is enabled.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar filladapt-debug-paragraph-face 'bold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Face used to display the current paragraph when debugging is enabled.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defvar filladapt-debug-indentation-extents nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (make-variable-buffer-local 'filladapt-debug-indentation-extents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar filladapt-debug-paragraph-extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (make-variable-buffer-local 'filladapt-debug-paragraph-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; kludge city, see references in code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defvar filladapt-old-line-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun do-auto-fill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (if (and filladapt-mode (null fill-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (let ((paragraph-ignore-fill-prefix nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;; if the user wanted this stuff, they probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; wouldn't be using filladapt-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (adaptive-fill-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (adaptive-fill-regexp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; need this or Emacs 19 ignores fill-prefix when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;; inside a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (comment-multi-line t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (filladapt-inside-filladapt t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 fill-prefix retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (filladapt-adapt nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (setq retval (filladapt-funcall 'do-auto-fill))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (throw 'done retval))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (filladapt-funcall 'do-auto-fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defun filladapt-fill-paragraph (function arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (if (and filladapt-mode (null fill-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (let ((paragraph-ignore-fill-prefix nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; if the user wanted this stuff, they probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; wouldn't be using filladapt-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (adaptive-fill-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (adaptive-fill-regexp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;; need this or Emacs 19 ignores fill-prefix when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; inside a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (comment-multi-line t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 fill-prefix retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (if (filladapt-adapt t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (progn
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
425 (if filladapt-fill-column-tolerance
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
426 (let* ((low (- fill-column
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
427 filladapt-fill-column-backward-fuzz))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
428 (high (+ fill-column
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
429 filladapt-fill-column-forward-fuzz))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
430 (old-fill-column fill-column)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
431 (fill-column fill-column)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
432 (lim (- high low))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
433 (done nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
434 (sign 1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
435 (delta 0))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
436 (while (not done)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
437 (setq retval (filladapt-funcall function arg))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
438 (if (filladapt-paragraph-within-fill-tolerance)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
439 (setq done 'success)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
440 (setq delta (1+ delta)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
441 sign (* sign -1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
442 fill-column (+ fill-column (* delta sign)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
443 (while (and (<= delta lim)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
444 (or (< fill-column low)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
445 (> fill-column high)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
446 (setq delta (1+ delta)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
447 sign (* sign -1)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
448 fill-column (+ fill-column
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
449 (* delta sign))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
450 (setq done (> delta lim))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
451 ;; if the paragraph lines never fell
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
452 ;; within the tolerances, refill using
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
453 ;; the old fill-column.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
454 (if (not (eq done 'success))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
455 (let ((fill-column old-fill-column))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
456 (setq retval (filladapt-funcall function arg)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
457 (setq retval (filladapt-funcall function arg)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (run-hooks 'filladapt-fill-paragraph-post-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (throw 'done retval))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; filladapt-adapt failed, so do fill-paragraph normally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (filladapt-funcall function arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun fill-paragraph (arg)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
464 "Fill paragraph at or after point. Prefix arg means justify as well.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
465
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
466 (This function has been overloaded with the `filladapt' version.)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
467
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
468 If `sentence-end-double-space' is non-nil, then period followed by one
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
469 space does not end a sentence, so don't break a line there.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
470
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
471 If `fill-paragraph-function' is non-nil, we call it (passing our
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
472 argument to it), and if it returns non-nil, we simply return its value."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (interactive "*P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (let ((filladapt-inside-filladapt t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (filladapt-fill-paragraph 'fill-paragraph arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (defun lisp-fill-paragraph (&optional arg)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
478 "Like \\[fill-paragraph], but handle Emacs Lisp comments.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
479
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
480 (This function has been overloaded with the `filladapt' version.)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
481
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
482 If any of the current line is a comment, fill the comment or the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
483 paragraph of it that point is in, preserving the comment's indentation
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
484 and initial semicolons."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (interactive "*P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (let ((filladapt-inside-filladapt t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (filladapt-fill-paragraph 'lisp-fill-paragraph arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
489 (defun fill-region-as-paragraph (beg end &optional justify
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
490 nosqueeze squeeze-after)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
491 "Fill the region as one paragraph.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
492
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
493 (This function has been overloaded with the `filladapt' version.)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
494
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
495 It removes any paragraph breaks in the region and extra newlines at the end,
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
496 indents and fills lines between the margins given by the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
497 `current-left-margin' and `current-fill-column' functions.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
498 It leaves point at the beginning of the line following the paragraph.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
499
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
500 Normally performs justification according to the `current-justification'
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
501 function, but with a prefix arg, does full justification instead.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
502
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
503 From a program, optional third arg JUSTIFY can specify any type of
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
504 justification. Fourth arg NOSQUEEZE non-nil means not to make spaces
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
505 between words canonical before filling. Fifth arg SQUEEZE-AFTER, if non-nil,
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
506 means don't canonicalize spaces before that position.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
507
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
508 If `sentence-end-double-space' is non-nil, then period followed by one
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
509 space does not end a sentence, so don't break a line there."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (interactive "*r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (if (and filladapt-mode (not filladapt-inside-filladapt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (narrow-to-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (let ((filladapt-inside-filladapt t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 line-start last-token)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (goto-char beg)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
517 (while (equal (char-after (point)) ?\n)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
518 (delete-char 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (while (zerop (forward-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (if (setq last-token
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (car (filladapt-tail (filladapt-parse-prefixes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (setq line-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (move-to-column (nth 1 last-token))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (delete-region line-start (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; Dance...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;; Do this instead of (delete-char -1) to keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; markers on the correct side of the whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (goto-char (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (fill-paragraph justify))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; In XEmacs 19.12 and Emacs 18.59 fill-region relies on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; fill-region-as-paragraph to do this. If we don't do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;; it, fill-region will spin in an endless loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;; five args for Emacs 19.31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (filladapt-funcall 'fill-region-as-paragraph beg end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 justify nosqueeze squeeze-after)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (wrong-number-of-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;; four args for Emacs 19.29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (filladapt-funcall 'fill-region-as-paragraph beg end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 justify nosqueeze)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
551 ;; three args for the rest of the world.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
552 (wrong-number-of-arguments
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
553 (filladapt-funcall 'fill-region-as-paragraph beg end justify)))))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
554
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
555 (defun fill-region (beg end &optional justify nosqueeze to-eop)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
556 "Fill each of the paragraphs in the region.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
557
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
558 (This function has been overloaded with the `filladapt' version.)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
559
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
560 Prefix arg (non-nil third arg, if called from program) means justify as well.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
561
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
562 Noninteractively, fourth arg NOSQUEEZE non-nil means to leave
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
563 whitespace other than line breaks untouched, and fifth arg TO-EOP
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
564 non-nil means to keep filling to the end of the paragraph (or next
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
565 hard newline, if `use-hard-newlines' is on).
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
566
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
567 If `sentence-end-double-space' is non-nil, then period followed by one
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
568 space does not end a sentence, so don't break a line there."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
569 (interactive "*r\nP")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
570 (if (and filladapt-mode (not filladapt-inside-filladapt))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
571 (save-restriction
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
572 (narrow-to-region beg end)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
573 (let ((filladapt-inside-filladapt t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
574 start)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
575 (goto-char beg)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
576 (while (not (eobp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
577 (setq start (point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
578 (while (and (not (eobp)) (not (filladapt-parse-prefixes)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
579 (forward-line 1))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
580 (if (not (equal start (point)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
581 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
582 (save-restriction
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
583 (narrow-to-region start (point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
584 (fill-region start (point) justify nosqueeze to-eop)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
585 (goto-char (point-max)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
586 (if (and (not (bolp)) (not (eobp)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
587 (forward-line 1))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
588 (if (filladapt-parse-prefixes)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
589 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
590 (save-restriction
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
591 ;; for the clipping region
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
592 (filladapt-adapt t t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
593 (fill-paragraph justify)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
594 (goto-char (point-max)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
595 (if (and (not (bolp)) (not (eobp)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
596 (forward-line 1)))))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
597 (condition-case nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
598 (filladapt-funcall 'fill-region beg end justify nosqueeze to-eop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (wrong-number-of-arguments
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
600 (condition-case nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
601 (filladapt-funcall 'fill-region beg end justify nosqueeze)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
602 (wrong-number-of-arguments
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
603 (filladapt-funcall 'fill-region beg end justify)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defvar zmacs-region-stays) ; for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (defun filladapt-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 "Toggle Filladapt minor mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 With arg, turn Filladapt mode on iff arg is positive. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 Filladapt mode is enabled, auto-fill-mode and the fill-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 command are both smarter about guessing a proper fill-prefix and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 finding paragraph boundaries when bulleted and indented lines and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 paragraphs are used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;; don't deactivate the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (setq zmacs-region-stays t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (setq filladapt-mode (or (and arg (> (prefix-numeric-value arg) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (and (null arg) (null filladapt-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (if (fboundp 'force-mode-line-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (force-mode-line-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (set-buffer-modified-p (buffer-modified-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defun turn-on-filladapt-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 "Unconditionally turn on Filladapt mode in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (filladapt-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (defun turn-off-filladapt-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 "Unconditionally turn off Filladapt mode in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (filladapt-mode -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (defun filladapt-funcall (function &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 "Call the old definition of a function that filladapt has usurped."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (apply (cdr (assoc function filladapt-function-table)) args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (defun filladapt-paragraph-start (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 "Returns non-nil if LIST contains a paragraph starting token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 LIST should be a token list as returned by filladapt-parse-prefixes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (if (memq (car (car list)) filladapt-token-paragraph-start-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (throw 'done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (setq list (cdr list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (defun filladapt-parse-prefixes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 "Parse all the tokens after point and return a list of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 The tokens regular expressions are specified in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 filladapt-token-table. The list returned is of this form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ((SYM COL STRING) ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 SYM is a token symbol as found in filladapt-token-table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 COL is the column at which the token ended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 STRING is the token's text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (let ((token-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (old-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (case-fold-search nil)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
659 token-table not-token-table moved)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (while (not done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (setq not-token-table filladapt-not-token-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (while not-token-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (looking-at (car not-token-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (throw 'done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (setq not-token-table (cdr not-token-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (setq token-table filladapt-token-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 done t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (while token-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (if (null (looking-at (car (car token-table))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (setq token-table (cdr token-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (goto-char (match-end 0))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
673 (setq token-list (cons (list (nth 1 (car token-table))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 token-list)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
679 moved (not (eq (point) old-point))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
680 token-table (if moved nil (cdr token-table))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
681 done (not moved)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 old-point (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (nreverse token-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defun filladapt-tokens-match-p (list1 list2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 "Compare two token lists and return non-nil if they match, nil otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 The lists are walked through in lockstep, comparing tokens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 When two tokens A and B are compared, they are considered to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 match if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 1. A appears in B's list of matching tokens or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 B appears in A's list of matching tokens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 2. A and B both end at the same column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 A can match multiple tokens and ends at a column > than B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 B can match multiple tokens and ends at a column > than A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 In the case where the end columns differ the list pointer for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 token with the greater end column is not moved forward, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 allows its current token to be matched against the next token in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 the other list in the next iteration of the matching loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 All tokens must be matched in order for the lists to be considered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 matching."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (let ((matched t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (while (and (not done) list1 list2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (let* ((token1 (car (car list1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (token1-matches-many-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (memq token1 filladapt-token-match-many-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (token1-matches (cdr (assq token1 filladapt-token-match-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (token1-endcol (nth 1 (car list1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (token2 (car (car list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (token2-matches-many-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (memq token2 filladapt-token-match-many-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (token2-matches (cdr (assq token2 filladapt-token-match-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (token2-endcol (nth 1 (car list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (tokens-match (or (memq token1 token2-matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (memq token2 token1-matches))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (cond ((not tokens-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (setq matched nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ((and token1-matches-many-p token2-matches-many-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (cond ((= token1-endcol token2-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (setq list1 (cdr list1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 list2 (cdr list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ((< token1-endcol token2-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (setq list1 (cdr list1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (setq list2 (cdr list2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (token1-matches-many-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (cond ((= token1-endcol token2-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (setq list1 (cdr list1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 list2 (cdr list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ((< token1-endcol token2-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (setq matched nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (setq list2 (cdr list2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (token2-matches-many-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (cond ((= token1-endcol token2-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (setq list1 (cdr list1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 list2 (cdr list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ((< token2-endcol token1-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (setq matched nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (setq list1 (cdr list1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ((= token1-endcol token2-endcol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (setq list1 (cdr list1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 list2 (cdr list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (setq matched nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 done t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (and matched (null list1) (null list2)) ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (defun filladapt-make-fill-prefix (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 "Build a fill-prefix for a token LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 filladapt-token-conversion-table specifies how this is done."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (let ((prefix-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (conversion-spec nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (setq conversion-spec (cdr (assq (car (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 filladapt-token-conversion-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (cond ((eq conversion-spec 'spaces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (setq prefix-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (filladapt-convert-to-spaces (nth 2 (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 prefix-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ((eq conversion-spec 'exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (setq prefix-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (nth 2 (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 prefix-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (apply (function concat) (nreverse prefix-list)) ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
781 (defun filladapt-paragraph-within-fill-tolerance ()
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
782 (catch 'done
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
783 (save-excursion
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
784 (let ((low (- fill-column filladapt-fill-column-tolerance))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
785 (shortline nil))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
786 (goto-char (point-min))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
787 (while (not (eobp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
788 (if shortline
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
789 (throw 'done nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
790 (end-of-line)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
791 (setq shortline (< (current-column) low))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
792 (forward-line 1)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
793 t ))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
794
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (defun filladapt-convert-to-spaces (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 "Return a copy of STRING, with all non-tabs and non-space changed to spaces."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (space-list '(?\ ?\t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (space ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (lim (length string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (setq string (copy-sequence string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (while (< i lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (if (not (memq (aref string i) space-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (aset string i space))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 string ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (defun filladapt-adapt (paragraph debugging)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 "Set fill-prefix based on the contents of the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 If the first arg PARAGRAPH is non-nil, also set a clipping region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 around the current paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 If the second arg DEBUGGING is non-nil, don't do the kludge that's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 necessary to make certain paragraph fills work properly."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (let ((token-list (filladapt-parse-prefixes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 curr-list done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (if (null token-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (setq fill-prefix (filladapt-make-fill-prefix token-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (if paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (let (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (if (filladapt-paragraph-start token-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (setq done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (while (not done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (cond ((not (= 0 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (setq done t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ((not (filladapt-tokens-match-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 token-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (setq curr-list (filladapt-parse-prefixes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq done t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ((filladapt-paragraph-start curr-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (setq done t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 beg (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (setq done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (while (not done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (cond ((not (= 0 (progn (end-of-line) (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (setq done t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ((not (filladapt-tokens-match-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 token-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (setq curr-list (filladapt-parse-prefixes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (setq done t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ((filladapt-paragraph-start curr-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (setq done t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 end (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (narrow-to-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ;; Multiple spaces after the bullet at the start of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;; a hanging list paragraph get squashed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;; fill-paragraph. We kludge around this by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; replacing the line prefix with the fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; used by the rest of the lines in the paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; fill-paragraph will not alter the fill prefix so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; we win. The post hook restores the old line prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ;; after fill-paragraph has been called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (if (and paragraph (not debugging))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (let (col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (setq col (nth 1 (car (filladapt-tail token-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (move-to-column col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (setq filladapt-old-line-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (buffer-substring (point-min) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (delete-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (insert fill-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (add-hook 'filladapt-fill-paragraph-post-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 'filladapt-cleanup-kludge-at-point-min)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 t ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (defun filladapt-cleanup-kludge-at-point-min ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 "Cleanup the paragraph fill kludge.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 See filladapt-adapt."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (insert filladapt-old-line-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (delete-char (length fill-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (remove-hook 'filladapt-fill-paragraph-post-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 'filladapt-cleanup-kludge-at-point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (defun filladapt-tail (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 "Returns the last cons in LIST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (if (null list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (while (consp (cdr list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 list ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (defun filladapt-delete-extent (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (if (fboundp 'delete-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (delete-extent e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (delete-overlay e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (defun filladapt-make-extent (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (if (fboundp 'make-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (make-extent beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (make-overlay beg end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (defun filladapt-set-extent-endpoints (e beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (if (fboundp 'set-extent-endpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (set-extent-endpoints e beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (move-overlay e beg end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (defun filladapt-set-extent-property (e prop val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (if (fboundp 'set-extent-property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (set-extent-property e prop val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (overlay-put e prop val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (defun filladapt-debug ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 "Toggle filladapt debugging on/off in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (make-local-variable 'filladapt-debug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (setq filladapt-debug (not filladapt-debug))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (if (null filladapt-debug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (mapcar (function (lambda (e) (filladapt-set-extent-endpoints e 1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 filladapt-debug-indentation-extents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (if filladapt-debug-paragraph-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (filladapt-delete-extent filladapt-debug-paragraph-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (setq filladapt-debug-paragraph-extent nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (add-hook 'post-command-hook 'filladapt-display-debug-info-maybe))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (defun filladapt-display-debug-info-maybe ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (cond ((null filladapt-debug) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (fill-prefix nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (if (null filladapt-debug-paragraph-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (let ((e (filladapt-make-extent 1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (filladapt-set-extent-property e 'detachable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (filladapt-set-extent-property e 'evaporate nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (filladapt-set-extent-property e 'face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 filladapt-debug-paragraph-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (setq filladapt-debug-paragraph-extent e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (let ((ei-list filladapt-debug-indentation-extents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (ep filladapt-debug-paragraph-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (face filladapt-debug-indentation-face-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 fill-prefix token-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (if (null (filladapt-adapt t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (filladapt-set-extent-endpoints ep 1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (while ei-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (filladapt-set-extent-endpoints (car ei-list) 1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (setq ei-list (cdr ei-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (filladapt-set-extent-endpoints ep (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (setq token-list (filladapt-parse-prefixes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (message "(%s)" (mapconcat (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (lambda (q) (symbol-name (car q))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 token-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (while token-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (if ei-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (setq e (car ei-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 ei-list (cdr ei-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (setq e (filladapt-make-extent 1 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (filladapt-set-extent-property e 'detachable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (filladapt-set-extent-property e 'evaporate nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (setq filladapt-debug-indentation-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (cons e filladapt-debug-indentation-extents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (filladapt-set-extent-property e 'face face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (filladapt-set-extent-endpoints e (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (move-to-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (nth 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (car token-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (if (eq face filladapt-debug-indentation-face-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (setq face filladapt-debug-indentation-face-2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (setq face filladapt-debug-indentation-face-1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (setq token-list (cdr token-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (while ei-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (filladapt-set-extent-endpoints (car ei-list) 1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (setq ei-list (cdr ei-list))))))))))