Mercurial > emacs
annotate lisp/enriched.el @ 18440:a94d8b31ae3d
(isearch-search-and-update): When a reverse search
need not actually search, update isearch-case-fold-search anyway.
(isearch-mode-map): Define latin-iso8859-9 as self-searching.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 25 Jun 1997 03:45:38 +0000 |
parents | 5c5fa38a1c79 |
children | fa6d68fd97b1 |
rev | line source |
---|---|
13337 | 1 ;;; enriched.el --- read and save files in text/enriched format |
14169 | 2 |
16022
ac3fea1b270e
Add 1996 to copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
16021
diff
changeset
|
3 ;; Copyright (c) 1994, 1995, 1996 Free Software Foundation, Inc. |
9676 | 4 |
12082
257af4819582
Change email address for Boris.
Boris Goldowsky <boris@gnu.org>
parents:
11234
diff
changeset
|
5 ;; Author: Boris Goldowsky <boris@gnu.ai.mit.edu> |
9676 | 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. | |
14169 | 14 |
9676 | 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. | |
14169 | 19 |
9676 | 20 ;; You should have received a copy of the GNU General Public License |
14169 | 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. | |
9676 | 24 |
25 ;;; Commentary: | |
14169 | 26 |
9676 | 27 ;; This file implements reading, editing, and saving files with |
14169 | 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 | |
9676 | 31 ;; The file format used is the MIME text/enriched format, which is a |
14169 | 32 ;; standard format defined in internet RFC 1563. All standard annotations |
33 ;; are supported except for <smaller> and <bigger>, which are currently not | |
9676 | 34 ;; possible to display. |
14169 | 35 |
9676 | 36 ;; A separate file, enriched.doc, contains further documentation and other |
14169 | 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: | |
9676 | 42 |
43 (provide 'enriched) | |
44 | |
45 ;;; | |
46 ;;; Variables controlling the display | |
47 ;;; | |
48 | |
17426
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
49 (defgroup enriched nil |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
50 "Read and save files in text/enriched format" |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
51 :group 'wp) |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
52 |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
53 (defcustom enriched-verbose t |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
54 "*If non-nil, give status messages when reading and writing files." |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
55 :type 'boolean |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
56 :group 'enriched) |
9676 | 57 |
58 ;;; | |
59 ;;; Set up faces & display table | |
60 ;;; | |
61 | |
62 ;; A slight cheat - all emacs's faces are fixed-width. | |
63 ;; The idea is just to pick one that looks different from the default. | |
64 (if (internal-find-face 'fixed) | |
65 nil | |
66 (make-face 'fixed) | |
67 (if window-system | |
68 (set-face-font 'fixed | |
69 (car (or (x-list-fonts "*fixed-medium*" | |
70 'default (selected-frame)) | |
71 (x-list-fonts "*fixed*" | |
72 'default (selected-frame))))))) | |
73 | |
74 (if (internal-find-face 'excerpt) | |
75 nil | |
76 (make-face 'excerpt) | |
77 (if window-system | |
12370
07d919c1b14a
(excerpt): Ignore error making `excerpt' italic.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
78 (make-face-italic 'excerpt nil t))) |
9676 | 79 |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
80 (defconst enriched-display-table (or (copy-sequence standard-display-table) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
81 (make-display-table))) |
9676 | 82 (aset enriched-display-table ?\f (make-vector (1- (frame-width)) ?-)) |
83 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
84 (defconst enriched-par-props '(left-margin right-margin justification) |
9676 | 85 "Text-properties that usually apply to whole paragraphs. |
86 These are set front-sticky everywhere except at hard newlines.") | |
87 | |
88 ;;; | |
89 ;;; Variables controlling the file format | |
90 ;;; (bidirectional) | |
91 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
92 (defconst enriched-initial-annotation |
9676 | 93 (lambda () |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
94 (format "Content-Type: text/enriched\nText-Width: %d\n\n" |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
95 fill-column)) |
9676 | 96 "What to insert at the start of a text/enriched file. |
97 If this is a string, it is inserted. If it is a list, it should be a lambda | |
98 expression, which is evaluated to get the string to insert.") | |
99 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
100 (defconst enriched-annotation-format "<%s%s>" |
9676 | 101 "General format of enriched-text annotations.") |
102 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
103 (defconst enriched-annotation-regexp "<\\(/\\)?\\([-A-za-z0-9]+\\)>" |
9676 | 104 "Regular expression matching enriched-text annotations.") |
105 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
106 (defconst enriched-translations |
9676 | 107 '((face (bold-italic "bold" "italic") |
108 (bold "bold") | |
109 (italic "italic") | |
110 (underline "underline") | |
111 (fixed "fixed") | |
112 (excerpt "excerpt") | |
113 (default ) | |
114 (nil enriched-encode-other-face)) | |
115 (left-margin (4 "indent")) | |
116 (right-margin (4 "indentright")) | |
117 (justification (none "nofill") | |
118 (right "flushright") | |
119 (left "flushleft") | |
10519
66c7e651194d
(enriched-annotation-list): property `hard-newline'
Richard M. Stallman <rms@gnu.org>
parents:
9694
diff
changeset
|
120 (full "flushboth") |
9676 | 121 (center "center")) |
122 (PARAMETER (t "param")) ; Argument of preceding annotation | |
123 ;; The following are not part of the standard: | |
124 (FUNCTION (enriched-decode-foreground "x-color") | |
125 (enriched-decode-background "x-bg-color")) | |
126 (read-only (t "x-read-only")) | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
127 (unknown (nil format-annotate-value)) |
9676 | 128 ; (font-size (2 "bigger") ; unimplemented |
129 ; (-2 "smaller")) | |
130 ) | |
131 "List of definitions of text/enriched annotations. | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
132 See `format-annotate-region' and `format-deannotate-region' for the definition |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
133 of this structure.") |
9676 | 134 |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
135 (defconst enriched-ignore |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
136 '(front-sticky rear-nonsticky hard) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
137 "Properties that are OK to ignore when saving text/enriched files. |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
138 Any property that is neither on this list nor dealt with by |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
139 `enriched-translations' will generate a warning.") |
9676 | 140 |
141 ;;; Internal variables | |
142 | |
143 (defvar enriched-mode nil | |
15239 | 144 "True if Enriched mode is in use.") |
9676 | 145 (make-variable-buffer-local 'enriched-mode) |
146 | |
147 (if (not (assq 'enriched-mode minor-mode-alist)) | |
148 (setq minor-mode-alist | |
149 (cons '(enriched-mode " Enriched") | |
150 minor-mode-alist))) | |
151 | |
17426
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
152 (defcustom enriched-mode-hook nil |
15239 | 153 "Functions to run when entering Enriched mode. |
9676 | 154 If you set variables in this hook, you should arrange for them to be restored |
15239 | 155 to their old values if you leave Enriched mode. One way to do this is to add |
17426
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
156 them and their old values to `enriched-old-bindings'." |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
157 :type 'hook |
5c5fa38a1c79
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17207
diff
changeset
|
158 :group 'enriched) |
9676 | 159 |
160 (defvar enriched-old-bindings nil | |
161 "Store old variable values that we change when entering mode. | |
162 The value is a list of \(VAR VALUE VAR VALUE...).") | |
163 (make-variable-buffer-local 'enriched-old-bindings) | |
164 | |
165 ;;; | |
166 ;;; Define the mode | |
167 ;;; | |
168 | |
9694
f8aa9230c3fa
(enriched-mode): Add autoload cookie.
Boris Goldowsky <boris@gnu.org>
parents:
9677
diff
changeset
|
169 ;;;###autoload |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
170 (defun enriched-mode (&optional arg) |
9676 | 171 "Minor mode for editing text/enriched files. |
172 These are files with embedded formatting information in the MIME standard | |
173 text/enriched format. | |
15239 | 174 Turning the mode on runs `enriched-mode-hook'. |
9676 | 175 |
15239 | 176 More information about Enriched mode is available in the file |
9676 | 177 etc/enriched.doc in the Emacs distribution directory. |
178 | |
179 Commands: | |
180 | |
181 \\<enriched-mode-map>\\{enriched-mode-map}" | |
182 (interactive "P") | |
183 (let ((mod (buffer-modified-p))) | |
184 (cond ((or (<= (prefix-numeric-value arg) 0) | |
185 (and enriched-mode (null arg))) | |
186 ;; Turn mode off | |
187 (setq enriched-mode nil) | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
188 (setq buffer-file-format (delq 'text/enriched buffer-file-format)) |
9676 | 189 ;; restore old variable values |
190 (while enriched-old-bindings | |
191 (funcall 'set (car enriched-old-bindings) | |
192 (car (cdr enriched-old-bindings))) | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
193 (setq enriched-old-bindings (cdr (cdr enriched-old-bindings))))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
194 |
9676 | 195 (enriched-mode nil) ; Mode already on; do nothing. |
196 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
197 (t (setq enriched-mode t) ; Turn mode on |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
198 (add-to-list 'buffer-file-format 'text/enriched) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
199 ;; Save old variable values before we change them. |
15239 | 200 ;; These will be restored if we exit Enriched mode. |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
201 (setq enriched-old-bindings |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
202 (list 'buffer-display-table buffer-display-table |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
203 'indent-line-function indent-line-function |
11129
2ce4b0aac50c
(enriched-mode): Use new plist-put and plist-get fns,
Boris Goldowsky <boris@gnu.org>
parents:
11055
diff
changeset
|
204 'default-text-properties default-text-properties)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
205 (make-local-variable 'indent-line-function) |
11129
2ce4b0aac50c
(enriched-mode): Use new plist-put and plist-get fns,
Boris Goldowsky <boris@gnu.org>
parents:
11055
diff
changeset
|
206 (make-local-variable 'default-text-properties) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
207 (setq indent-line-function 'indent-to-left-margin |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
208 buffer-display-table enriched-display-table) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
209 (use-hard-newlines 1 nil) |
11129
2ce4b0aac50c
(enriched-mode): Use new plist-put and plist-get fns,
Boris Goldowsky <boris@gnu.org>
parents:
11055
diff
changeset
|
210 (let ((sticky (plist-get default-text-properties 'front-sticky)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
211 (p enriched-par-props)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
212 (while p |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
213 (add-to-list 'sticky (car p)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
214 (setq p (cdr p))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
215 (if sticky |
11129
2ce4b0aac50c
(enriched-mode): Use new plist-put and plist-get fns,
Boris Goldowsky <boris@gnu.org>
parents:
11055
diff
changeset
|
216 (setq default-text-properties |
2ce4b0aac50c
(enriched-mode): Use new plist-put and plist-get fns,
Boris Goldowsky <boris@gnu.org>
parents:
11055
diff
changeset
|
217 (plist-put default-text-properties |
2ce4b0aac50c
(enriched-mode): Use new plist-put and plist-get fns,
Boris Goldowsky <boris@gnu.org>
parents:
11055
diff
changeset
|
218 'front-sticky sticky)))) |
15239 | 219 (run-hooks 'enriched-mode-hook))) |
9676 | 220 (set-buffer-modified-p mod) |
221 (force-mode-line-update))) | |
222 | |
223 ;;; | |
224 ;;; Keybindings | |
225 ;;; | |
226 | |
227 (defvar enriched-mode-map nil | |
15239 | 228 "Keymap for Enriched mode.") |
9676 | 229 |
230 (if (null enriched-mode-map) | |
231 (fset 'enriched-mode-map (setq enriched-mode-map (make-sparse-keymap)))) | |
232 | |
233 (if (not (assq 'enriched-mode minor-mode-map-alist)) | |
234 (setq minor-mode-map-alist | |
235 (cons (cons 'enriched-mode enriched-mode-map) | |
236 minor-mode-map-alist))) | |
237 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
238 (define-key enriched-mode-map "\C-a" 'beginning-of-line-text) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
239 (define-key enriched-mode-map "\C-m" 'reindent-then-newline-and-indent) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
240 (define-key enriched-mode-map "\C-j" 'reindent-then-newline-and-indent) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
241 (define-key enriched-mode-map "\M-j" 'facemenu-justification-menu) |
10519
66c7e651194d
(enriched-annotation-list): property `hard-newline'
Richard M. Stallman <rms@gnu.org>
parents:
9694
diff
changeset
|
242 (define-key enriched-mode-map "\M-S" 'set-justification-center) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
243 (define-key enriched-mode-map "\C-x\t" 'increase-left-margin) |
10519
66c7e651194d
(enriched-annotation-list): property `hard-newline'
Richard M. Stallman <rms@gnu.org>
parents:
9694
diff
changeset
|
244 (define-key enriched-mode-map "\C-c\C-l" 'set-left-margin) |
66c7e651194d
(enriched-annotation-list): property `hard-newline'
Richard M. Stallman <rms@gnu.org>
parents:
9694
diff
changeset
|
245 (define-key enriched-mode-map "\C-c\C-r" 'set-right-margin) |
9676 | 246 |
247 ;;; | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
248 ;;; Some functions dealing with text-properties, especially indentation |
9676 | 249 ;;; |
250 | |
251 (defun enriched-map-property-regions (prop func &optional from to) | |
252 "Apply a function to regions of the buffer based on a text property. | |
253 For each contiguous region of the buffer for which the value of PROPERTY is | |
254 eq, the FUNCTION will be called. Optional arguments FROM and TO specify the | |
255 region over which to scan. | |
256 | |
257 The specified function receives three arguments: the VALUE of the property in | |
258 the region, and the START and END of each region." | |
259 (save-excursion | |
260 (save-restriction | |
261 (if to (narrow-to-region (point-min) to)) | |
262 (goto-char (or from (point-min))) | |
263 (let ((begin (point)) | |
264 end | |
265 (marker (make-marker)) | |
266 (val (get-text-property (point) prop))) | |
267 (while (setq end (text-property-not-all begin (point-max) prop val)) | |
268 (move-marker marker end) | |
269 (funcall func val begin (marker-position marker)) | |
270 (setq begin (marker-position marker) | |
271 val (get-text-property marker prop))) | |
272 (if (< begin (point-max)) | |
273 (funcall func val begin (point-max))))))) | |
274 | |
275 (put 'enriched-map-property-regions 'lisp-indent-hook 1) | |
276 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
277 (defun enriched-insert-indentation (&optional from to) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
278 "Indent and justify each line in the region." |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
279 (save-excursion |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
280 (save-restriction |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
281 (if to (narrow-to-region (point-min) to)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
282 (goto-char (or from (point-min))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
283 (if (not (bolp)) (forward-line 1)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
284 (while (not (eobp)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
285 (if (eolp) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
286 nil ; skip blank lines |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
287 (indent-to (current-left-margin)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
288 (justify-current-line t nil t)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
289 (forward-line 1))))) |
9676 | 290 |
291 ;;; | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
292 ;;; Encoding Files |
9676 | 293 ;;; |
294 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
295 ;;;###autoload |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
296 (defun enriched-encode (from to orig-buf) |
9676 | 297 (if enriched-verbose (message "Enriched: encoding document...")) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
298 (save-restriction |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
299 (narrow-to-region from to) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
300 (delete-to-left-margin) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
301 (unjustify-region) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
302 (goto-char from) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
303 (format-replace-strings '(("<" . "<<"))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
304 (format-insert-annotations |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
305 (format-annotate-region from (point-max) enriched-translations |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
306 'enriched-make-annotation enriched-ignore)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
307 (goto-char from) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
308 (insert (if (stringp enriched-initial-annotation) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
309 enriched-initial-annotation |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
310 (save-excursion |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
311 ;; Eval this in the buffer we are annotating. This |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
312 ;; fixes a bug which was saving incorrect File-Width |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
313 ;; information, since we were looking at local |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
314 ;; variables in the wrong buffer. |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
315 (if orig-buf (set-buffer orig-buf)) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
316 (funcall enriched-initial-annotation)))) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
317 (enriched-map-property-regions 'hard |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
318 (lambda (v b e) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
319 (if (and v (= ?\n (char-after b))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
320 (progn (goto-char b) (insert "\n")))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
321 (point) nil) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
322 (if enriched-verbose (message nil)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
323 ;; Return new end. |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
324 (point-max))) |
9676 | 325 |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
326 (defun enriched-make-annotation (name positive) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
327 "Format an annotation called NAME. |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
328 If POSITIVE is non-nil, this is the opening annotation, if nil, this is the |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
329 matching close." |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
330 (cond ((stringp name) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
331 (format enriched-annotation-format (if positive "" "/") name)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
332 ;; Otherwise it is an annotation with parameters, represented as a list |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
333 (positive |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
334 (let ((item (car name)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
335 (params (cdr name))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
336 (concat (format enriched-annotation-format "" item) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
337 (mapconcat (lambda (i) (concat "<param>" i "</param>")) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
338 params "")))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
339 (t (format enriched-annotation-format "/" (car name))))) |
9676 | 340 |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
341 (defun enriched-encode-other-face (old new) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
342 "Generate annotations for random face change. |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
343 One annotation each for foreground color, background color, italic, etc." |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
344 (cons (and old (enriched-face-ans old)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
345 (and new (enriched-face-ans new)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
346 |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
347 (defun enriched-face-ans (face) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
348 "Return annotations specifying FACE." |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
349 (cond ((string-match "^fg:" (symbol-name face)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
350 (list (list "x-color" (substring (symbol-name face) 3)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
351 ((string-match "^bg:" (symbol-name face)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
352 (list (list "x-bg-color" (substring (symbol-name face) 3)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
353 ((let* ((fg (face-foreground face)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
354 (bg (face-background face)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
355 (props (face-font face t)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
356 (ans (cdr (format-annotate-single-property-change |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
357 'face nil props enriched-translations)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
358 (if fg (setq ans (cons (list "x-color" fg) ans))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
359 (if bg (setq ans (cons (list "x-bg-color" bg) ans))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
360 ans)))) |
9676 | 361 |
362 ;;; | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
363 ;;; Decoding files |
9676 | 364 ;;; |
365 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
366 ;;;###autoload |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
367 (defun enriched-decode (from to) |
9676 | 368 (if enriched-verbose (message "Enriched: decoding document...")) |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
369 (use-hard-newlines 1 'never) |
9676 | 370 (save-excursion |
371 (save-restriction | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
372 (narrow-to-region from to) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
373 (goto-char from) |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
374 |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
375 ;; Deal with header |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
376 (let ((file-width (enriched-get-file-width))) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
377 (enriched-remove-header) |
9676 | 378 |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
379 ;; Deal with newlines |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
380 (while (search-forward-regexp "\n\n+" nil t) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
381 (if (current-justification) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
382 (delete-char -1)) |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
383 (set-hard-newline-properties (match-beginning 0) (point))) |
9676 | 384 |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
385 ;; Translate annotations |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
386 (format-deannotate-region from (point-max) enriched-translations |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
387 'enriched-next-annotation) |
9676 | 388 |
16021
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
389 ;; Indent or fill the buffer |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
390 (cond (file-width ; File was filled to this width |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
391 (setq fill-column file-width) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
392 (if enriched-verbose (message "Indenting...")) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
393 (enriched-insert-indentation)) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
394 (t ; File was not filled. |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
395 (if enriched-verbose (message "Filling paragraphs...")) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
396 (fill-region (point-min) (point-max)))) |
d6a8a05960d5
Don't fill based on window width.
Richard M. Stallman <rms@gnu.org>
parents:
15239
diff
changeset
|
397 (if enriched-verbose (message nil))) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
398 (point-max)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
399 |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
400 (defun enriched-next-annotation () |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
401 "Find and return next text/enriched annotation. |
13488
71c747dc59ca
(enriched-next-annotation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
402 Any \"<<\" strings encountered are converted to \"<\". |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
403 Return value is \(begin end name positive-p), or nil if none was found." |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
404 (while (and (search-forward "<" nil 1) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
405 (progn (goto-char (match-beginning 0)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
406 (not (looking-at enriched-annotation-regexp)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
407 (forward-char 1) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
408 (if (= ?< (char-after (point))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
409 (delete-char 1) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
410 ;; A single < that does not start an annotation is an error, |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
411 ;; which we note and then ignore. |
14340
bf1d862f3673
(enriched-next-annotation): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
412 (message "Warning: malformed annotation in file at %s" |
bf1d862f3673
(enriched-next-annotation): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
413 (1- (point))))) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
414 (if (not (eobp)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
415 (let* ((beg (match-beginning 0)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
416 (end (match-end 0)) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
417 (name (downcase (buffer-substring |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
418 (match-beginning 2) (match-end 2)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
419 (pos (not (match-beginning 1)))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
420 (list beg end name pos)))) |
9676 | 421 |
422 (defun enriched-get-file-width () | |
423 "Look for file width information on this line." | |
424 (save-excursion | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
425 (if (search-forward "Text-Width: " (+ (point) 1000) t) |
9676 | 426 (read (current-buffer))))) |
427 | |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
428 (defun enriched-remove-header () |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
429 "Remove file-format header at point." |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
430 (while (looking-at "^[-A-Za-z]+: .*\n") |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
431 (delete-region (point) (match-end 0))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
432 (if (looking-at "^\n") |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
433 (delete-char 1))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
434 |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
435 (defun enriched-decode-foreground (from to &optional color) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
436 (let ((face (intern (concat "fg:" color)))) |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
437 (cond ((null color) |
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
438 (message "Warning: no color specified for <x-color>")) |
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
439 ((internal-find-face face)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
440 ((and window-system (facemenu-get-face face))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
441 (window-system |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
442 (message "Warning: color `%s' is not defined" color)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
443 ((make-face face) |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
444 (message "Warning: color `%s' can't be displayed" color))) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
445 (list from to 'face face))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
446 |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
447 (defun enriched-decode-background (from to &optional color) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
448 (let ((face (intern (concat "bg:" color)))) |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
449 (cond ((null color) |
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
450 (message "Warning: no color specified for <x-bg-color>")) |
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
451 ((internal-find-face face)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
452 ((and window-system (facemenu-get-face face))) |
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
453 (window-system |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
454 (message "Warning: color `%s' is not defined" color)) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
455 ((make-face face) |
17207
2d0b382efa26
(enriched-decode-foreground, enriched-decode-background):
Richard M. Stallman <rms@gnu.org>
parents:
16022
diff
changeset
|
456 (message "Warning: color `%s' can't be displayed" color))) |
11055
c8790275a636
Rewrite, many things moved to format.el.
Boris Goldowsky <boris@gnu.org>
parents:
10519
diff
changeset
|
457 (list from to 'face face))) |
9676 | 458 |
459 ;;; enriched.el ends here |