diff options
| author | Stefan Monnier | 2014-10-17 01:09:24 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-10-17 01:09:24 -0400 |
| commit | 942501730f55719f1d3cda9f476e00f5c497259c (patch) | |
| tree | 42395325d99dca1891b759881b7fe9b6b28e4382 | |
| parent | 60727a5494698b4c6bfa24bab72f75bb7d07a755 (diff) | |
| download | emacs-942501730f55719f1d3cda9f476e00f5c497259c.tar.gz emacs-942501730f55719f1d3cda9f476e00f5c497259c.zip | |
* lisp/emacs-lisp/eieio-base.el: Use lexical-binding and cl-lib.
* lisp/emacs-lisp/eieio-core.el: Use lexical-binding and cl-lib.
(list-of): New type.
(eieio--typep): Remove.
(eieio-perform-slot-validation): Use cl-typep instead.
* lisp/emacs-lisp/eieio.el: Use lexical-binding drop non-GV fallback.
(defclass, defgeneric, defmethod): Add doc-string position.
(with-slots): Require cl-lib.
* lisp/emacs-lisp/cl-macs.el (cl--make-type-test): Avoid ((lambda ..) ..).
| -rw-r--r-- | lisp/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 36 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio-base.el | 11 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio-core.el | 107 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio.el | 47 |
5 files changed, 96 insertions, 126 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0b3d8d9a87b..b69ab31db3d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,10 +1,25 @@ | |||
| 1 | 2014-10-17 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/eieio.el: Use lexical-binding drop non-GV fallback. | ||
| 4 | (defclass, defgeneric, defmethod): Add doc-string position. | ||
| 5 | (with-slots): Require cl-lib. | ||
| 6 | |||
| 7 | * emacs-lisp/eieio-core.el: Use lexical-binding and cl-lib. | ||
| 8 | (list-of): New type. | ||
| 9 | (eieio--typep): Remove. | ||
| 10 | (eieio-perform-slot-validation): Use cl-typep instead. | ||
| 11 | |||
| 12 | * emacs-lisp/eieio-base.el: Use lexical-binding and cl-lib. | ||
| 13 | |||
| 14 | * emacs-lisp/cl-macs.el (cl--make-type-test): Avoid ((lambda ..) ..). | ||
| 15 | |||
| 1 | 2014-10-16 Alan Mackenzie <acm@muc.de> | 16 | 2014-10-16 Alan Mackenzie <acm@muc.de> |
| 2 | 17 | ||
| 3 | Trigger showing when point is in the "periphery" of a line or just | 18 | Trigger showing when point is in the "periphery" of a line or just |
| 4 | inside a paren. | 19 | inside a paren. |
| 5 | * paren.el (show-paren-style, show-paren-delay) | 20 | * paren.el (show-paren-style, show-paren-delay) |
| 6 | (show-paren-priority, show-paren-ring-bell-on-mismatch): Remove | 21 | (show-paren-priority, show-paren-ring-bell-on-mismatch): |
| 7 | superfluous :group specifications. | 22 | Remove superfluous :group specifications. |
| 8 | (show-paren-when-point-inside-paren) | 23 | (show-paren-when-point-inside-paren) |
| 9 | (show-paren-when-point-in-periphery): New customizable variables. | 24 | (show-paren-when-point-in-periphery): New customizable variables. |
| 10 | (show-paren-highlight-openparen): Make into a defcustom. | 25 | (show-paren-highlight-openparen): Make into a defcustom. |
| @@ -532,7 +547,7 @@ | |||
| 532 | * term.el (term-mouse-paste): | 547 | * term.el (term-mouse-paste): |
| 533 | * mouse.el (mouse-yank-primary): Use gui-get-primary-selection. | 548 | * mouse.el (mouse-yank-primary): Use gui-get-primary-selection. |
| 534 | 549 | ||
| 535 | 2014-10-02 H. Dieter Wilhelm <dieter@duenenhof-wilhelm.de> (tiny change) | 550 | 2014-10-02 H. Dieter Wilhelm <dieter@duenenhof-wilhelm.de> |
| 536 | 551 | ||
| 537 | * calc/calc-help.el (calc-describe-thing): Quote strings | 552 | * calc/calc-help.el (calc-describe-thing): Quote strings |
| 538 | which could look like regexps. | 553 | which could look like regexps. |
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index e4a73d1a4de..8336a2443da 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el | |||
| @@ -822,7 +822,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 822 | "repeat" "while" "until" "always" "never" | 822 | "repeat" "while" "until" "always" "never" |
| 823 | "thereis" "collect" "append" "nconc" "sum" | 823 | "thereis" "collect" "append" "nconc" "sum" |
| 824 | "count" "maximize" "minimize" "if" "unless" | 824 | "count" "maximize" "minimize" "if" "unless" |
| 825 | "return"] form] | 825 | "return"] |
| 826 | form] | ||
| 826 | ;; Simple default, which covers 99% of the cases. | 827 | ;; Simple default, which covers 99% of the cases. |
| 827 | symbolp form))) | 828 | symbolp form))) |
| 828 | (if (not (memq t (mapcar #'symbolp | 829 | (if (not (memq t (mapcar #'symbolp |
| @@ -1136,7 +1137,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1136 | (if end | 1137 | (if end |
| 1137 | (push (list | 1138 | (push (list |
| 1138 | (if down (if excl '> '>=) (if excl '< '<=)) | 1139 | (if down (if excl '> '>=) (if excl '< '<=)) |
| 1139 | var (or end-var end)) cl--loop-body)) | 1140 | var (or end-var end)) |
| 1141 | cl--loop-body)) | ||
| 1140 | (push (list var (list (if down '- '+) var | 1142 | (push (list var (list (if down '- '+) var |
| 1141 | (or step-var step 1))) | 1143 | (or step-var step 1))) |
| 1142 | loop-for-steps))) | 1144 | loop-for-steps))) |
| @@ -1194,7 +1196,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1194 | (push (list temp-vec (pop cl--loop-args)) loop-for-bindings) | 1196 | (push (list temp-vec (pop cl--loop-args)) loop-for-bindings) |
| 1195 | (push (list temp-idx -1) loop-for-bindings) | 1197 | (push (list temp-idx -1) loop-for-bindings) |
| 1196 | (push `(< (setq ,temp-idx (1+ ,temp-idx)) | 1198 | (push `(< (setq ,temp-idx (1+ ,temp-idx)) |
| 1197 | (length ,temp-vec)) cl--loop-body) | 1199 | (length ,temp-vec)) |
| 1200 | cl--loop-body) | ||
| 1198 | (if (eq word 'across-ref) | 1201 | (if (eq word 'across-ref) |
| 1199 | (push (list var `(aref ,temp-vec ,temp-idx)) | 1202 | (push (list var `(aref ,temp-vec ,temp-idx)) |
| 1200 | cl--loop-symbol-macs) | 1203 | cl--loop-symbol-macs) |
| @@ -1370,7 +1373,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1370 | (if loop-for-sets | 1373 | (if loop-for-sets |
| 1371 | (push `(progn | 1374 | (push `(progn |
| 1372 | ,(cl--loop-let (nreverse loop-for-sets) 'setq ands) | 1375 | ,(cl--loop-let (nreverse loop-for-sets) 'setq ands) |
| 1373 | t) cl--loop-body)) | 1376 | t) |
| 1377 | cl--loop-body)) | ||
| 1374 | (if loop-for-steps | 1378 | (if loop-for-steps |
| 1375 | (push (cons (if ands 'cl-psetq 'setq) | 1379 | (push (cons (if ands 'cl-psetq 'setq) |
| 1376 | (apply 'append (nreverse loop-for-steps))) | 1380 | (apply 'append (nreverse loop-for-steps))) |
| @@ -1388,7 +1392,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1388 | (push `(progn (push ,what ,var) t) cl--loop-body) | 1392 | (push `(progn (push ,what ,var) t) cl--loop-body) |
| 1389 | (push `(progn | 1393 | (push `(progn |
| 1390 | (setq ,var (nconc ,var (list ,what))) | 1394 | (setq ,var (nconc ,var (list ,what))) |
| 1391 | t) cl--loop-body)))) | 1395 | t) |
| 1396 | cl--loop-body)))) | ||
| 1392 | 1397 | ||
| 1393 | ((memq word '(nconc nconcing append appending)) | 1398 | ((memq word '(nconc nconcing append appending)) |
| 1394 | (let ((what (pop cl--loop-args)) | 1399 | (let ((what (pop cl--loop-args)) |
| @@ -1403,7 +1408,9 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1403 | ,var) | 1408 | ,var) |
| 1404 | `(,(if (memq word '(nconc nconcing)) | 1409 | `(,(if (memq word '(nconc nconcing)) |
| 1405 | #'nconc #'append) | 1410 | #'nconc #'append) |
| 1406 | ,var ,what))) t) cl--loop-body))) | 1411 | ,var ,what))) |
| 1412 | t) | ||
| 1413 | cl--loop-body))) | ||
| 1407 | 1414 | ||
| 1408 | ((memq word '(concat concating)) | 1415 | ((memq word '(concat concating)) |
| 1409 | (let ((what (pop cl--loop-args)) | 1416 | (let ((what (pop cl--loop-args)) |
| @@ -1434,7 +1441,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1434 | (set `(setq ,var (if ,var (,func ,var ,temp) ,temp)))) | 1441 | (set `(setq ,var (if ,var (,func ,var ,temp) ,temp)))) |
| 1435 | (push `(progn ,(if (eq temp what) set | 1442 | (push `(progn ,(if (eq temp what) set |
| 1436 | `(let ((,temp ,what)) ,set)) | 1443 | `(let ((,temp ,what)) ,set)) |
| 1437 | t) cl--loop-body))) | 1444 | t) |
| 1445 | cl--loop-body))) | ||
| 1438 | 1446 | ||
| 1439 | ((eq word 'with) | 1447 | ((eq word 'with) |
| 1440 | (let ((bindings nil)) | 1448 | (let ((bindings nil)) |
| @@ -1505,7 +1513,8 @@ For more details, see Info node `(cl)Loop Facility'. | |||
| 1505 | (or cl--loop-result-var | 1513 | (or cl--loop-result-var |
| 1506 | (setq cl--loop-result-var (make-symbol "--cl-var--"))) | 1514 | (setq cl--loop-result-var (make-symbol "--cl-var--"))) |
| 1507 | (push `(setq ,cl--loop-result-var ,(pop cl--loop-args) | 1515 | (push `(setq ,cl--loop-result-var ,(pop cl--loop-args) |
| 1508 | ,cl--loop-finish-flag nil) cl--loop-body)) | 1516 | ,cl--loop-finish-flag nil) |
| 1517 | cl--loop-body)) | ||
| 1509 | 1518 | ||
| 1510 | (t | 1519 | (t |
| 1511 | ;; This is an advertised interface: (info "(cl)Other Clauses"). | 1520 | ;; This is an advertised interface: (info "(cl)Other Clauses"). |
| @@ -2398,7 +2407,8 @@ non-nil value, that slot cannot be set via `setf'. | |||
| 2398 | pred-form pred-check) | 2407 | pred-form pred-check) |
| 2399 | (if (stringp (car descs)) | 2408 | (if (stringp (car descs)) |
| 2400 | (push `(put ',name 'structure-documentation | 2409 | (push `(put ',name 'structure-documentation |
| 2401 | ,(pop descs)) forms)) | 2410 | ,(pop descs)) |
| 2411 | forms)) | ||
| 2402 | (setq descs (cons '(cl-tag-slot) | 2412 | (setq descs (cons '(cl-tag-slot) |
| 2403 | (mapcar (function (lambda (x) (if (consp x) x (list x)))) | 2413 | (mapcar (function (lambda (x) (if (consp x) x (list x)))) |
| 2404 | descs))) | 2414 | descs))) |
| @@ -2551,7 +2561,8 @@ non-nil value, that slot cannot be set via `setf'. | |||
| 2551 | (progn (push `(cl-defsubst ,predicate (cl-x) | 2561 | (progn (push `(cl-defsubst ,predicate (cl-x) |
| 2552 | ,(if (eq (car pred-form) 'and) | 2562 | ,(if (eq (car pred-form) 'and) |
| 2553 | (append pred-form '(t)) | 2563 | (append pred-form '(t)) |
| 2554 | `(and ,pred-form t))) forms) | 2564 | `(and ,pred-form t))) |
| 2565 | forms) | ||
| 2555 | (push (cons predicate 'error-free) side-eff))) | 2566 | (push (cons predicate 'error-free) side-eff))) |
| 2556 | (and copier | 2567 | (and copier |
| 2557 | (progn (push `(defun ,copier (x) (copy-sequence x)) forms) | 2568 | (progn (push `(defun ,copier (x) (copy-sequence x)) forms) |
| @@ -2568,7 +2579,8 @@ non-nil value, that slot cannot be set via `setf'. | |||
| 2568 | slots defaults))) | 2579 | slots defaults))) |
| 2569 | (push `(cl-defsubst ,name | 2580 | (push `(cl-defsubst ,name |
| 2570 | (&cl-defs '(nil ,@descs) ,@args) | 2581 | (&cl-defs '(nil ,@descs) ,@args) |
| 2571 | (,type ,@make)) forms) | 2582 | (,type ,@make)) |
| 2583 | forms) | ||
| 2572 | (if (cl--safe-expr-p `(progn ,@(mapcar #'cl-second descs))) | 2584 | (if (cl--safe-expr-p `(progn ,@(mapcar #'cl-second descs))) |
| 2573 | (push (cons name t) side-eff)))) | 2585 | (push (cons name t) side-eff)))) |
| 2574 | (if print-auto (nconc print-func (list '(princ ")" cl-s) t))) | 2586 | (if print-auto (nconc print-func (list '(princ ")" cl-s) t))) |
| @@ -2673,7 +2685,7 @@ Of course, we really can't know that for sure, so it's just a heuristic." | |||
| 2673 | (cdr type)))) | 2685 | (cdr type)))) |
| 2674 | ((memq (car type) '(member cl-member)) | 2686 | ((memq (car type) '(member cl-member)) |
| 2675 | `(and (cl-member ,val ',(cdr type)) t)) | 2687 | `(and (cl-member ,val ',(cdr type)) t)) |
| 2676 | ((eq (car type) 'satisfies) (list (cadr type) val)) | 2688 | ((eq (car type) 'satisfies) `(funcall #',(cadr type) ,val)) |
| 2677 | (t (error "Bad type spec: %s" type))))) | 2689 | (t (error "Bad type spec: %s" type))))) |
| 2678 | 2690 | ||
| 2679 | (defvar cl--object) | 2691 | (defvar cl--object) |
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 150724e6484..a1c2cb54a9e 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; eieio-base.el --- Base classes for EIEIO. | 1 | ;;; eieio-base.el --- Base classes for EIEIO. -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;;; Copyright (C) 2000-2002, 2004-2005, 2007-2014 Free Software | 3 | ;;; Copyright (C) 2000-2002, 2004-2005, 2007-2014 Free Software |
| 4 | ;;; Foundation, Inc. | 4 | ;;; Foundation, Inc. |
| @@ -31,7 +31,7 @@ | |||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (require 'eieio) | 33 | (require 'eieio) |
| 34 | (eval-when-compile (require 'cl)) ;FIXME: Use cl-lib! | 34 | (eval-when-compile (require 'cl-lib)) |
| 35 | 35 | ||
| 36 | ;;; eieio-instance-inheritor | 36 | ;;; eieio-instance-inheritor |
| 37 | ;; | 37 | ;; |
| @@ -52,7 +52,8 @@ a parent instance. When a slot in the child is referenced, and has | |||
| 52 | not been set, use values from the parent." | 52 | not been set, use values from the parent." |
| 53 | :abstract t) | 53 | :abstract t) |
| 54 | 54 | ||
| 55 | (defmethod slot-unbound ((object eieio-instance-inheritor) class slot-name fn) | 55 | (defmethod slot-unbound ((object eieio-instance-inheritor) |
| 56 | _class slot-name _fn) | ||
| 56 | "If a slot OBJECT in this CLASS is unbound, try to inherit, or throw a signal. | 57 | "If a slot OBJECT in this CLASS is unbound, try to inherit, or throw a signal. |
| 57 | SLOT-NAME is the offending slot. FN is the function signaling the error." | 58 | SLOT-NAME is the offending slot. FN is the function signaling the error." |
| 58 | (if (slot-boundp object 'parent-instance) | 59 | (if (slot-boundp object 'parent-instance) |
| @@ -118,7 +119,7 @@ a variable symbol used to store a list of all instances." | |||
| 118 | :abstract t) | 119 | :abstract t) |
| 119 | 120 | ||
| 120 | (defmethod initialize-instance :AFTER ((this eieio-instance-tracker) | 121 | (defmethod initialize-instance :AFTER ((this eieio-instance-tracker) |
| 121 | &rest slots) | 122 | &rest _slots) |
| 122 | "Make sure THIS is in our master list of this class. | 123 | "Make sure THIS is in our master list of this class. |
| 123 | Optional argument SLOTS are the initialization arguments." | 124 | Optional argument SLOTS are the initialization arguments." |
| 124 | ;; Theoretically, this is never called twice for a given instance. | 125 | ;; Theoretically, this is never called twice for a given instance. |
| @@ -154,7 +155,7 @@ Multiple calls to `make-instance' will return this object.")) | |||
| 154 | A singleton is a class which will only ever have one instance." | 155 | A singleton is a class which will only ever have one instance." |
| 155 | :abstract t) | 156 | :abstract t) |
| 156 | 157 | ||
| 157 | (defmethod constructor :STATIC ((class eieio-singleton) name &rest slots) | 158 | (defmethod constructor :STATIC ((class eieio-singleton) _name &rest _slots) |
| 158 | "Constructor for singleton CLASS. | 159 | "Constructor for singleton CLASS. |
| 159 | NAME and SLOTS initialize the new object. | 160 | NAME and SLOTS initialize the new object. |
| 160 | This constructor guarantees that no matter how many you request, | 161 | This constructor guarantees that no matter how many you request, |
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 76655caf65a..4637de5fd3e 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; eieio-core.el --- Core implementation for eieio | 1 | ;;; eieio-core.el --- Core implementation for eieio -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1995-1996, 1998-2014 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1995-1996, 1998-2014 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -31,7 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | ;;; Code: | 32 | ;;; Code: |
| 33 | 33 | ||
| 34 | (eval-when-compile (require 'cl)) ;FIXME: Use cl-lib! | 34 | (require 'cl-lib) |
| 35 | 35 | ||
| 36 | ;; Compatibility | 36 | ;; Compatibility |
| 37 | (if (fboundp 'compiled-function-arglist) | 37 | (if (fboundp 'compiled-function-arglist) |
| @@ -408,6 +408,12 @@ It creates an autoload function for CNAME's constructor." | |||
| 408 | (when (eq (car-safe (symbol-function cname)) 'autoload) | 408 | (when (eq (car-safe (symbol-function cname)) 'autoload) |
| 409 | (load-library (car (cdr (symbol-function cname)))))) | 409 | (load-library (car (cdr (symbol-function cname)))))) |
| 410 | 410 | ||
| 411 | (cl-deftype list-of (elem-type) | ||
| 412 | `(and list | ||
| 413 | (satisfies (lambda (list) | ||
| 414 | (cl-every (lambda (elem) (cl-typep elem ',elem-type)) | ||
| 415 | list))))) | ||
| 416 | |||
| 411 | (defun eieio-defclass (cname superclasses slots options-and-doc) | 417 | (defun eieio-defclass (cname superclasses slots options-and-doc) |
| 412 | ;; FIXME: Most of this should be moved to the `defclass' macro. | 418 | ;; FIXME: Most of this should be moved to the `defclass' macro. |
| 413 | "Define CNAME as a new subclass of SUPERCLASSES. | 419 | "Define CNAME as a new subclass of SUPERCLASSES. |
| @@ -476,7 +482,7 @@ See `defclass' for more information." | |||
| 476 | (setf (eieio--class-children (class-v (car pname))) | 482 | (setf (eieio--class-children (class-v (car pname))) |
| 477 | (cons cname (eieio--class-children (class-v (car pname)))))) | 483 | (cons cname (eieio--class-children (class-v (car pname)))))) |
| 478 | ;; Get custom groups, and store them into our local copy. | 484 | ;; Get custom groups, and store them into our local copy. |
| 479 | (mapc (lambda (g) (pushnew g groups :test #'equal)) | 485 | (mapc (lambda (g) (cl-pushnew g groups :test #'equal)) |
| 480 | (class-option (car pname) :custom-groups)) | 486 | (class-option (car pname) :custom-groups)) |
| 481 | ;; save parent in child | 487 | ;; save parent in child |
| 482 | (setf (eieio--class-parent newc) (cons (car pname) (eieio--class-parent newc)))) | 488 | (setf (eieio--class-parent newc) (cons (car pname) (eieio--class-parent newc)))) |
| @@ -553,8 +559,7 @@ See `defclass' for more information." | |||
| 553 | ;; test, so we can let typep have the CLOS documented behavior | 559 | ;; test, so we can let typep have the CLOS documented behavior |
| 554 | ;; while keeping our above predicate clean. | 560 | ;; while keeping our above predicate clean. |
| 555 | 561 | ||
| 556 | ;; It would be cleaner to use `defsetf' here, but that requires cl | 562 | ;; FIXME: It would be cleaner to use `cl-deftype' here. |
| 557 | ;; at runtime. | ||
| 558 | (put cname 'cl-deftype-handler | 563 | (put cname 'cl-deftype-handler |
| 559 | (list 'lambda () `(list 'satisfies (quote ,csym))))) | 564 | (list 'lambda () `(list 'satisfies (quote ,csym))))) |
| 560 | 565 | ||
| @@ -655,7 +660,7 @@ See `defclass' for more information." | |||
| 655 | prot initarg alloc 'defaultoverride skip-nil) | 660 | prot initarg alloc 'defaultoverride skip-nil) |
| 656 | 661 | ||
| 657 | ;; We need to id the group, and store them in a group list attribute. | 662 | ;; We need to id the group, and store them in a group list attribute. |
| 658 | (mapc (lambda (cg) (pushnew cg groups :test 'equal)) customg) | 663 | (mapc (lambda (cg) (cl-pushnew cg groups :test 'equal)) customg) |
| 659 | 664 | ||
| 660 | ;; Anyone can have an accessor function. This creates a function | 665 | ;; Anyone can have an accessor function. This creates a function |
| 661 | ;; of the specified name, and also performs a `defsetf' if applicable | 666 | ;; of the specified name, and also performs a `defsetf' if applicable |
| @@ -721,7 +726,7 @@ See `defclass' for more information." | |||
| 721 | (setf (eieio--class-public-d newc) (nreverse (eieio--class-public-d newc))) | 726 | (setf (eieio--class-public-d newc) (nreverse (eieio--class-public-d newc))) |
| 722 | (setf (eieio--class-public-doc newc) (nreverse (eieio--class-public-doc newc))) | 727 | (setf (eieio--class-public-doc newc) (nreverse (eieio--class-public-doc newc))) |
| 723 | (setf (eieio--class-public-type newc) | 728 | (setf (eieio--class-public-type newc) |
| 724 | (apply 'vector (nreverse (eieio--class-public-type newc)))) | 729 | (apply #'vector (nreverse (eieio--class-public-type newc)))) |
| 725 | (setf (eieio--class-public-custom newc) (nreverse (eieio--class-public-custom newc))) | 730 | (setf (eieio--class-public-custom newc) (nreverse (eieio--class-public-custom newc))) |
| 726 | (setf (eieio--class-public-custom-label newc) (nreverse (eieio--class-public-custom-label newc))) | 731 | (setf (eieio--class-public-custom-label newc) (nreverse (eieio--class-public-custom-label newc))) |
| 727 | (setf (eieio--class-public-custom-group newc) (nreverse (eieio--class-public-custom-group newc))) | 732 | (setf (eieio--class-public-custom-group newc) (nreverse (eieio--class-public-custom-group newc))) |
| @@ -732,11 +737,11 @@ See `defclass' for more information." | |||
| 732 | ;; The storage for class-class-allocation-type needs to be turned into | 737 | ;; The storage for class-class-allocation-type needs to be turned into |
| 733 | ;; a vector now. | 738 | ;; a vector now. |
| 734 | (setf (eieio--class-class-allocation-type newc) | 739 | (setf (eieio--class-class-allocation-type newc) |
| 735 | (apply 'vector (eieio--class-class-allocation-type newc))) | 740 | (apply #'vector (eieio--class-class-allocation-type newc))) |
| 736 | 741 | ||
| 737 | ;; Also, take class allocated values, and vectorize them for speed. | 742 | ;; Also, take class allocated values, and vectorize them for speed. |
| 738 | (setf (eieio--class-class-allocation-values newc) | 743 | (setf (eieio--class-class-allocation-values newc) |
| 739 | (apply 'vector (eieio--class-class-allocation-values newc))) | 744 | (apply #'vector (eieio--class-class-allocation-values newc))) |
| 740 | 745 | ||
| 741 | ;; Attach slot symbols into an obarray, and store the index of | 746 | ;; Attach slot symbols into an obarray, and store the index of |
| 742 | ;; this slot as the variable slot in this new symbol. We need to | 747 | ;; this slot as the variable slot in this new symbol. We need to |
| @@ -779,7 +784,7 @@ See `defclass' for more information." | |||
| 779 | (fset cname | 784 | (fset cname |
| 780 | `(lambda (newname &rest slots) | 785 | `(lambda (newname &rest slots) |
| 781 | ,(format "Create a new object with name NAME of class type %s" cname) | 786 | ,(format "Create a new object with name NAME of class type %s" cname) |
| 782 | (apply 'constructor ,cname newname slots))) | 787 | (apply #'constructor ,cname newname slots))) |
| 783 | ) | 788 | ) |
| 784 | 789 | ||
| 785 | ;; Set up a specialized doc string. | 790 | ;; Set up a specialized doc string. |
| @@ -798,7 +803,7 @@ See `defclass' for more information." | |||
| 798 | 803 | ||
| 799 | ;; We have a list of custom groups. Store them into the options. | 804 | ;; We have a list of custom groups. Store them into the options. |
| 800 | (let ((g (class-option-assoc options :custom-groups))) | 805 | (let ((g (class-option-assoc options :custom-groups))) |
| 801 | (mapc (lambda (cg) (pushnew cg g :test 'equal)) groups) | 806 | (mapc (lambda (cg) (cl-pushnew cg g :test 'equal)) groups) |
| 802 | (if (memq :custom-groups options) | 807 | (if (memq :custom-groups options) |
| 803 | (setcar (cdr (memq :custom-groups options)) g) | 808 | (setcar (cdr (memq :custom-groups options)) g) |
| 804 | (setq options (cons :custom-groups (cons g options))))) | 809 | (setq options (cons :custom-groups (cons g options))))) |
| @@ -1065,7 +1070,7 @@ if default value is nil." | |||
| 1065 | )) | 1070 | )) |
| 1066 | )) | 1071 | )) |
| 1067 | 1072 | ||
| 1068 | (defun eieio-copy-parents-into-subclass (newc parents) | 1073 | (defun eieio-copy-parents-into-subclass (newc _parents) |
| 1069 | "Copy into NEWC the slots of PARENTS. | 1074 | "Copy into NEWC the slots of PARENTS. |
| 1070 | Follow the rules of not overwriting early parents when applying to | 1075 | Follow the rules of not overwriting early parents when applying to |
| 1071 | the new child class." | 1076 | the new child class." |
| @@ -1178,6 +1183,8 @@ DOC-STRING is the documentation attached to METHOD." | |||
| 1178 | (let ((doc-string (documentation method))) | 1183 | (let ((doc-string (documentation method))) |
| 1179 | (fset method (eieio-defgeneric-form-primary-only method doc-string)))) | 1184 | (fset method (eieio-defgeneric-form-primary-only method doc-string)))) |
| 1180 | 1185 | ||
| 1186 | (declare-function no-applicable-method "eieio" (object method &rest args)) | ||
| 1187 | |||
| 1181 | (defun eieio-defgeneric-form-primary-only-one (method doc-string | 1188 | (defun eieio-defgeneric-form-primary-only-one (method doc-string |
| 1182 | class | 1189 | class |
| 1183 | impl | 1190 | impl |
| @@ -1212,7 +1219,7 @@ IMPL is the symbol holding the method implementation." | |||
| 1212 | ',class))) | 1219 | ',class))) |
| 1213 | 1220 | ||
| 1214 | ;; If not the right kind of object, call no applicable | 1221 | ;; If not the right kind of object, call no applicable |
| 1215 | (apply 'no-applicable-method (car local-args) | 1222 | (apply #'no-applicable-method (car local-args) |
| 1216 | ',method local-args) | 1223 | ',method local-args) |
| 1217 | 1224 | ||
| 1218 | ;; It is ok, do the call. | 1225 | ;; It is ok, do the call. |
| @@ -1299,53 +1306,12 @@ but remove reference to all implementations of METHOD." | |||
| 1299 | ;; This is a hideous hack for replacing `typep' from cl-macs, to avoid | 1306 | ;; This is a hideous hack for replacing `typep' from cl-macs, to avoid |
| 1300 | ;; requiring the CL library at run-time. It can be eliminated if/when | 1307 | ;; requiring the CL library at run-time. It can be eliminated if/when |
| 1301 | ;; `typep' is merged into Emacs core. | 1308 | ;; `typep' is merged into Emacs core. |
| 1302 | (defun eieio--typep (val type) | ||
| 1303 | (if (symbolp type) | ||
| 1304 | (cond ((get type 'cl-deftype-handler) | ||
| 1305 | (eieio--typep val (funcall (get type 'cl-deftype-handler)))) | ||
| 1306 | ((eq type t) t) | ||
| 1307 | ((eq type 'null) (null val)) | ||
| 1308 | ((eq type 'atom) (atom val)) | ||
| 1309 | ((eq type 'float) (and (numberp val) (not (integerp val)))) | ||
| 1310 | ((eq type 'real) (numberp val)) | ||
| 1311 | ((eq type 'fixnum) (integerp val)) | ||
| 1312 | ((memq type '(character string-char)) (characterp val)) | ||
| 1313 | (t | ||
| 1314 | (let* ((name (symbol-name type)) | ||
| 1315 | (namep (intern (concat name "p")))) | ||
| 1316 | (if (fboundp namep) | ||
| 1317 | (funcall `(lambda () (,namep val))) | ||
| 1318 | (funcall `(lambda () | ||
| 1319 | (,(intern (concat name "-p")) val))))))) | ||
| 1320 | (cond ((get (car type) 'cl-deftype-handler) | ||
| 1321 | (eieio--typep val (apply (get (car type) 'cl-deftype-handler) | ||
| 1322 | (cdr type)))) | ||
| 1323 | ((memq (car type) '(integer float real number)) | ||
| 1324 | (and (eieio--typep val (car type)) | ||
| 1325 | (or (memq (cadr type) '(* nil)) | ||
| 1326 | (if (consp (cadr type)) | ||
| 1327 | (> val (car (cadr type))) | ||
| 1328 | (>= val (cadr type)))) | ||
| 1329 | (or (memq (caddr type) '(* nil)) | ||
| 1330 | (if (consp (car (cddr type))) | ||
| 1331 | (< val (caar (cddr type))) | ||
| 1332 | (<= val (car (cddr type))))))) | ||
| 1333 | ((memq (car type) '(and or not)) | ||
| 1334 | (eval (cons (car type) | ||
| 1335 | (mapcar (lambda (x) | ||
| 1336 | `(eieio--typep (quote ,val) (quote ,x))) | ||
| 1337 | (cdr type))))) | ||
| 1338 | ((memq (car type) '(member member*)) | ||
| 1339 | (memql val (cdr type))) | ||
| 1340 | ((eq (car type) 'satisfies) | ||
| 1341 | (funcall `(lambda () (,(cadr type) val)))) | ||
| 1342 | (t (error "Bad type spec: %s" type))))) | ||
| 1343 | 1309 | ||
| 1344 | (defun eieio-perform-slot-validation (spec value) | 1310 | (defun eieio-perform-slot-validation (spec value) |
| 1345 | "Return non-nil if SPEC does not match VALUE." | 1311 | "Return non-nil if SPEC does not match VALUE." |
| 1346 | (or (eq spec t) ; t always passes | 1312 | (or (eq spec t) ; t always passes |
| 1347 | (eq value eieio-unbound) ; unbound always passes | 1313 | (eq value eieio-unbound) ; unbound always passes |
| 1348 | (eieio--typep value spec))) | 1314 | (cl-typep value spec))) |
| 1349 | 1315 | ||
| 1350 | (defun eieio-validate-slot-value (class slot-idx value slot) | 1316 | (defun eieio-validate-slot-value (class slot-idx value slot) |
| 1351 | "Make sure that for CLASS referencing SLOT-IDX, VALUE is valid. | 1317 | "Make sure that for CLASS referencing SLOT-IDX, VALUE is valid. |
| @@ -1632,7 +1598,7 @@ If a consistent order does not exist, signal an error." | |||
| 1632 | ;; applicable. | 1598 | ;; applicable. |
| 1633 | (eieio-c3-merge-lists | 1599 | (eieio-c3-merge-lists |
| 1634 | (cons next reversed-partial-result) | 1600 | (cons next reversed-partial-result) |
| 1635 | (mapcar (lambda (l) (if (eq (first l) next) (rest l) l)) | 1601 | (mapcar (lambda (l) (if (eq (cl-first l) next) (cl-rest l) l)) |
| 1636 | remaining-inputs)) | 1602 | remaining-inputs)) |
| 1637 | ;; The graph is inconsistent, give up | 1603 | ;; The graph is inconsistent, give up |
| 1638 | (signal 'inconsistent-class-hierarchy (list remaining-inputs)))))) | 1604 | (signal 'inconsistent-class-hierarchy (list remaining-inputs)))))) |
| @@ -1700,7 +1666,7 @@ The order, in which the parents are returned depends on the | |||
| 1700 | method invocation orders of the involved classes." | 1666 | method invocation orders of the involved classes." |
| 1701 | (if (or (null class) (eq class 'eieio-default-superclass)) | 1667 | (if (or (null class) (eq class 'eieio-default-superclass)) |
| 1702 | nil | 1668 | nil |
| 1703 | (case (class-method-invocation-order class) | 1669 | (cl-case (class-method-invocation-order class) |
| 1704 | (:depth-first | 1670 | (:depth-first |
| 1705 | (eieio-class-precedence-dfs class)) | 1671 | (eieio-class-precedence-dfs class)) |
| 1706 | (:breadth-first | 1672 | (:breadth-first |
| @@ -1839,7 +1805,7 @@ This should only be called from a generic function." | |||
| 1839 | 1805 | ||
| 1840 | ;; Now loop through all occurrences forms which we must execute | 1806 | ;; Now loop through all occurrences forms which we must execute |
| 1841 | ;; (which are happily sorted now) and execute them all! | 1807 | ;; (which are happily sorted now) and execute them all! |
| 1842 | (let ((rval nil) (lastval nil) (rvalever nil) (found nil)) | 1808 | (let ((rval nil) (lastval nil) (found nil)) |
| 1843 | (while lambdas | 1809 | (while lambdas |
| 1844 | (if (car lambdas) | 1810 | (if (car lambdas) |
| 1845 | (eieio--with-scoped-class (cdr (car lambdas)) | 1811 | (eieio--with-scoped-class (cdr (car lambdas)) |
| @@ -1856,20 +1822,16 @@ This should only be called from a generic function." | |||
| 1856 | ;;(setq rval (apply (car (car lambdas)) newargs)) | 1822 | ;;(setq rval (apply (car (car lambdas)) newargs)) |
| 1857 | (setq lastval (apply (car (car lambdas)) newargs)) | 1823 | (setq lastval (apply (car (car lambdas)) newargs)) |
| 1858 | (when has-return-val | 1824 | (when has-return-val |
| 1859 | (setq rval lastval | 1825 | (setq rval lastval)) |
| 1860 | rvalever t)) | ||
| 1861 | ))) | 1826 | ))) |
| 1862 | (setq lambdas (cdr lambdas) | 1827 | (setq lambdas (cdr lambdas) |
| 1863 | keys (cdr keys))) | 1828 | keys (cdr keys))) |
| 1864 | (if (not found) | 1829 | (if (not found) |
| 1865 | (if (eieio-object-p (car args)) | 1830 | (if (eieio-object-p (car args)) |
| 1866 | (setq rval (apply 'no-applicable-method (car args) method args) | 1831 | (setq rval (apply #'no-applicable-method (car args) method args)) |
| 1867 | rvalever t) | ||
| 1868 | (signal | 1832 | (signal |
| 1869 | 'no-method-definition | 1833 | 'no-method-definition |
| 1870 | (list method args)))) | 1834 | (list method args)))) |
| 1871 | ;; Right Here... it could be that lastval is returned when | ||
| 1872 | ;; rvalever is nil. Is that right? | ||
| 1873 | rval))) | 1835 | rval))) |
| 1874 | 1836 | ||
| 1875 | (defun eieio-generic-call-primary-only (method args) | 1837 | (defun eieio-generic-call-primary-only (method args) |
| @@ -1920,7 +1882,7 @@ for this common case to improve performance." | |||
| 1920 | ;; Now loop through all occurrences forms which we must execute | 1882 | ;; Now loop through all occurrences forms which we must execute |
| 1921 | ;; (which are happily sorted now) and execute them all! | 1883 | ;; (which are happily sorted now) and execute them all! |
| 1922 | (eieio--with-scoped-class (cdr lambdas) | 1884 | (eieio--with-scoped-class (cdr lambdas) |
| 1923 | (let* ((rval nil) (lastval nil) (rvalever nil) | 1885 | (let* ((rval nil) (lastval nil) |
| 1924 | (eieio-generic-call-key method-primary) | 1886 | (eieio-generic-call-key method-primary) |
| 1925 | ;; Use the cdr, as the first element is the fcn | 1887 | ;; Use the cdr, as the first element is the fcn |
| 1926 | ;; we are calling right now. | 1888 | ;; we are calling right now. |
| @@ -1931,8 +1893,8 @@ for this common case to improve performance." | |||
| 1931 | 1893 | ||
| 1932 | ;; No methods found for this impl... | 1894 | ;; No methods found for this impl... |
| 1933 | (if (eieio-object-p (car args)) | 1895 | (if (eieio-object-p (car args)) |
| 1934 | (setq rval (apply 'no-applicable-method (car args) method args) | 1896 | (setq rval (apply #'no-applicable-method |
| 1935 | rvalever t) | 1897 | (car args) method args)) |
| 1936 | (signal | 1898 | (signal |
| 1937 | 'no-method-definition | 1899 | 'no-method-definition |
| 1938 | (list method args))) | 1900 | (list method args))) |
| @@ -1943,12 +1905,8 @@ for this common case to improve performance." | |||
| 1943 | lambdas) | 1905 | lambdas) |
| 1944 | 1906 | ||
| 1945 | (setq lastval (apply (car lambdas) newargs)) | 1907 | (setq lastval (apply (car lambdas) newargs)) |
| 1946 | (setq rval lastval | 1908 | (setq rval lastval)) |
| 1947 | rvalever t) | ||
| 1948 | ) | ||
| 1949 | 1909 | ||
| 1950 | ;; Right Here... it could be that lastval is returned when | ||
| 1951 | ;; rvalever is nil. Is that right? | ||
| 1952 | rval)))) | 1910 | rval)))) |
| 1953 | 1911 | ||
| 1954 | (defun eieiomt-method-list (method key class) | 1912 | (defun eieiomt-method-list (method key class) |
| @@ -2054,7 +2012,7 @@ CLASS is the class this method is associated with." | |||
| 2054 | (when (string-match "\\.elc$" fname) | 2012 | (when (string-match "\\.elc$" fname) |
| 2055 | (setq fname (substring fname 0 (1- (length fname))))) | 2013 | (setq fname (substring fname 0 (1- (length fname))))) |
| 2056 | (setq loc (get method-name 'method-locations)) | 2014 | (setq loc (get method-name 'method-locations)) |
| 2057 | (pushnew (list class fname) loc :test 'equal) | 2015 | (cl-pushnew (list class fname) loc :test 'equal) |
| 2058 | (put method-name 'method-locations loc))) | 2016 | (put method-name 'method-locations loc))) |
| 2059 | ;; Now optimize the entire obarray | 2017 | ;; Now optimize the entire obarray |
| 2060 | (if (< key method-num-lists) | 2018 | (if (< key method-num-lists) |
| @@ -2084,7 +2042,8 @@ nil for superclasses. This function performs no type checking!" | |||
| 2084 | ;; we replace the nil from above. | 2042 | ;; we replace the nil from above. |
| 2085 | (let ((external-symbol (intern-soft (symbol-name s)))) | 2043 | (let ((external-symbol (intern-soft (symbol-name s)))) |
| 2086 | (catch 'done | 2044 | (catch 'done |
| 2087 | (dolist (ancestor (rest (eieio-class-precedence-list external-symbol))) | 2045 | (dolist (ancestor |
| 2046 | (cl-rest (eieio-class-precedence-list external-symbol))) | ||
| 2088 | (let ((ov (intern-soft (symbol-name ancestor) | 2047 | (let ((ov (intern-soft (symbol-name ancestor) |
| 2089 | eieiomt-optimizing-obarray))) | 2048 | eieiomt-optimizing-obarray))) |
| 2090 | (when (fboundp ov) | 2049 | (when (fboundp ov) |
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 23cf5197233..22e247937e8 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects | 1 | ;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects -*- lexical-binding:t -*- |
| 2 | ;;; or maybe Eric's Implementation of Emacs Interpreted Objects | 2 | ;;; or maybe Eric's Implementation of Emacs Interpreted Objects |
| 3 | 3 | ||
| 4 | ;; Copyright (C) 1995-1996, 1998-2014 Free Software Foundation, Inc. | 4 | ;; Copyright (C) 1995-1996, 1998-2014 Free Software Foundation, Inc. |
| @@ -44,8 +44,6 @@ | |||
| 44 | 44 | ||
| 45 | ;;; Code: | 45 | ;;; Code: |
| 46 | 46 | ||
| 47 | (eval-when-compile (require 'cl)) ;FIXME: Use cl-lib! | ||
| 48 | |||
| 49 | (defvar eieio-version "1.4" | 47 | (defvar eieio-version "1.4" |
| 50 | "Current version of EIEIO.") | 48 | "Current version of EIEIO.") |
| 51 | 49 | ||
| @@ -115,6 +113,7 @@ Options in CLOS not supported in EIEIO: | |||
| 115 | 113 | ||
| 116 | Due to the way class options are set up, you can add any tags you wish, | 114 | Due to the way class options are set up, you can add any tags you wish, |
| 117 | and reference them using the function `class-option'." | 115 | and reference them using the function `class-option'." |
| 116 | (declare (doc-string 4)) | ||
| 118 | ;; This is eval-and-compile only to silence spurious compiler warnings | 117 | ;; This is eval-and-compile only to silence spurious compiler warnings |
| 119 | ;; about functions and variables not known to be defined. | 118 | ;; about functions and variables not known to be defined. |
| 120 | ;; When eieio-defclass code is merged here and this becomes | 119 | ;; When eieio-defclass code is merged here and this becomes |
| @@ -155,7 +154,7 @@ a string." | |||
| 155 | 154 | ||
| 156 | ;;; CLOS methods and generics | 155 | ;;; CLOS methods and generics |
| 157 | ;; | 156 | ;; |
| 158 | (defmacro defgeneric (method args &optional doc-string) | 157 | (defmacro defgeneric (method _args &optional doc-string) |
| 159 | "Create a generic function METHOD. | 158 | "Create a generic function METHOD. |
| 160 | DOC-STRING is the base documentation for this class. A generic | 159 | DOC-STRING is the base documentation for this class. A generic |
| 161 | function has no body, as its purpose is to decide which method body | 160 | function has no body, as its purpose is to decide which method body |
| @@ -163,6 +162,7 @@ is appropriate to use. Uses `defmethod' to create methods, and calls | |||
| 163 | `defgeneric' for you. With this implementation the ARGS are | 162 | `defgeneric' for you. With this implementation the ARGS are |
| 164 | currently ignored. You can use `defgeneric' to apply specialized | 163 | currently ignored. You can use `defgeneric' to apply specialized |
| 165 | top level documentation to a method." | 164 | top level documentation to a method." |
| 165 | (declare (doc-string 3)) | ||
| 166 | `(eieio--defalias ',method | 166 | `(eieio--defalias ',method |
| 167 | (eieio--defgeneric-init-form ',method ,doc-string))) | 167 | (eieio--defgeneric-init-form ',method ,doc-string))) |
| 168 | 168 | ||
| @@ -191,6 +191,7 @@ Summary: | |||
| 191 | ((typearg class-name) arg2 &optional opt &rest rest) | 191 | ((typearg class-name) arg2 &optional opt &rest rest) |
| 192 | \"doc-string\" | 192 | \"doc-string\" |
| 193 | body)" | 193 | body)" |
| 194 | (declare (doc-string 3)) | ||
| 194 | (let* ((key (if (keywordp (car args)) (pop args))) | 195 | (let* ((key (if (keywordp (car args)) (pop args))) |
| 195 | (params (car args)) | 196 | (params (car args)) |
| 196 | (arg1 (car params)) | 197 | (arg1 (car params)) |
| @@ -246,6 +247,7 @@ Where each VAR is the local variable given to the associated | |||
| 246 | SLOT. A slot specified without a variable name is given a | 247 | SLOT. A slot specified without a variable name is given a |
| 247 | variable name of the same name as the slot." | 248 | variable name of the same name as the slot." |
| 248 | (declare (indent 2)) | 249 | (declare (indent 2)) |
| 250 | (require 'cl-lib) | ||
| 249 | ;; Transform the spec-list into a cl-symbol-macrolet spec-list. | 251 | ;; Transform the spec-list into a cl-symbol-macrolet spec-list. |
| 250 | (let ((mappings (mapcar (lambda (entry) | 252 | (let ((mappings (mapcar (lambda (entry) |
| 251 | (let ((var (if (listp entry) (car entry) entry)) | 253 | (let ((var (if (listp entry) (car entry) entry)) |
| @@ -523,7 +525,7 @@ Use `next-method-p' to find out if there is a next method to call." | |||
| 523 | (next (car eieio-generic-call-next-method-list)) | 525 | (next (car eieio-generic-call-next-method-list)) |
| 524 | ) | 526 | ) |
| 525 | (if (or (not next) (not (car next))) | 527 | (if (or (not next) (not (car next))) |
| 526 | (apply 'no-next-method (car newargs) (cdr newargs)) | 528 | (apply #'no-next-method (car newargs) (cdr newargs)) |
| 527 | (let* ((eieio-generic-call-next-method-list | 529 | (let* ((eieio-generic-call-next-method-list |
| 528 | (cdr eieio-generic-call-next-method-list)) | 530 | (cdr eieio-generic-call-next-method-list)) |
| 529 | (eieio-generic-call-arglst newargs) | 531 | (eieio-generic-call-arglst newargs) |
| @@ -535,27 +537,7 @@ Use `next-method-p' to find out if there is a next method to call." | |||
| 535 | ;;; Here are some CLOS items that need the CL package | 537 | ;;; Here are some CLOS items that need the CL package |
| 536 | ;; | 538 | ;; |
| 537 | 539 | ||
| 538 | (defsetf eieio-oref eieio-oset) | 540 | (gv-define-simple-setter eieio-oref eieio-oset) |
| 539 | |||
| 540 | (if (eval-when-compile (fboundp 'gv-define-expander)) | ||
| 541 | ;; Not needed for Emacs>=24.3 since gv.el's setf expands macros and | ||
| 542 | ;; follows aliases. | ||
| 543 | nil | ||
| 544 | (defsetf slot-value eieio-oset) | ||
| 545 | |||
| 546 | ;; The below setf method was written by Arnd Kohrs <kohrs@acm.org> | ||
| 547 | (define-setf-method oref (obj slot) | ||
| 548 | (with-no-warnings | ||
| 549 | (require 'cl) | ||
| 550 | (let ((obj-temp (gensym)) | ||
| 551 | (slot-temp (gensym)) | ||
| 552 | (store-temp (gensym))) | ||
| 553 | (list (list obj-temp slot-temp) | ||
| 554 | (list obj `(quote ,slot)) | ||
| 555 | (list store-temp) | ||
| 556 | (list 'set-slot-value obj-temp slot-temp | ||
| 557 | store-temp) | ||
| 558 | (list 'slot-value obj-temp slot-temp)))))) | ||
| 559 | 541 | ||
| 560 | 542 | ||
| 561 | ;;; | 543 | ;;; |
| @@ -651,7 +633,7 @@ dynamically set from SLOTS." | |||
| 651 | "Method invoked when an attempt to access a slot in OBJECT fails.") | 633 | "Method invoked when an attempt to access a slot in OBJECT fails.") |
| 652 | 634 | ||
| 653 | (defmethod slot-missing ((object eieio-default-superclass) slot-name | 635 | (defmethod slot-missing ((object eieio-default-superclass) slot-name |
| 654 | operation &optional new-value) | 636 | _operation &optional _new-value) |
| 655 | "Method invoked when an attempt to access a slot in OBJECT fails. | 637 | "Method invoked when an attempt to access a slot in OBJECT fails. |
| 656 | SLOT-NAME is the name of the failed slot, OPERATION is the type of access | 638 | SLOT-NAME is the name of the failed slot, OPERATION is the type of access |
| 657 | that was requested, and optional NEW-VALUE is the value that was desired | 639 | that was requested, and optional NEW-VALUE is the value that was desired |
| @@ -684,7 +666,7 @@ EIEIO can only dispatch on the first argument, so the first two are swapped." | |||
| 684 | "Called if there are no implementations for OBJECT in METHOD.") | 666 | "Called if there are no implementations for OBJECT in METHOD.") |
| 685 | 667 | ||
| 686 | (defmethod no-applicable-method ((object eieio-default-superclass) | 668 | (defmethod no-applicable-method ((object eieio-default-superclass) |
| 687 | method &rest args) | 669 | method &rest _args) |
| 688 | "Called if there are no implementations for OBJECT in METHOD. | 670 | "Called if there are no implementations for OBJECT in METHOD. |
| 689 | OBJECT is the object which has no method implementation. | 671 | OBJECT is the object which has no method implementation. |
| 690 | ARGS are the arguments that were passed to METHOD. | 672 | ARGS are the arguments that were passed to METHOD. |
| @@ -734,7 +716,7 @@ first and modify the returned object.") | |||
| 734 | (defgeneric destructor (this &rest params) | 716 | (defgeneric destructor (this &rest params) |
| 735 | "Destructor for cleaning up any dynamic links to our object.") | 717 | "Destructor for cleaning up any dynamic links to our object.") |
| 736 | 718 | ||
| 737 | (defmethod destructor ((this eieio-default-superclass) &rest params) | 719 | (defmethod destructor ((_this eieio-default-superclass) &rest _params) |
| 738 | "Destructor for cleaning up any dynamic links to our object. | 720 | "Destructor for cleaning up any dynamic links to our object. |
| 739 | Argument THIS is the object being destroyed. PARAMS are additional | 721 | Argument THIS is the object being destroyed. PARAMS are additional |
| 740 | ignored parameters." | 722 | ignored parameters." |
| @@ -760,7 +742,7 @@ Implement this function and specify STRINGS in a call to | |||
| 760 | `call-next-method' to provide additional summary information. | 742 | `call-next-method' to provide additional summary information. |
| 761 | When passing in extra strings from child classes, always remember | 743 | When passing in extra strings from child classes, always remember |
| 762 | to prepend a space." | 744 | to prepend a space." |
| 763 | (eieio-object-name this (apply 'concat strings))) | 745 | (eieio-object-name this (apply #'concat strings))) |
| 764 | 746 | ||
| 765 | (defvar eieio-print-depth 0 | 747 | (defvar eieio-print-depth 0 |
| 766 | "When printing, keep track of the current indentation depth.") | 748 | "When printing, keep track of the current indentation depth.") |
| @@ -859,7 +841,7 @@ this object." | |||
| 859 | 841 | ||
| 860 | ;;; Unimplemented functions from CLOS | 842 | ;;; Unimplemented functions from CLOS |
| 861 | ;; | 843 | ;; |
| 862 | (defun change-class (obj class) | 844 | (defun change-class (_obj _class) |
| 863 | "Change the class of OBJ to type CLASS. | 845 | "Change the class of OBJ to type CLASS. |
| 864 | This may create or delete slots, but does not affect the return value | 846 | This may create or delete slots, but does not affect the return value |
| 865 | of `eq'." | 847 | of `eq'." |
| @@ -879,7 +861,8 @@ Optional argument NOESCAPE is passed to `prin1-to-string' when appropriate." | |||
| 879 | ((eieio-object-p object) (object-print object)) | 861 | ((eieio-object-p object) (object-print object)) |
| 880 | ((and (listp object) (or (class-p (car object)) | 862 | ((and (listp object) (or (class-p (car object)) |
| 881 | (eieio-object-p (car object)))) | 863 | (eieio-object-p (car object)))) |
| 882 | (concat "(" (mapconcat 'eieio-edebug-prin1-to-string object " ") ")")) | 864 | (concat "(" (mapconcat #'eieio-edebug-prin1-to-string object " ") |
| 865 | ")")) | ||
| 883 | (t (prin1-to-string object noescape)))) | 866 | (t (prin1-to-string object noescape)))) |
| 884 | 867 | ||
| 885 | (add-hook 'edebug-setup-hook | 868 | (add-hook 'edebug-setup-hook |