/[emacs]/emacs/lisp/textmodes/enriched.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/enriched.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3.2.2 by miles, Tue Jul 6 10:26:56 2004 UTC revision 1.3.2.3 by miles, Wed Oct 6 05:21:59 2004 UTC
# Line 1  Line 1 
1  ;;; enriched.el --- read and save files in text/enriched format  ;;; enriched.el --- read and save files in text/enriched format
2    
3  ;; Copyright (c) 1994, 1995, 1996, 2002 Free Software Foundation, Inc.  ;; Copyright (c) 1994, 1995, 1996, 2002, 2004 Free Software Foundation, Inc.
4    
5  ;; Author: Boris Goldowsky <boris@gnu.org>  ;; Author: Boris Goldowsky <boris@gnu.org>
6  ;; Keywords: wp, faces  ;; Keywords: wp, faces
# Line 141  Any property that is neither on this lis Line 141  Any property that is neither on this lis
141    
142  ;;; Internal variables  ;;; Internal variables
143    
   
144  (defcustom enriched-mode-hook nil  (defcustom enriched-mode-hook nil
145    "Hook run after entering/leaving Enriched mode.    "Hook run after entering/leaving Enriched mode.
146  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
# Line 155  them and their old values to `enriched-o Line 154  them and their old values to `enriched-o
154  The value is a list of \(VAR VALUE VAR VALUE...).")  The value is a list of \(VAR VALUE VAR VALUE...).")
155  (make-variable-buffer-local 'enriched-old-bindings)  (make-variable-buffer-local 'enriched-old-bindings)
156    
157    ;; The next variable is buffer local if and only if Enriched mode is
158    ;; enabled.  The buffer local value records whether
159    ;; `default-text-properties' should remain buffer local when disabling
160    ;; Enriched mode.  For technical reasons, the default value should be t.
161    (defvar enriched-default-text-properties-local-flag t)
162    
163    ;; Technical internal variable.  Bound to t if `enriched-mode' is
164    ;; being rerun by a major mode to allow it to restore buffer-local
165    ;; variables and to correctly update `enriched-old-bindings'.
166    (defvar enriched-rerun-flag nil)
167    
168  ;;;  ;;;
169  ;;; Define the mode  ;;; Define the mode
170  ;;;  ;;;
# Line 165  The value is a list of \(VAR VALUE VAR V Line 175  The value is a list of \(VAR VALUE VAR V
175    "Minor mode for editing text/enriched files.    "Minor mode for editing text/enriched files.
176  These are files with embedded formatting information in the MIME standard  These are files with embedded formatting information in the MIME standard
177  text/enriched format.  text/enriched format.
178  Turning the mode on runs `enriched-mode-hook'.  Turning the mode on or off runs `enriched-mode-hook'.
179    
180  More information about Enriched mode is available in the file  More information about Enriched mode is available in the file
181  etc/enriched.doc in the Emacs distribution directory.  etc/enriched.doc in the Emacs distribution directory.
# Line 179  Commands: Line 189  Commands:
189           (setq buffer-file-format (delq 'text/enriched buffer-file-format))           (setq buffer-file-format (delq 'text/enriched buffer-file-format))
190           ;; restore old variable values           ;; restore old variable values
191           (while enriched-old-bindings           (while enriched-old-bindings
192             (set (pop enriched-old-bindings) (pop enriched-old-bindings))))             (set (pop enriched-old-bindings) (pop enriched-old-bindings)))
193             (unless enriched-default-text-properties-local-flag
194               (kill-local-variable 'default-text-properties))
195             (kill-local-variable 'enriched-default-text-properties-local-flag)
196             (unless use-hard-newlines (use-hard-newlines 0)))
197    
198          ((memq 'text/enriched buffer-file-format)          ((and (memq 'text/enriched buffer-file-format)
199                  (not enriched-rerun-flag))
200           ;; Mode already on; do nothing.           ;; Mode already on; do nothing.
201           nil)           nil)
202    
203          (t                              ; Turn mode on          (t                              ; Turn mode on
204           (push 'text/enriched buffer-file-format)           (add-to-list 'buffer-file-format 'text/enriched)
205           ;; Save old variable values before we change them.           ;; Save old variable values before we change them.
206           ;; These will be restored if we exit Enriched mode.           ;; These will be restored if we exit Enriched mode.
207           (setq enriched-old-bindings           (setq enriched-old-bindings
208                 (list 'buffer-display-table buffer-display-table                 (list 'buffer-display-table buffer-display-table
209                       'indent-line-function indent-line-function                       'default-text-properties default-text-properties
210                       'default-text-properties default-text-properties))                       'use-hard-newlines use-hard-newlines))
211           (make-local-variable 'indent-line-function)           (make-local-variable 'enriched-default-text-properties-local-flag)
212             (setq enriched-default-text-properties-local-flag
213                   (local-variable-p 'default-text-properties))
214           (make-local-variable 'default-text-properties)           (make-local-variable 'default-text-properties)
215           (setq indent-line-function 'indent-to-left-margin ;WHY??  -sm           (setq buffer-display-table  enriched-display-table)
216                 buffer-display-table  enriched-display-table)           (use-hard-newlines 1 (if enriched-rerun-flag 'never nil))
          (use-hard-newlines 1 nil)  
217           (let ((sticky (plist-get default-text-properties 'front-sticky))           (let ((sticky (plist-get default-text-properties 'front-sticky))
218                 (p enriched-par-props))                 (p enriched-par-props))
219             (dolist (x p)             (dolist (x p)
# Line 207  Commands: Line 223  Commands:
223                       (plist-put default-text-properties                       (plist-put default-text-properties
224                                  'front-sticky sticky)))))))                                  'front-sticky sticky)))))))
225    
226    (defun enriched-before-change-major-mode ()
227      (when enriched-mode
228        (while enriched-old-bindings
229          (set (pop enriched-old-bindings) (pop enriched-old-bindings)))))
230    
231    (add-hook 'change-major-mode-hook 'enriched-before-change-major-mode)
232    
233    (defun enriched-after-change-major-mode ()
234      (when enriched-mode
235        (let ((enriched-rerun-flag t))
236          (enriched-mode 1))))
237    
238    (add-hook 'after-change-major-mode-hook 'enriched-after-change-major-mode)
239    
240  ;;;  ;;;
241  ;;; Keybindings  ;;; Keybindings
242  ;;;  ;;;

Legend:
Removed from v.1.3.2.2  
changed lines
  Added in v.1.3.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26