annotate lisp/enriched.el @ 15681:b0652f55a85d

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