Mercurial > emacs
annotate lisp/textmodes/enriched.el @ 56875:db0f95a55fd4
(ispell-html-skip-alists): Fix backslashes in docstring.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Thu, 02 Sep 2004 09:42:13 +0000 |
parents | a712704c769c |
children | 049bdfb5d92f 6f6e9fe4658b |
rev | line source |
---|---|
51349 | 1 ;;; enriched.el --- read and save files in text/enriched format |
2 | |
3 ;; Copyright (c) 1994, 1995, 1996, 2002 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Boris Goldowsky <boris@gnu.org> | |
6 ;; Keywords: wp, faces | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; This file implements reading, editing, and saving files with | |
28 ;; text-properties such as faces, levels of indentation, and true line | |
29 ;; breaks distinguished from newlines just used to fit text into the window. | |
30 | |
31 ;; The file format used is the MIME text/enriched format, which is a | |
32 ;; standard format defined in internet RFC 1563. All standard annotations | |
33 ;; are supported except for <smaller> and <bigger>, which are currently not | |
34 ;; possible to display. | |
35 | |
36 ;; A separate file, enriched.doc, contains further documentation and other | |
37 ;; important information about this code. It also serves as an example | |
38 ;; file in text/enriched format. It should be in the etc directory of your | |
39 ;; emacs distribution. | |
40 | |
41 ;;; Code: | |
42 | |
43 (provide 'enriched) | |
44 | |
45 ;;; | |
46 ;;; Variables controlling the display | |
47 ;;; | |
48 | |
49 (defgroup enriched nil | |
50 "Read and save files in text/enriched format" | |
51 :group 'wp) | |
52 | |
53 (defcustom enriched-verbose t | |
54 "*If non-nil, give status messages when reading and writing files." | |
55 :type 'boolean | |
56 :group 'enriched) | |
57 | |
58 ;;; | |
59 ;;; Set up faces & display table | |
60 ;;; | |
61 | |
62 ;; Emacs doesn't have a "fixed" face by default, since all faces currently | |
63 ;; have to be fixed-width. So we just pick one that looks different from the | |
64 ;; default. | |
65 (defface fixed | |
66 '((t (:weight bold))) | |
67 "Face used for text that must be shown in fixed width. | |
68 Currently, emacs can only display fixed-width fonts, but this may change. | |
69 This face is used for text specifically marked as fixed-width, for example | |
70 in text/enriched files." | |
71 :group 'enriched) | |
72 | |
73 (defface excerpt | |
74 '((t (:slant italic))) | |
75 "Face used for text that is an excerpt from another document. | |
76 This is used in Enriched mode for text explicitly marked as an excerpt." | |
77 :group 'enriched) | |
78 | |
79 (defconst enriched-display-table (or (copy-sequence standard-display-table) | |
80 (make-display-table))) | |
81 (aset enriched-display-table ?\f (make-vector (1- (frame-width)) ?-)) | |
82 | |
83 (defconst enriched-par-props '(left-margin right-margin justification) | |
84 "Text-properties that usually apply to whole paragraphs. | |
85 These are set front-sticky everywhere except at hard newlines.") | |
86 | |
87 ;;; | |
88 ;;; Variables controlling the file format | |
89 ;;; (bidirectional) | |
90 | |
91 (defconst enriched-initial-annotation | |
92 (lambda () | |
93 (format "Content-Type: text/enriched\nText-Width: %d\n\n" | |
94 fill-column)) | |
95 "What to insert at the start of a text/enriched file. | |
96 If this is a string, it is inserted. If it is a list, it should be a lambda | |
97 expression, which is evaluated to get the string to insert.") | |
98 | |
99 (defconst enriched-annotation-format "<%s%s>" | |
100 "General format of enriched-text annotations.") | |
101 | |
102 (defconst enriched-annotation-regexp "<\\(/\\)?\\([-A-Za-z0-9]+\\)>" | |
103 "Regular expression matching enriched-text annotations.") | |
104 | |
105 (defconst enriched-translations | |
106 '((face (bold-italic "bold" "italic") | |
107 (bold "bold") | |
108 (italic "italic") | |
109 (underline "underline") | |
110 (fixed "fixed") | |
111 (excerpt "excerpt") | |
112 (default ) | |
113 (nil enriched-encode-other-face)) | |
114 (left-margin (4 "indent")) | |
115 (right-margin (4 "indentright")) | |
116 (justification (none "nofill") | |
117 (right "flushright") | |
118 (left "flushleft") | |
119 (full "flushboth") | |
120 (center "center")) | |
121 (PARAMETER (t "param")) ; Argument of preceding annotation | |
122 ;; The following are not part of the standard: | |
123 (FUNCTION (enriched-decode-foreground "x-color") | |
124 (enriched-decode-background "x-bg-color") | |
125 (enriched-decode-display-prop "x-display")) | |
126 (read-only (t "x-read-only")) | |
127 (display (nil enriched-handle-display-prop)) | |
128 (unknown (nil format-annotate-value)) | |
129 ; (font-size (2 "bigger") ; unimplemented | |
130 ; (-2 "smaller")) | |
131 ) | |
132 "List of definitions of text/enriched annotations. | |
133 See `format-annotate-region' and `format-deannotate-region' for the definition | |
134 of this structure.") | |
135 | |
136 (defconst enriched-ignore | |
137 '(front-sticky rear-nonsticky hard) | |
138 "Properties that are OK to ignore when saving text/enriched files. | |
139 Any property that is neither on this list nor dealt with by | |
140 `enriched-translations' will generate a warning.") | |
141 | |
142 ;;; Internal variables | |
143 | |
144 | |
145 (defcustom enriched-mode-hook nil | |
146 "Hook run after entering/leaving Enriched mode. | |
147 If you set variables in this hook, you should arrange for them to be restored | |
148 to their old values if you leave Enriched mode. One way to do this is to add | |
149 them and their old values to `enriched-old-bindings'." | |
150 :type 'hook | |
151 :group 'enriched) | |
152 | |
153 (defvar enriched-old-bindings nil | |
154 "Store old variable values that we change when entering mode. | |
155 The value is a list of \(VAR VALUE VAR VALUE...).") | |
156 (make-variable-buffer-local 'enriched-old-bindings) | |
157 | |
158 ;;; | |
159 ;;; Define the mode | |
160 ;;; | |
161 | |
162 (put 'enriched-mode 'permanent-local t) | |
163 ;;;###autoload | |
164 (define-minor-mode enriched-mode | |
165 "Minor mode for editing text/enriched files. | |
166 These are files with embedded formatting information in the MIME standard | |
167 text/enriched format. | |
168 Turning the mode on runs `enriched-mode-hook'. | |
169 | |
170 More information about Enriched mode is available in the file | |
171 etc/enriched.doc in the Emacs distribution directory. | |
172 | |
173 Commands: | |
174 | |
175 \\{enriched-mode-map}" | |
176 nil " Enriched" nil | |
177 (cond ((null enriched-mode) | |
178 ;; Turn mode off | |
179 (setq buffer-file-format (delq 'text/enriched buffer-file-format)) | |
180 ;; restore old variable values | |
181 (while enriched-old-bindings | |
182 (set (pop enriched-old-bindings) (pop enriched-old-bindings)))) | |
183 | |
184 ((memq 'text/enriched buffer-file-format) | |
185 ;; Mode already on; do nothing. | |
186 nil) | |
187 | |
188 (t ; Turn mode on | |
189 (push 'text/enriched buffer-file-format) | |
190 ;; Save old variable values before we change them. | |
191 ;; These will be restored if we exit Enriched mode. | |
192 (setq enriched-old-bindings | |
193 (list 'buffer-display-table buffer-display-table | |
194 'indent-line-function indent-line-function | |
195 'default-text-properties default-text-properties)) | |
196 (make-local-variable 'indent-line-function) | |
197 (make-local-variable 'default-text-properties) | |
198 (setq indent-line-function 'indent-to-left-margin ;WHY?? -sm | |
199 buffer-display-table enriched-display-table) | |
200 (use-hard-newlines 1 nil) | |
201 (let ((sticky (plist-get default-text-properties 'front-sticky)) | |
202 (p enriched-par-props)) | |
203 (dolist (x p) | |
204 (add-to-list 'sticky x)) | |
205 (if sticky | |
206 (setq default-text-properties | |
207 (plist-put default-text-properties | |
208 'front-sticky sticky))))))) | |
209 | |
210 ;;; | |
211 ;;; Keybindings | |
212 ;;; | |
213 | |
214 (defvar enriched-mode-map nil | |
215 "Keymap for Enriched mode.") | |
216 | |
217 (if (null enriched-mode-map) | |
218 (fset 'enriched-mode-map (setq enriched-mode-map (make-sparse-keymap)))) | |
219 | |
220 (if (not (assq 'enriched-mode minor-mode-map-alist)) | |
221 (setq minor-mode-map-alist | |
222 (cons (cons 'enriched-mode enriched-mode-map) | |
223 minor-mode-map-alist))) | |
224 | |
225 (define-key enriched-mode-map "\C-a" 'beginning-of-line-text) | |
226 (define-key enriched-mode-map "\C-m" 'reindent-then-newline-and-indent) | |
227 (define-key enriched-mode-map "\C-j" 'reindent-then-newline-and-indent) | |
228 (define-key enriched-mode-map "\M-j" 'facemenu-justification-menu) | |
229 (define-key enriched-mode-map "\M-S" 'set-justification-center) | |
230 (define-key enriched-mode-map "\C-x\t" 'increase-left-margin) | |
231 (define-key enriched-mode-map "\C-c\C-l" 'set-left-margin) | |
232 (define-key enriched-mode-map "\C-c\C-r" 'set-right-margin) | |
233 | |
234 ;;; | |
235 ;;; Some functions dealing with text-properties, especially indentation | |
236 ;;; | |
237 | |
238 (defun enriched-map-property-regions (prop func &optional from to) | |
239 "Apply a function to regions of the buffer based on a text property. | |
240 For each contiguous region of the buffer for which the value of PROPERTY is | |
241 eq, the FUNCTION will be called. Optional arguments FROM and TO specify the | |
242 region over which to scan. | |
243 | |
244 The specified function receives three arguments: the VALUE of the property in | |
245 the region, and the START and END of each region." | |
246 (save-excursion | |
247 (save-restriction | |
248 (if to (narrow-to-region (point-min) to)) | |
249 (goto-char (or from (point-min))) | |
250 (let ((begin (point)) | |
251 end | |
252 (marker (make-marker)) | |
253 (val (get-text-property (point) prop))) | |
254 (while (setq end (text-property-not-all begin (point-max) prop val)) | |
255 (move-marker marker end) | |
256 (funcall func val begin (marker-position marker)) | |
257 (setq begin (marker-position marker) | |
258 val (get-text-property marker prop))) | |
259 (if (< begin (point-max)) | |
260 (funcall func val begin (point-max))))))) | |
261 | |
262 (put 'enriched-map-property-regions 'lisp-indent-hook 1) | |
263 | |
264 (defun enriched-insert-indentation (&optional from to) | |
265 "Indent and justify each line in the region." | |
266 (save-excursion | |
267 (save-restriction | |
268 (if to (narrow-to-region (point-min) to)) | |
269 (goto-char (or from (point-min))) | |
270 (if (not (bolp)) (forward-line 1)) | |
271 (while (not (eobp)) | |
272 (if (eolp) | |
273 nil ; skip blank lines | |
274 (indent-to (current-left-margin)) | |
275 (justify-current-line t nil t)) | |
276 (forward-line 1))))) | |
277 | |
278 ;;; | |
279 ;;; Encoding Files | |
280 ;;; | |
281 | |
282 ;;;###autoload | |
283 (defun enriched-encode (from to orig-buf) | |
284 (if enriched-verbose (message "Enriched: encoding document...")) | |
56323
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
285 (let ((inhibit-read-only t)) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
286 (save-restriction |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
287 (narrow-to-region from to) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
288 (delete-to-left-margin) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
289 (unjustify-region) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
290 (goto-char from) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
291 (format-replace-strings '(("<" . "<<"))) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
292 (format-insert-annotations |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
293 (format-annotate-region from (point-max) enriched-translations |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
294 'enriched-make-annotation enriched-ignore)) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
295 (goto-char from) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
296 (insert (if (stringp enriched-initial-annotation) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
297 enriched-initial-annotation |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
298 (save-excursion |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
299 ;; Eval this in the buffer we are annotating. This |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
300 ;; fixes a bug which was saving incorrect File-Width |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
301 ;; information, since we were looking at local |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
302 ;; variables in the wrong buffer. |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
303 (if orig-buf (set-buffer orig-buf)) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
304 (funcall enriched-initial-annotation)))) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
305 (enriched-map-property-regions 'hard |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
306 (lambda (v b e) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
307 (if (and v (= ?\n (char-after b))) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
308 (progn (goto-char b) (insert "\n")))) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
309 (point) nil) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
310 (if enriched-verbose (message nil)) |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
311 ;; Return new end. |
a712704c769c
(enriched-encode): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
312 (point-max)))) |
51349 | 313 |
314 (defun enriched-make-annotation (internal-ann positive) | |
315 "Format an annotation INTERNAL-ANN. | |
316 INTERNAL-ANN may be a string, for a flag, or a list of the form (PARAM VALUE). | |
317 If POSITIVE is non-nil, this is the opening annotation; | |
318 if nil, the matching close." | |
319 (cond ((stringp internal-ann) | |
320 (format enriched-annotation-format (if positive "" "/") internal-ann)) | |
321 ;; Otherwise it is an annotation with parameters, represented as a list | |
322 (positive | |
323 (let ((item (car internal-ann)) | |
324 (params (cdr internal-ann))) | |
325 (concat (format enriched-annotation-format "" item) | |
326 (mapconcat (lambda (i) (concat "<param>" i "</param>")) | |
327 params "")))) | |
328 (t (format enriched-annotation-format "/" (car internal-ann))))) | |
329 | |
330 (defun enriched-encode-other-face (old new) | |
331 "Generate annotations for random face change. | |
332 One annotation each for foreground color, background color, italic, etc." | |
333 (cons (and old (enriched-face-ans old)) | |
334 (and new (enriched-face-ans new)))) | |
335 | |
336 (defun enriched-face-ans (face) | |
337 "Return annotations specifying FACE. | |
338 FACE may be a list of faces instead of a single face; | |
339 it can also be anything allowed as an element of a list | |
340 which can be the value of the `face' text property." | |
341 (cond ((and (consp face) (eq (car face) 'foreground-color)) | |
342 (list (list "x-color" (cdr face)))) | |
343 ((and (consp face) (eq (car face) 'background-color)) | |
344 (list (list "x-bg-color" (cdr face)))) | |
345 ((and (listp face) (eq (car face) :foreground)) | |
346 (list (list "x-color" (cadr face)))) | |
347 ((and (listp face) (eq (car face) :background)) | |
348 (list (list "x-bg-color" (cadr face)))) | |
349 ((listp face) | |
350 (apply 'append (mapcar 'enriched-face-ans face))) | |
351 ((let* ((fg (face-attribute face :foreground)) | |
352 (bg (face-attribute face :background)) | |
353 (props (face-font face t)) | |
354 (ans (cdr (format-annotate-single-property-change | |
355 'face nil props enriched-translations)))) | |
356 (unless (eq fg 'unspecified) | |
357 (setq ans (cons (list "x-color" fg) ans))) | |
358 (unless (eq bg 'unspecified) | |
359 (setq ans (cons (list "x-bg-color" bg) ans))) | |
360 ans)))) | |
361 | |
362 ;;; | |
363 ;;; Decoding files | |
364 ;;; | |
365 | |
366 ;;;###autoload | |
367 (defun enriched-decode (from to) | |
368 (if enriched-verbose (message "Enriched: decoding document...")) | |
369 (use-hard-newlines 1 'never) | |
370 (save-excursion | |
371 (save-restriction | |
372 (narrow-to-region from to) | |
373 (goto-char from) | |
374 | |
375 ;; Deal with header | |
376 (let ((file-width (enriched-get-file-width))) | |
377 (enriched-remove-header) | |
378 | |
379 ;; Deal with newlines | |
380 (while (search-forward-regexp "\n\n+" nil t) | |
381 (if (current-justification) | |
382 (delete-char -1)) | |
383 (set-hard-newline-properties (match-beginning 0) (point))) | |
384 | |
385 ;; Translate annotations | |
386 (format-deannotate-region from (point-max) enriched-translations | |
387 'enriched-next-annotation) | |
388 | |
389 ;; Indent or fill the buffer | |
390 (cond (file-width ; File was filled to this width | |
391 (setq fill-column file-width) | |
392 (if enriched-verbose (message "Indenting...")) | |
393 (enriched-insert-indentation)) | |
394 (t ; File was not filled. | |
395 (if enriched-verbose (message "Filling paragraphs...")) | |
396 (fill-region (point-min) (point-max)))) | |
397 (if enriched-verbose (message nil))) | |
398 (point-max)))) | |
399 | |
400 (defun enriched-next-annotation () | |
401 "Find and return next text/enriched annotation. | |
402 Any \"<<\" strings encountered are converted to \"<\". | |
403 Return value is \(begin end name positive-p), or nil if none was found." | |
404 (while (and (search-forward "<" nil 1) | |
405 (progn (goto-char (match-beginning 0)) | |
406 (not (looking-at enriched-annotation-regexp)))) | |
407 (forward-char 1) | |
408 (if (= ?< (char-after (point))) | |
409 (delete-char 1) | |
410 ;; A single < that does not start an annotation is an error, | |
411 ;; which we note and then ignore. | |
412 (message "Warning: malformed annotation in file at %s" | |
413 (1- (point))))) | |
414 (if (not (eobp)) | |
415 (let* ((beg (match-beginning 0)) | |
416 (end (match-end 0)) | |
417 (name (downcase (buffer-substring | |
418 (match-beginning 2) (match-end 2)))) | |
419 (pos (not (match-beginning 1)))) | |
420 (list beg end name pos)))) | |
421 | |
422 (defun enriched-get-file-width () | |
423 "Look for file width information on this line." | |
424 (save-excursion | |
425 (if (search-forward "Text-Width: " (+ (point) 1000) t) | |
426 (read (current-buffer))))) | |
427 | |
428 (defun enriched-remove-header () | |
429 "Remove file-format header at point." | |
430 (while (looking-at "^[-A-Za-z]+: .*\n") | |
431 (delete-region (point) (match-end 0))) | |
432 (if (looking-at "^\n") | |
433 (delete-char 1))) | |
434 | |
435 (defun enriched-decode-foreground (from to &optional color) | |
436 (if color | |
437 (list from to 'face (list ':foreground color)) | |
438 (message "Warning: no color specified for <x-color>") | |
439 nil)) | |
440 | |
441 (defun enriched-decode-background (from to &optional color) | |
442 (if color | |
443 (list from to 'face (list ':background color)) | |
444 (message "Warning: no color specified for <x-bg-color>") | |
445 nil)) | |
446 | |
447 ;;; Handling the `display' property. | |
448 | |
449 | |
450 (defun enriched-handle-display-prop (old new) | |
451 "Return a list of annotations for a change in the `display' property. | |
452 OLD is the old value of the property, NEW is the new value. Value | |
453 is a list `(CLOSE OPEN)', where CLOSE is a list of annotations to | |
454 close and OPEN a list of annotations to open. Each of these lists | |
455 has the form `(ANNOTATION PARAM ...)'." | |
456 (let ((annotation "x-display") | |
457 (param (prin1-to-string (or old new)))) | |
458 (if (null old) | |
459 (cons nil (list (list annotation param))) | |
460 (cons (list (list annotation param)) nil)))) | |
461 | |
462 (defun enriched-decode-display-prop (start end &optional param) | |
463 "Decode a `display' property for text between START and END. | |
464 PARAM is a `<param>' found for the property. | |
465 Value is a list `(START END SYMBOL VALUE)' with START and END denoting | |
51962
d4560e85f83c
(enriched-decode-display-prop): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
51349
diff
changeset
|
466 the range of text to assign text property SYMBOL with value VALUE." |
51349 | 467 (let ((prop (when (stringp param) |
468 (condition-case () | |
469 (car (read-from-string param)) | |
470 (error nil))))) | |
471 (unless prop | |
472 (message "Warning: invalid <x-display> parameter %s" param)) | |
473 (list start end 'display prop))) | |
474 | |
52401 | 475 ;;; arch-tag: 05cae488-3fea-45cd-ac29-5b02cb64e42b |
51349 | 476 ;;; enriched.el ends here |