]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/enriched.el
Merge from trunk
[gnu-emacs] / lisp / textmodes / enriched.el
index f25bec2d84188e8f2845f614531ee89e0e0afcdf..64eb83f817809f36b1a0004dbf0e341a8f34bbbc 100644 (file)
@@ -1,16 +1,17 @@
 ;;; enriched.el --- read and save files in text/enriched format
 
-;; Copyright (c) 1994, 1995, 1996, 2002, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <boris@gnu.org>
 ;; Keywords: wp, faces
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -47,7 +46,7 @@
 ;;;
 
 (defgroup enriched nil
-  "Read and save files in text/enriched format"
+  "Read and save files in text/enriched format."
   :group 'wp)
 
 (defcustom enriched-verbose t
@@ -65,7 +64,7 @@
 (defface fixed
   '((t (:weight bold)))
   "Face used for text that must be shown in fixed width.
-Currently, emacs can only display fixed-width fonts, but this may change.
+Currently, Emacs can only display fixed-width fonts, but this may change.
 This face is used for text specifically marked as fixed-width, for example
 in text/enriched files."
   :group 'enriched)
@@ -102,7 +101,7 @@ expression, which is evaluated to get the string to insert.")
 (defconst enriched-annotation-regexp "<\\(/\\)?\\([-A-Za-z0-9]+\\)>"
   "Regular expression matching enriched-text annotations.")
 
-(defconst enriched-translations
+(defvar enriched-translations
   '((face          (bold-italic "bold" "italic")
                   (bold        "bold")
                   (italic      "italic")
@@ -154,6 +153,12 @@ them and their old values to `enriched-old-bindings'."
 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'.
@@ -169,7 +174,7 @@ The value is a list of \(VAR VALUE VAR VALUE...).")
   "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'.
+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.
@@ -177,13 +182,17 @@ etc/enriched.doc in the Emacs distribution directory.
 Commands:
 
 \\{enriched-mode-map}"
-  nil " Enriched" nil
+  :group 'enriched :lighter " Enriched"
   (cond ((null enriched-mode)
         ;; Turn mode off
         (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))))
+          (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))
@@ -196,7 +205,11 @@ Commands:
         ;; 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))
+                    '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))
@@ -238,14 +251,15 @@ Commands:
          (cons (cons 'enriched-mode enriched-mode-map)
                minor-mode-map-alist)))
 
-(define-key enriched-mode-map "\C-a" 'beginning-of-line-text)
+(define-key enriched-mode-map [remap move-beginning-of-line] 'beginning-of-line-text)
 (define-key enriched-mode-map "\C-m" 'reindent-then-newline-and-indent)
-(define-key enriched-mode-map "\C-j" 'reindent-then-newline-and-indent)
+(define-key enriched-mode-map
+  [remap newline-and-indent] 'reindent-then-newline-and-indent)
 (define-key enriched-mode-map "\M-j" 'facemenu-justification-menu)
 (define-key enriched-mode-map "\M-S" 'set-justification-center)
 (define-key enriched-mode-map "\C-x\t" 'increase-left-margin)
-(define-key enriched-mode-map "\C-c\C-l" 'set-left-margin)
-(define-key enriched-mode-map "\C-c\C-r" 'set-right-margin)
+(define-key enriched-mode-map "\C-c[" 'set-left-margin)
+(define-key enriched-mode-map "\C-c]" 'set-right-margin)
 
 ;;;
 ;;; Some functions dealing with text-properties, especially indentation
@@ -488,5 +502,5 @@ the range of text to assign text property SYMBOL with value VALUE."
       (message "Warning: invalid <x-display> parameter %s" param))
     (list start end 'display prop)))
 
-;;; arch-tag: 05cae488-3fea-45cd-ac29-5b02cb64e42b
+;; arch-tag: 05cae488-3fea-45cd-ac29-5b02cb64e42b
 ;;; enriched.el ends here