]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/eieio-base.el
When running under emacs -q, always refuse to save the customisations, even if the...
[gnu-emacs] / lisp / emacs-lisp / eieio-base.el
index 6bd09a778c3e95fff5d7e9b4564dbe2c33ff51f1..139f5e6a4ce8365438db88d5e70490f5775563fe 100644 (file)
@@ -1,11 +1,12 @@
 ;;; eieio-base.el --- Base classes for EIEIO.
 
-;;; Copyright (C) 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009
+;;; Copyright (C) 2000-2002, 2004-2005, 2007-2011
 ;;; Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <zappo@gnu.org>
 ;; Version: 0.2
 ;; Keywords: OO, lisp
+;; Package: eieio
 
 ;; This file is part of GNU Emacs.
 
@@ -42,7 +43,7 @@
                    :type eieio-instance-inheritor-child
                    :documentation
                    "The parent of this instance.
-If a slot of this class is reference, and is unbound, then  the parent
+If a slot of this class is referenced, and is unbound, then the parent
 is checked for a value.")
    )
   "This special class can enable instance inheritance.
@@ -53,7 +54,7 @@ not been set, use values from the parent."
 
 (defmethod slot-unbound ((object eieio-instance-inheritor) class slot-name fn)
   "If a slot OBJECT in this CLASS is unbound, try to inherit, or throw a signal.
-SLOT-NAME, is the offending slot.  FN is the function signalling the error."
+SLOT-NAME is the offending slot.  FN is the function signalling the error."
   (if (slot-boundp object 'parent-instance)
       ;; It may not look like it, but this line recurses back into this
       ;; method if the parent instance's slot is unbound.
@@ -85,9 +86,9 @@ All slots are unbound, except those initialized with PARAMS."
 
 (defmethod eieio-instance-inheritor-slot-boundp ((object eieio-instance-inheritor)
                                                slot)
-  "Non-nil if the instance inheritor OBJECT's SLOT is bound.
-See `slot-boundp' for for details on binding slots.
-The instance inheritor uses unbound slots as a way cascading cloned
+  "Return non-nil if the instance inheritor OBJECT's SLOT is bound.
+See `slot-boundp' for details on binding slots.
+The instance inheritor uses unbound slots as a way of cascading cloned
 slot values, so testing for a slot being bound requires extra steps
 for this kind of object."
   (if (slot-boundp object slot)
@@ -150,7 +151,7 @@ Returns the first match."
              "The only instance of this class that will be instantiated.
 Multiple calls to `make-instance' will return this object."))
   "This special class causes subclasses to be singletons.
-A singleton is a class which will only ever have one instace."
+A singleton is a class which will only ever have one instance."
   :abstract t)
 
 (defmethod constructor :STATIC ((class eieio-singleton) name &rest slots)
@@ -213,7 +214,7 @@ specified will not be saved."
 
 (defmethod eieio-persistent-save-interactive ((this eieio-persistent) prompt
                                              &optional name)
-  "Perpare to save THIS.  Use in an `interactive' statement.
+  "Prepare to save THIS.  Use in an `interactive' statement.
 Query user for file name with PROMPT if THIS does not yet specify
 a file.  Optional argument NAME specifies a default file name."
   (unless (slot-boundp this 'file)
@@ -230,8 +231,7 @@ a file.  Optional argument NAME specifies a default file name."
        (buffstr nil))
     (unwind-protect
        (progn
-         (save-excursion
-           (set-buffer (get-buffer-create " *tmp eieio read*"))
+         (with-current-buffer (get-buffer-create " *tmp eieio read*")
            (insert-file-contents filename nil nil nil t)
            (goto-char (point-min))
            (setq buffstr (buffer-string)))
@@ -273,7 +273,11 @@ instance."
                        (eieio-persistent-path-relative this file)
                      (file-name-nondirectory cfn)))
              (object-write this (oref this file-header-line)))
-           (let ((backup-inhibited (not (oref this do-backups))))
+           (let ((backup-inhibited (not (oref this do-backups)))
+                 (cs (car (find-coding-systems-region
+                           (point-min) (point-max)))))
+             (unless (eq cs 'undecided)
+               (setq buffer-file-coding-system cs))
              ;; Old way - write file.  Leaves message behind.
              ;;(write-file cfn nil)
 
@@ -306,9 +310,9 @@ access to it."
 
 (defmethod slot-missing ((obj eieio-named)
                         slot-name operation &optional new-value)
-  "Called when a on-existant slot is accessed.
+  "Called when a non-existent slot is accessed.
 For variable `eieio-named', provide an imaginary `object-name' slot.
-Argument OBJ is the Named object.
+Argument OBJ is the named object.
 Argument SLOT-NAME is the slot that was attempted to be accessed.
 OPERATION is the type of access, such as `oref' or `oset'.
 NEW-VALUE is the value that was being set into SLOT if OPERATION were