73 |
(defface excerpt |
(defface excerpt |
74 |
'((t (:italic t))) |
'((t (:italic t))) |
75 |
"Face used for text that is an excerpt from another document. |
"Face used for text that is an excerpt from another document. |
76 |
This is used in enriched-mode for text explicitly marked as an excerpt." |
This is used in `enriched-mode' for text explicitly marked as an excerpt." |
77 |
:group 'enriched) |
:group 'enriched) |
78 |
|
|
79 |
(defconst enriched-display-table (or (copy-sequence standard-display-table) |
(defconst enriched-display-table (or (copy-sequence standard-display-table) |
141 |
|
|
142 |
;;; Internal variables |
;;; Internal variables |
143 |
|
|
|
(defvar enriched-mode nil |
|
|
"True if Enriched mode is in use.") |
|
|
(make-variable-buffer-local 'enriched-mode) |
|
|
(put 'enriched-mode 'permanent-local t) |
|
|
|
|
|
(if (not (assq 'enriched-mode minor-mode-alist)) |
|
|
(setq minor-mode-alist |
|
|
(cons '(enriched-mode " Enriched") |
|
|
minor-mode-alist))) |
|
144 |
|
|
145 |
(defcustom enriched-mode-hook nil |
(defcustom enriched-mode-hook nil |
146 |
"Functions to run when entering Enriched mode. |
"Hook run after entering/leaving Enriched mode. |
147 |
If you set variables in this hook, you should arrange for them to be restored |
If you set variables in this hook, you should arrange for them to be restored |
148 |
to their old values if you leave Enriched mode. One way to do this is to add |
to their old values if you leave Enriched mode. One way to do this is to add |
149 |
them and their old values to `enriched-old-bindings'." |
them and their old values to `enriched-old-bindings'." |
159 |
;;; Define the mode |
;;; Define the mode |
160 |
;;; |
;;; |
161 |
|
|
162 |
|
(put 'enriched-mode 'permanent-local t) |
163 |
;;;###autoload |
;;;###autoload |
164 |
(defun enriched-mode (&optional arg) |
(define-minor-mode enriched-mode |
165 |
"Minor mode for editing text/enriched files. |
"Minor mode for editing text/enriched files. |
166 |
These are files with embedded formatting information in the MIME standard |
These are files with embedded formatting information in the MIME standard |
167 |
text/enriched format. |
text/enriched format. |
168 |
Turning the mode on runs `enriched-mode-hook'. |
Turning the mode on runs `enriched-mode-hook'. |
169 |
|
|
170 |
More information about Enriched mode is available in the file |
More information about Enriched mode is available in the file |
171 |
etc/enriched.doc in the Emacs distribution directory. |
etc/enriched.doc in the Emacs distribution directory. |
172 |
|
|
173 |
Commands: |
Commands: |
174 |
|
|
175 |
\\<enriched-mode-map>\\{enriched-mode-map}" |
\\<enriched-mode-map>\\{enriched-mode-map}" |
176 |
(interactive "P") |
nil " Enriched" nil |
177 |
(let ((mod (buffer-modified-p))) |
(cond ((null enriched-mode) |
178 |
(cond ((or (<= (prefix-numeric-value arg) 0) |
;; Turn mode off |
179 |
(and enriched-mode (null arg))) |
(setq buffer-file-format (delq 'text/enriched buffer-file-format)) |
180 |
;; Turn mode off |
;; restore old variable values |
181 |
(setq enriched-mode nil) |
(while enriched-old-bindings |
182 |
(setq buffer-file-format (delq 'text/enriched buffer-file-format)) |
(set (pop enriched-old-bindings) (pop enriched-old-bindings)))) |
183 |
;; restore old variable values |
|
184 |
(while enriched-old-bindings |
((memq 'text/enriched buffer-file-format) |
185 |
(funcall 'set (car enriched-old-bindings) |
;; Mode already on; do nothing. |
186 |
(car (cdr enriched-old-bindings))) |
nil) |
187 |
(setq enriched-old-bindings (cdr (cdr enriched-old-bindings))))) |
|
188 |
|
(t ; Turn mode on |
189 |
(enriched-mode nil) ; Mode already on; do nothing. |
(push 'text/enriched buffer-file-format) |
190 |
|
;; Save old variable values before we change them. |
191 |
(t (setq enriched-mode t) ; Turn mode on |
;; These will be restored if we exit Enriched mode. |
192 |
(add-to-list 'buffer-file-format 'text/enriched) |
(setq enriched-old-bindings |
193 |
;; Save old variable values before we change them. |
(list 'buffer-display-table buffer-display-table |
194 |
;; These will be restored if we exit Enriched mode. |
'indent-line-function indent-line-function |
195 |
(setq enriched-old-bindings |
'default-text-properties default-text-properties)) |
196 |
(list 'buffer-display-table buffer-display-table |
(make-local-variable 'indent-line-function) |
197 |
'indent-line-function indent-line-function |
(make-local-variable 'default-text-properties) |
198 |
'default-text-properties default-text-properties)) |
(setq indent-line-function 'indent-to-left-margin ;WHY?? -sm |
199 |
(make-local-variable 'indent-line-function) |
buffer-display-table enriched-display-table) |
200 |
(make-local-variable 'default-text-properties) |
(use-hard-newlines 1 nil) |
201 |
(setq indent-line-function 'indent-to-left-margin |
(let ((sticky (plist-get default-text-properties 'front-sticky)) |
202 |
buffer-display-table enriched-display-table) |
(p enriched-par-props)) |
203 |
(use-hard-newlines 1 nil) |
(dolist (x p) |
204 |
(let ((sticky (plist-get default-text-properties 'front-sticky)) |
(add-to-list 'sticky x)) |
205 |
(p enriched-par-props)) |
(if sticky |
206 |
(while p |
(setq default-text-properties |
207 |
(add-to-list 'sticky (car p)) |
(plist-put default-text-properties |
208 |
(setq p (cdr p))) |
'front-sticky sticky))))))) |
|
(if sticky |
|
|
(setq default-text-properties |
|
|
(plist-put default-text-properties |
|
|
'front-sticky sticky)))) |
|
|
(run-hooks 'enriched-mode-hook))) |
|
|
(set-buffer-modified-p mod) |
|
|
(force-mode-line-update))) |
|
209 |
|
|
210 |
;;; |
;;; |
211 |
;;; Keybindings |
;;; Keybindings |