annotate lisp/enriched.el @ 13877:44149f0bf44a

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