aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2004-09-19 00:12:43 +0000
committerLuc Teirlinck2004-09-19 00:12:43 +0000
commit609ee2ff4cafda1c975628316f03a3840df154b8 (patch)
tree77a3ad889ea957ec3dcd96f67d6e0ea23e81ef22
parente174f8db476c35f0eaa8b281b2e8618b02595f6c (diff)
downloademacs-609ee2ff4cafda1c975628316f03a3840df154b8.tar.gz
emacs-609ee2ff4cafda1c975628316f03a3840df154b8.zip
(enriched-rerun-flag): New variable.
(enriched-before-change-major-mode): New function. Add it to `change-major-mode-hook'. (enriched-after-change-major-mode): New function. Add it to `after-change-major-mode-hook'. (enriched-mode): Make it work correctly if called from `after-change-major-mode-hook'. No longer set `indent-line-function'.
-rw-r--r--lisp/textmodes/enriched.el34
1 files changed, 25 insertions, 9 deletions
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el
index 531fe7d95df..f25bec2d841 100644
--- a/lisp/textmodes/enriched.el
+++ b/lisp/textmodes/enriched.el
@@ -1,6 +1,6 @@
1;;; enriched.el --- read and save files in text/enriched format 1;;; enriched.el --- read and save files in text/enriched format
2 2
3;; Copyright (c) 1994, 1995, 1996, 2002 Free Software Foundation, Inc. 3;; Copyright (c) 1994, 1995, 1996, 2002, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Boris Goldowsky <boris@gnu.org> 5;; Author: Boris Goldowsky <boris@gnu.org>
6;; Keywords: wp, faces 6;; Keywords: wp, faces
@@ -141,7 +141,6 @@ Any property that is neither on this list nor dealt with by
141 141
142;;; Internal variables 142;;; Internal variables
143 143
144
145(defcustom enriched-mode-hook nil 144(defcustom enriched-mode-hook nil
146 "Hook run after entering/leaving Enriched mode. 145 "Hook run after entering/leaving Enriched mode.
147If you set variables in this hook, you should arrange for them to be restored 146If you set variables in this hook, you should arrange for them to be restored
@@ -155,6 +154,11 @@ them and their old values to `enriched-old-bindings'."
155The value is a list of \(VAR VALUE VAR VALUE...).") 154The value is a list of \(VAR VALUE VAR VALUE...).")
156(make-variable-buffer-local 'enriched-old-bindings) 155(make-variable-buffer-local 'enriched-old-bindings)
157 156
157;; Technical internal variable. Bound to t if `enriched-mode' is
158;; being rerun by a major mode to allow it to restore buffer-local
159;; variables and to correctly update `enriched-old-bindings'.
160(defvar enriched-rerun-flag nil)
161
158;;; 162;;;
159;;; Define the mode 163;;; Define the mode
160;;; 164;;;
@@ -181,23 +185,21 @@ Commands:
181 (while enriched-old-bindings 185 (while enriched-old-bindings
182 (set (pop enriched-old-bindings) (pop enriched-old-bindings)))) 186 (set (pop enriched-old-bindings) (pop enriched-old-bindings))))
183 187
184 ((memq 'text/enriched buffer-file-format) 188 ((and (memq 'text/enriched buffer-file-format)
189 (not enriched-rerun-flag))
185 ;; Mode already on; do nothing. 190 ;; Mode already on; do nothing.
186 nil) 191 nil)
187 192
188 (t ; Turn mode on 193 (t ; Turn mode on
189 (push 'text/enriched buffer-file-format) 194 (add-to-list 'buffer-file-format 'text/enriched)
190 ;; Save old variable values before we change them. 195 ;; Save old variable values before we change them.
191 ;; These will be restored if we exit Enriched mode. 196 ;; These will be restored if we exit Enriched mode.
192 (setq enriched-old-bindings 197 (setq enriched-old-bindings
193 (list 'buffer-display-table buffer-display-table 198 (list 'buffer-display-table buffer-display-table
194 'indent-line-function indent-line-function
195 'default-text-properties default-text-properties)) 199 'default-text-properties default-text-properties))
196 (make-local-variable 'indent-line-function)
197 (make-local-variable 'default-text-properties) 200 (make-local-variable 'default-text-properties)
198 (setq indent-line-function 'indent-to-left-margin ;WHY?? -sm 201 (setq buffer-display-table enriched-display-table)
199 buffer-display-table enriched-display-table) 202 (use-hard-newlines 1 (if enriched-rerun-flag 'never nil))
200 (use-hard-newlines 1 nil)
201 (let ((sticky (plist-get default-text-properties 'front-sticky)) 203 (let ((sticky (plist-get default-text-properties 'front-sticky))
202 (p enriched-par-props)) 204 (p enriched-par-props))
203 (dolist (x p) 205 (dolist (x p)
@@ -207,6 +209,20 @@ Commands:
207 (plist-put default-text-properties 209 (plist-put default-text-properties
208 'front-sticky sticky))))))) 210 'front-sticky sticky)))))))
209 211
212(defun enriched-before-change-major-mode ()
213 (when enriched-mode
214 (while enriched-old-bindings
215 (set (pop enriched-old-bindings) (pop enriched-old-bindings)))))
216
217(add-hook 'change-major-mode-hook 'enriched-before-change-major-mode)
218
219(defun enriched-after-change-major-mode ()
220 (when enriched-mode
221 (let ((enriched-rerun-flag t))
222 (enriched-mode 1))))
223
224(add-hook 'after-change-major-mode-hook 'enriched-after-change-major-mode)
225
210;;; 226;;;
211;;; Keybindings 227;;; Keybindings
212;;; 228;;;