[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/textmodes/enriched.el [lexbind]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/textmodes/enriched.el [lexbind] |
Date: |
Wed, 06 Oct 2004 01:44:27 -0400 |
Index: emacs/lisp/textmodes/enriched.el
diff -c emacs/lisp/textmodes/enriched.el:1.3.2.2
emacs/lisp/textmodes/enriched.el:1.3.2.3
*** emacs/lisp/textmodes/enriched.el:1.3.2.2 Tue Jul 6 10:26:56 2004
--- emacs/lisp/textmodes/enriched.el Wed Oct 6 05:21:59 2004
***************
*** 1,6 ****
;;; enriched.el --- read and save files in text/enriched format
! ;; Copyright (c) 1994, 1995, 1996, 2002 Free Software Foundation, Inc.
;; Author: Boris Goldowsky <address@hidden>
;; Keywords: wp, faces
--- 1,6 ----
;;; enriched.el --- read and save files in text/enriched format
! ;; Copyright (c) 1994, 1995, 1996, 2002, 2004 Free Software Foundation, Inc.
;; Author: Boris Goldowsky <address@hidden>
;; Keywords: wp, faces
***************
*** 141,147 ****
;;; Internal variables
-
(defcustom enriched-mode-hook nil
"Hook run after entering/leaving Enriched mode.
If you set variables in this hook, you should arrange for them to be restored
--- 141,146 ----
***************
*** 155,160 ****
--- 154,170 ----
The value is a list of \(VAR VALUE VAR VALUE...).")
(make-variable-buffer-local 'enriched-old-bindings)
+ ;; The next variable is buffer local if and only if Enriched mode is
+ ;; enabled. The buffer local value records whether
+ ;; `default-text-properties' should remain buffer local when disabling
+ ;; Enriched mode. For technical reasons, the default value should be t.
+ (defvar enriched-default-text-properties-local-flag t)
+
+ ;; Technical internal variable. Bound to t if `enriched-mode' is
+ ;; being rerun by a major mode to allow it to restore buffer-local
+ ;; variables and to correctly update `enriched-old-bindings'.
+ (defvar enriched-rerun-flag nil)
+
;;;
;;; Define the mode
;;;
***************
*** 165,171 ****
"Minor mode for editing text/enriched files.
These are files with embedded formatting information in the MIME standard
text/enriched format.
! Turning the mode on runs `enriched-mode-hook'.
More information about Enriched mode is available in the file
etc/enriched.doc in the Emacs distribution directory.
--- 175,181 ----
"Minor mode for editing text/enriched files.
These are files with embedded formatting information in the MIME standard
text/enriched format.
! Turning the mode on or off runs `enriched-mode-hook'.
More information about Enriched mode is available in the file
etc/enriched.doc in the Emacs distribution directory.
***************
*** 179,203 ****
(setq buffer-file-format (delq 'text/enriched buffer-file-format))
;; restore old variable values
(while enriched-old-bindings
! (set (pop enriched-old-bindings) (pop enriched-old-bindings))))
! ((memq 'text/enriched buffer-file-format)
;; Mode already on; do nothing.
nil)
(t ; Turn mode on
! (push 'text/enriched buffer-file-format)
;; Save old variable values before we change them.
;; These will be restored if we exit Enriched mode.
(setq enriched-old-bindings
(list 'buffer-display-table buffer-display-table
! 'indent-line-function indent-line-function
! 'default-text-properties default-text-properties))
! (make-local-variable 'indent-line-function)
(make-local-variable 'default-text-properties)
! (setq indent-line-function 'indent-to-left-margin ;WHY?? -sm
! buffer-display-table enriched-display-table)
! (use-hard-newlines 1 nil)
(let ((sticky (plist-get default-text-properties 'front-sticky))
(p enriched-par-props))
(dolist (x p)
--- 189,219 ----
(setq buffer-file-format (delq 'text/enriched buffer-file-format))
;; restore old variable values
(while enriched-old-bindings
! (set (pop enriched-old-bindings) (pop enriched-old-bindings)))
! (unless enriched-default-text-properties-local-flag
! (kill-local-variable 'default-text-properties))
! (kill-local-variable 'enriched-default-text-properties-local-flag)
! (unless use-hard-newlines (use-hard-newlines 0)))
! ((and (memq 'text/enriched buffer-file-format)
! (not enriched-rerun-flag))
;; Mode already on; do nothing.
nil)
(t ; Turn mode on
! (add-to-list 'buffer-file-format 'text/enriched)
;; Save old variable values before we change them.
;; These will be restored if we exit Enriched mode.
(setq enriched-old-bindings
(list 'buffer-display-table buffer-display-table
! 'default-text-properties default-text-properties
! 'use-hard-newlines use-hard-newlines))
! (make-local-variable 'enriched-default-text-properties-local-flag)
! (setq enriched-default-text-properties-local-flag
! (local-variable-p 'default-text-properties))
(make-local-variable 'default-text-properties)
! (setq buffer-display-table enriched-display-table)
! (use-hard-newlines 1 (if enriched-rerun-flag 'never nil))
(let ((sticky (plist-get default-text-properties 'front-sticky))
(p enriched-par-props))
(dolist (x p)
***************
*** 207,212 ****
--- 223,242 ----
(plist-put default-text-properties
'front-sticky sticky)))))))
+ (defun enriched-before-change-major-mode ()
+ (when enriched-mode
+ (while enriched-old-bindings
+ (set (pop enriched-old-bindings) (pop enriched-old-bindings)))))
+
+ (add-hook 'change-major-mode-hook 'enriched-before-change-major-mode)
+
+ (defun enriched-after-change-major-mode ()
+ (when enriched-mode
+ (let ((enriched-rerun-flag t))
+ (enriched-mode 1))))
+
+ (add-hook 'after-change-major-mode-hook 'enriched-after-change-major-mode)
+
;;;
;;; Keybindings
;;;