0
|
1 ;;; enriched.el --- read and save files in text/enriched format
|
|
2 ;; Copyright (c) 1994, 1995 Free Software Foundation, Inc.
|
|
3
|
|
4 ;; XEmacs version: Mike Sperber <sperber@informatik.uni-tuebingen.de>
|
|
5 ;; Original author: Boris Goldowsky <boris@gnu.ai.mit.edu>
|
|
6 ;; Keywords: wp, faces
|
|
7
|
2
|
8 ;; This file is part of XEmacs.
|
0
|
9
|
2
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
0
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
2
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
0
|
20 ;; You should have received a copy of the GNU General Public License
|
2
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
23 ;; 02111-1307, USA.
|
0
|
24
|
2
|
25 ;;; Synched up with: FSF 19.34.
|
0
|
26
|
|
27 ;;; Commentary:
|
|
28 ;;
|
|
29 ;; This file implements reading, editing, and saving files with
|
2
|
30 ;; text-properties such as faces, levels of indentation, and true line
|
|
31 ;; breaks distinguished from newlines just used to fit text into the
|
|
32 ;; window.
|
0
|
33 ;;
|
|
34 ;; The file format used is the MIME text/enriched format, which is a
|
|
35 ;; standard format defined in internet RFC 1563. All standard
|
|
36 ;; annotations are supported.
|
|
37 ;;
|
2
|
38 ;; A separate file, enriched.doc, contains further documentation and
|
|
39 ;; other important information about this code. It also serves as an
|
|
40 ;; example file in text/enriched format. It should be in the etc
|
|
41 ;; directory of your emacs distribution.
|
0
|
42 ;;
|
|
43 ;;; TODO for the XEmacs port:
|
|
44 ;;
|
|
45 ;; Currently XEmacs does not support default-text-properties. The
|
|
46 ;; original enriched.el uses this to set the left-margin,
|
|
47 ;; right-margin, and justification properties to 'front-sticky.
|
|
48 ;; If you know the Right Way to fix this, contact
|
|
49 ;; Mike Sperber <sperber@informatik.uni-tuebingen.de>.
|
|
50
|
|
51 (provide 'enriched)
|
2
|
52 (if window-system (require 'facemenu))
|
0
|
53
|
|
54 ;;;
|
|
55 ;;; Variables controlling the display
|
|
56 ;;;
|
|
57
|
134
|
58 (defgroup enriched nil
|
|
59 "Read and save files in text/enriched format"
|
|
60 :group 'wp)
|
|
61
|
0
|
62
|
134
|
63 (defcustom enriched-verbose t
|
|
64 "*If non-nil, give status messages when reading and writing files."
|
|
65 :type 'boolean
|
|
66 :group 'enriched)
|
|
67
|
|
68 (defcustom enriched-default-right-margin 10
|
0
|
69 "*Default amount of space to leave on the right edge of the screen.
|
|
70 This can be increased inside text by changing the 'right-margin text property.
|
|
71 Measured in character widths. If the screen is narrower than this, it is
|
134
|
72 assumed to be 0."
|
|
73 :type 'integer
|
|
74 :group 'enriched)
|
0
|
75
|
134
|
76 (defcustom enriched-fill-after-visiting t
|
0
|
77 "If t, fills paragraphs when reading in enriched documents.
|
|
78 If nil, only fills when you explicitly request it. If the value is 'ask, then
|
|
79 it will query you whether to fill.
|
|
80 Filling is never done if the current text-width is the same as the value
|
134
|
81 stored in the file."
|
|
82 :type '(choice (const nil) (const t) (const ask))
|
|
83 :group 'enriched)
|
0
|
84
|
|
85 ;;;
|
|
86 ;;; Set up faces & display table
|
|
87 ;;;
|
|
88
|
2
|
89 ;; XEmacs change (Can't cheat, we have variable width fonts)
|
0
|
90 (if (not (find-face 'fixed))
|
|
91 (copy-face 'default 'fixed))
|
|
92
|
|
93 (if (not (find-face 'excerpt))
|
|
94 (copy-face 'italic 'excerpt))
|
|
95
|
|
96 (defconst enriched-display-table (make-display-table))
|
|
97 (aset enriched-display-table ?\f (make-string (1- (frame-width)) ?-))
|
|
98
|
2
|
99 (defconst enriched-par-props '(left-margin right-margin justification)
|
|
100 "Text-properties that usually apply to whole paragraphs.
|
|
101 These are set front-sticky everywhere except at hard newlines.")
|
|
102
|
0
|
103 ;;;
|
|
104 ;;; Variables controlling the file format
|
|
105 ;;; (bidirectional)
|
|
106
|
|
107 (defconst enriched-initial-annotation
|
|
108 (lambda ()
|
|
109 (format "Content-Type: text/enriched\nText-Width: %d\n\n"
|
|
110 (enriched-text-width)))
|
|
111 "What to insert at the start of a text/enriched file.
|
|
112 If this is a string, it is inserted. If it is a list, it should be a lambda
|
|
113 expression, which is evaluated to get the string to insert.")
|
|
114
|
|
115 (defconst enriched-annotation-format "<%s%s>"
|
|
116 "General format of enriched-text annotations.")
|
|
117
|
|
118 (defconst enriched-annotation-regexp "<\\(/\\)?\\([-A-za-z0-9]+\\)>"
|
|
119 "Regular expression matching enriched-text annotations.")
|
|
120
|
|
121 (defconst enriched-translations
|
|
122 '((face (bold-italic "bold" "italic")
|
|
123 (bold "bold")
|
|
124 (italic "italic")
|
|
125 (underline "underline")
|
|
126 (fixed "fixed")
|
|
127 (excerpt "excerpt")
|
|
128 (default )
|
|
129 (nil enriched-encode-other-face))
|
2
|
130 (left-margin (4 "indent"))
|
|
131 (right-margin (4 "indentright"))
|
0
|
132 (justification (none "nofill")
|
|
133 (right "flushright")
|
|
134 (left "flushleft")
|
|
135 (full "flushboth")
|
|
136 (center "center"))
|
|
137 (PARAMETER (t "param")) ; Argument of preceding annotation
|
2
|
138 ;; The following are not part of the standard:
|
0
|
139 (FUNCTION (enriched-decode-foreground "x-color")
|
|
140 (enriched-decode-background "x-bg-color")
|
2
|
141 ;; XEmacs addition
|
0
|
142 (facemenu-make-larger "bigger")
|
|
143 (facemenu-make-smaller "smaller"))
|
|
144 (read-only (t "x-read-only"))
|
2
|
145 (unknown (nil format-annotate-value))
|
|
146 ; (font-size (2 "bigger") ; unimplemented
|
|
147 ; (-2 "smaller"))
|
|
148 )
|
0
|
149 "List of definitions of text/enriched annotations.
|
|
150 See `format-annotate-region' and `format-deannotate-region' for the definition
|
|
151 of this structure.")
|
|
152
|
2
|
153 (defconst enriched-ignore
|
|
154 '(front-sticky rear-nonsticky hard)
|
0
|
155 "Properties that are OK to ignore when saving text/enriched files.
|
|
156 Any property that is neither on this list nor dealt with by
|
|
157 `enriched-translations' will generate a warning.")
|
|
158
|
|
159 ;;; Internal variables
|
|
160
|
|
161 (defvar enriched-mode nil
|
2
|
162 "True if Enriched mode is in use.")
|
0
|
163 (make-variable-buffer-local 'enriched-mode)
|
|
164
|
|
165 (if (not (assq 'enriched-mode minor-mode-alist))
|
|
166 (setq minor-mode-alist
|
|
167 (cons '(enriched-mode " Enriched")
|
|
168 minor-mode-alist)))
|
|
169
|
134
|
170 (defcustom enriched-mode-hook nil
|
2
|
171 "Functions to run when entering Enriched mode.
|
0
|
172 If you set variables in this hook, you should arrange for them to be restored
|
2
|
173 to their old values if you leave Enriched mode. One way to do this is to add
|
134
|
174 them and their old values to `enriched-old-bindings'."
|
|
175 :type 'hook
|
|
176 :group 'enriched)
|
0
|
177
|
|
178 (defvar enriched-old-bindings nil
|
|
179 "Store old variable values that we change when entering mode.
|
|
180 The value is a list of \(VAR VALUE VAR VALUE...).")
|
|
181 (make-variable-buffer-local 'enriched-old-bindings)
|
|
182
|
|
183 (defvar enriched-text-width nil)
|
|
184 (make-variable-buffer-local 'enriched-text-width)
|
|
185
|
|
186 ;;;
|
|
187 ;;; Define the mode
|
|
188 ;;;
|
|
189
|
|
190 ;;;###autoload
|
|
191 (defun enriched-mode (&optional arg)
|
|
192 "Minor mode for editing text/enriched files.
|
|
193 These are files with embedded formatting information in the MIME standard
|
|
194 text/enriched format.
|
2
|
195 Turning the mode on runs `enriched-mode-hook'.
|
0
|
196
|
2
|
197 More information about Enriched mode is available in the file
|
0
|
198 etc/enriched.doc in the Emacs distribution directory.
|
|
199
|
|
200 Commands:
|
|
201
|
|
202 \\<enriched-mode-map>\\{enriched-mode-map}"
|
|
203 (interactive "P")
|
|
204 (let ((mod (buffer-modified-p)))
|
|
205 (cond ((or (<= (prefix-numeric-value arg) 0)
|
|
206 (and enriched-mode (null arg)))
|
|
207 ;; Turn mode off
|
|
208 (setq enriched-mode nil)
|
|
209 (setq buffer-file-format (delq 'text/enriched buffer-file-format))
|
|
210 ;; restore old variable values
|
|
211 (while enriched-old-bindings
|
|
212 (funcall 'set (car enriched-old-bindings)
|
|
213 (car (cdr enriched-old-bindings)))
|
|
214 (setq enriched-old-bindings (cdr (cdr enriched-old-bindings)))))
|
|
215
|
|
216 (enriched-mode nil) ; Mode already on; do nothing.
|
|
217
|
|
218 (t (setq enriched-mode t) ; Turn mode on
|
|
219 (if (not (memq 'text/enriched buffer-file-format))
|
|
220 (setq buffer-file-format
|
|
221 (cons 'text/enriched buffer-file-format)))
|
|
222 ;; Save old variable values before we change them.
|
2
|
223 ;; These will be restored if we exit Enriched mode.
|
0
|
224 (setq enriched-old-bindings
|
2
|
225 ;; XEmacs change
|
|
226 (list ; 'buffer-display-table buffer-display-table
|
|
227 'indent-line-function indent-line-function
|
|
228 'use-hard-newlines use-hard-newlines
|
|
229 'default-text-properties default-text-properties))
|
0
|
230 (make-local-variable 'indent-line-function)
|
|
231 (make-local-variable 'use-hard-newlines)
|
2
|
232 (make-local-variable 'default-text-properties)
|
0
|
233 (setq indent-line-function 'indent-to-left-margin
|
2
|
234 ;; XEmacs change
|
|
235 ;; buffer-display-table enriched-display-table
|
|
236 use-hard-newlines t)
|
|
237 (let ((sticky (plist-get default-text-properties 'front-sticky))
|
|
238 (p enriched-par-props))
|
|
239 (while p
|
|
240 (if (not (memq (car p) sticky))
|
|
241 (setq sticky (cons (car p) sticky)))
|
|
242 (setq p (cdr p)))
|
|
243 (if sticky
|
|
244 (setq default-text-properties
|
|
245 (plist-put default-text-properties
|
|
246 'front-sticky sticky))))
|
|
247 (run-hooks 'enriched-mode-hook)))
|
0
|
248 (set-buffer-modified-p mod)
|
2
|
249 ;; XEmacs change
|
0
|
250 (redraw-modeline)))
|
|
251
|
|
252 ;;;
|
|
253 ;;; Keybindings
|
|
254 ;;;
|
|
255
|
|
256 (defvar enriched-mode-map nil
|
2
|
257 "Keymap for Enriched mode.")
|
0
|
258
|
|
259 (if (null enriched-mode-map)
|
|
260 (fset 'enriched-mode-map (setq enriched-mode-map (make-sparse-keymap))))
|
|
261
|
|
262 (if (not (assq 'enriched-mode minor-mode-map-alist))
|
|
263 (setq minor-mode-map-alist
|
|
264 (cons (cons 'enriched-mode enriched-mode-map)
|
|
265 minor-mode-map-alist)))
|
|
266
|
|
267 (define-key enriched-mode-map "\C-a" 'beginning-of-line-text)
|
|
268 (define-key enriched-mode-map "\C-m" 'reindent-then-newline-and-indent)
|
|
269 (define-key enriched-mode-map "\C-j" 'reindent-then-newline-and-indent)
|
|
270 (define-key enriched-mode-map "\M-j" 'facemenu-justification-menu)
|
|
271 (define-key enriched-mode-map "\M-S" 'set-justification-center)
|
|
272 (define-key enriched-mode-map "\C-x\t" 'increase-left-margin)
|
|
273 (define-key enriched-mode-map "\C-c\C-l" 'set-left-margin)
|
|
274 (define-key enriched-mode-map "\C-c\C-r" 'set-right-margin)
|
|
275
|
|
276 ;;;
|
|
277 ;;; Some functions dealing with text-properties, especially indentation
|
|
278 ;;;
|
|
279
|
|
280 (defun enriched-map-property-regions (prop func &optional from to)
|
|
281 "Apply a function to regions of the buffer based on a text property.
|
|
282 For each contiguous region of the buffer for which the value of PROPERTY is
|
|
283 eq, the FUNCTION will be called. Optional arguments FROM and TO specify the
|
|
284 region over which to scan.
|
|
285
|
|
286 The specified function receives three arguments: the VALUE of the property in
|
|
287 the region, and the START and END of each region."
|
|
288 (save-excursion
|
|
289 (save-restriction
|
|
290 (if to (narrow-to-region (point-min) to))
|
|
291 (goto-char (or from (point-min)))
|
|
292 (let ((begin (point))
|
|
293 end
|
|
294 (marker (make-marker))
|
|
295 (val (get-text-property (point) prop)))
|
|
296 (while (setq end (text-property-not-all begin (point-max) prop val))
|
|
297 (move-marker marker end)
|
|
298 (funcall func val begin (marker-position marker))
|
|
299 (setq begin (marker-position marker)
|
|
300 val (get-text-property marker prop)))
|
|
301 (if (< begin (point-max))
|
|
302 (funcall func val begin (point-max)))))))
|
|
303
|
|
304 (put 'enriched-map-property-regions 'lisp-indent-hook 1)
|
|
305
|
|
306 (defun enriched-insert-indentation (&optional from to)
|
|
307 "Indent and justify each line in the region."
|
|
308 (save-excursion
|
|
309 (save-restriction
|
|
310 (if to (narrow-to-region (point-min) to))
|
|
311 (goto-char (or from (point-min)))
|
|
312 (if (not (bolp)) (forward-line 1))
|
|
313 (while (not (eobp))
|
|
314 (if (eolp)
|
|
315 nil ; skip blank lines
|
|
316 (indent-to (current-left-margin))
|
|
317 (justify-current-line t nil t))
|
|
318 (forward-line 1)))))
|
|
319
|
|
320 (defun enriched-text-width ()
|
|
321 "The width of unindented text in this window, in characters.
|
|
322 This is the width of the window minus `enriched-default-right-margin'."
|
|
323 (or enriched-text-width
|
|
324 (let ((ww (window-width)))
|
|
325 (setq enriched-text-width
|
|
326 (if (> ww enriched-default-right-margin)
|
|
327 (- ww enriched-default-right-margin)
|
|
328 ww)))))
|
|
329
|
|
330 ;;;
|
|
331 ;;; Encoding Files
|
|
332 ;;;
|
|
333
|
|
334 ;;;###autoload
|
|
335 (defun enriched-encode (from to)
|
|
336 (if enriched-verbose (message "Enriched: encoding document..."))
|
|
337 (save-restriction
|
|
338 (narrow-to-region from to)
|
|
339 (delete-to-left-margin)
|
|
340 (unjustify-region)
|
|
341 (goto-char from)
|
|
342 (format-replace-strings '(("<" . "<<")))
|
|
343 (format-insert-annotations
|
|
344 (format-annotate-region from (point-max) enriched-translations
|
|
345 'enriched-make-annotation enriched-ignore))
|
|
346 (goto-char from)
|
|
347 (insert (if (stringp enriched-initial-annotation)
|
|
348 enriched-initial-annotation
|
|
349 (funcall enriched-initial-annotation)))
|
|
350 (enriched-map-property-regions 'hard
|
|
351 (lambda (v b e)
|
|
352 (if (and v (= ?\n (char-after b)))
|
|
353 (progn (goto-char b) (insert "\n"))))
|
|
354 (point) nil)
|
|
355 (if enriched-verbose (message nil))
|
|
356 ;; Return new end.
|
|
357 (point-max)))
|
|
358
|
|
359 (defun enriched-make-annotation (name positive)
|
|
360 "Format an annotation called NAME.
|
|
361 If POSITIVE is non-nil, this is the opening annotation, if nil, this is the
|
|
362 matching close."
|
|
363 (cond ((stringp name)
|
|
364 (format enriched-annotation-format (if positive "" "/") name))
|
|
365 ;; Otherwise it is an annotation with parameters, represented as a list
|
|
366 (positive
|
|
367 (let ((item (car name))
|
|
368 (params (cdr name)))
|
|
369 (concat (format enriched-annotation-format "" item)
|
|
370 (mapconcat (lambda (i) (concat "<param>" i "</param>"))
|
|
371 params ""))))
|
|
372 (t (format enriched-annotation-format "/" (car name)))))
|
|
373
|
2
|
374 ;; XEmacs addition
|
0
|
375 (defun enriched-face-strip-size (face)
|
|
376 "Create a symbol from the name of FACE devoid of size information,
|
|
377 i.e. remove all larger- and smaller- prefixes."
|
|
378 (let* ((face-symbol (face-name face))
|
|
379 (face-name (symbol-name face-symbol))
|
|
380 (old-name face-name)
|
|
381 new-name)
|
|
382 (while
|
|
383 (not (string-equal
|
|
384 old-name
|
|
385 (setq new-name (replace-in-string old-name "^larger-" ""))))
|
|
386 (setq old-name new-name))
|
|
387
|
|
388 (while
|
|
389 (not (string-equal
|
|
390 old-name
|
|
391 (setq new-name (replace-in-string old-name "^smaller-" ""))))
|
|
392 (setq old-name new-name))
|
|
393
|
|
394 (if (string-equal new-name face-name)
|
|
395 face-symbol
|
|
396 (intern new-name))))
|
|
397
|
|
398 (defun enriched-encode-other-face (old new)
|
|
399 "Generate annotations for random face change.
|
|
400 One annotation each for foreground color, background color, italic, etc."
|
|
401 (cons (and old (enriched-face-ans old))
|
|
402 (and new (enriched-face-ans new))))
|
|
403
|
|
404 (defun enriched-face-ans (face)
|
|
405 "Return annotations specifying FACE."
|
2
|
406 ;; XEmacs change (entire body of this function)
|
0
|
407 (let ((face-name (symbol-name face)))
|
|
408 (cond ((string-match "^fg:" face-name)
|
|
409 (list (list "x-color" (substring face-name 3))))
|
|
410 ((string-match "^bg:" face-name)
|
|
411 (list (list "x-bg-color" (substring face-name 3))))
|
|
412 ((or (string-match "^larger-" face-name)
|
|
413 (string-match "^smaller-" face-name))
|
|
414 (cdr (format-annotate-single-property-change
|
|
415 'face nil (enriched-face-strip-size face)
|
|
416 enriched-translations)))
|
|
417 (t
|
|
418 (let* ((fg (and (not (eq (face-foreground face)
|
|
419 (face-foreground 'default)))
|
|
420 (color-instance-name (face-foreground face))))
|
|
421 (bg (and (not (eq (face-background face)
|
|
422 (face-background 'default)))
|
|
423 (color-instance-name (face-background face))))
|
|
424 (ans '()))
|
|
425 (if fg (setq ans (cons (list "x-color" fg) ans)))
|
|
426 (if bg (setq ans (cons (list "x-bg-color" bg) ans)))
|
|
427 ans)))))
|
|
428
|
2
|
429 ;; XEmacs addition
|
0
|
430 (defun enriched-size-annotation (n annotation)
|
|
431 "Generate ANNOTATION N times."
|
|
432 (let ((l '()))
|
|
433 (while (not (zerop n))
|
|
434 (setq l (cons annotation l))
|
|
435 (setq n (1- n)))
|
|
436 l))
|
|
437
|
2
|
438 ;; XEmacs addition
|
0
|
439 (defun enriched-encode-size (old new)
|
|
440 "Return annotations specifying SIZE."
|
|
441 (let* ((old (or old 0))
|
|
442 (new (or new 0))
|
|
443 (closing-annotation
|
|
444 (enriched-size-annotation (abs old)
|
|
445 (if (> old 0) "bigger" "smaller")))
|
|
446 (opening-annotation
|
|
447 (enriched-size-annotation (abs new)
|
|
448 (if (> new 0) "bigger" "smaller"))))
|
|
449 (cons closing-annotation
|
|
450 opening-annotation)))
|
|
451
|
|
452 ;;;
|
|
453 ;;; Decoding files
|
|
454 ;;;
|
|
455
|
|
456 ;;;###autoload
|
|
457 (defun enriched-decode (from to)
|
|
458 (if enriched-verbose (message "Enriched: decoding document..."))
|
|
459 (save-excursion
|
|
460 (save-restriction
|
|
461 (narrow-to-region from to)
|
|
462 (goto-char from)
|
|
463 (let ((file-width (enriched-get-file-width))
|
|
464 (use-hard-newlines t))
|
|
465 (enriched-remove-header)
|
|
466
|
|
467 ;; Deal with newlines
|
|
468 (goto-char from)
|
|
469 (while (search-forward-regexp "\n\n+" nil t)
|
|
470 (if (current-justification)
|
|
471 (delete-char -1))
|
|
472 (put-text-property (match-beginning 0) (point) 'hard t)
|
|
473 (put-text-property (match-beginning 0) (point) 'front-sticky nil))
|
|
474
|
|
475 ;; Translate annotations
|
|
476 (format-deannotate-region from (point-max) enriched-translations
|
|
477 'enriched-next-annotation)
|
|
478
|
|
479 ;; Fill paragraphs
|
|
480 (if (or (and file-width ; possible reasons not to fill:
|
|
481 (= file-width (enriched-text-width))) ; correct wd.
|
|
482 (null enriched-fill-after-visiting) ; never fill
|
|
483 (and (eq 'ask enriched-fill-after-visiting) ; asked & declined
|
|
484 (not (y-or-n-p "Re-fill for current display width? "))))
|
|
485 ;; Minimally, we have to insert indentation and justification.
|
|
486 (enriched-insert-indentation)
|
|
487 (if enriched-verbose (message "Filling paragraphs..."))
|
|
488 (fill-region (point-min) (point-max))))
|
|
489 (if enriched-verbose (message nil))
|
|
490 (point-max))))
|
|
491
|
|
492 (defun enriched-next-annotation ()
|
|
493 "Find and return next text/enriched annotation.
|
|
494 Any \"<<\" strings encountered are converted to \"<\".
|
|
495 Return value is \(begin end name positive-p), or nil if none was found."
|
|
496 (while (and (search-forward "<" nil 1)
|
|
497 (progn (goto-char (match-beginning 0))
|
|
498 (not (looking-at enriched-annotation-regexp))))
|
|
499 (forward-char 1)
|
|
500 (if (= ?< (char-after (point)))
|
|
501 (delete-char 1)
|
|
502 ;; A single < that does not start an annotation is an error,
|
|
503 ;; which we note and then ignore.
|
2
|
504 (message "Warning: malformed annotation in file at %s"
|
|
505 (1- (point)))))
|
0
|
506 (if (not (eobp))
|
|
507 (let* ((beg (match-beginning 0))
|
|
508 (end (match-end 0))
|
|
509 (name (downcase (buffer-substring
|
|
510 (match-beginning 2) (match-end 2))))
|
|
511 (pos (not (match-beginning 1))))
|
|
512 (list beg end name pos))))
|
|
513
|
|
514 (defun enriched-get-file-width ()
|
|
515 "Look for file width information on this line."
|
|
516 (save-excursion
|
|
517 (if (search-forward "Text-Width: " (+ (point) 1000) t)
|
|
518 (read (current-buffer)))))
|
|
519
|
|
520 (defun enriched-remove-header ()
|
|
521 "Remove file-format header at point."
|
|
522 (while (looking-at "^[-A-Za-z]+: .*\n")
|
|
523 (delete-region (point) (match-end 0)))
|
|
524 (if (looking-at "^\n")
|
|
525 (delete-char 1)))
|
|
526
|
|
527 (defun enriched-decode-foreground (from to color)
|
2
|
528 ;; XEmacs change
|
0
|
529 (let ((face (facemenu-get-face (intern (concat "fg:" color)))))
|
|
530 (if (not face)
|
|
531 (progn
|
|
532 (make-face face)
|
|
533 (message "Warning: Color \"%s\" can't be displayed." color)))
|
|
534 (list from to 'face face)))
|
|
535
|
|
536 (defun enriched-decode-background (from to color)
|
2
|
537 ;; XEmacs change
|
0
|
538 (let ((face (facemenu-get-face (intern (concat "bg:" color)))))
|
|
539 (if (not face)
|
|
540 (progn
|
|
541 (make-face face)
|
|
542 (message "Warning: Color \"%s\" can't be displayed." color)))
|
|
543 (list from to 'face face)))
|
|
544
|
|
545 ;;; enriched.el ends here
|