annotate lisp/packages/filladapt.el @ 211:78478c60bfcd r20-4b4

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