;;; 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.
: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.
(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.
(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)
"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)
(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)
(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)))
(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)
(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