diff options
| author | Lars Ingebrigtsen | 2019-06-19 17:12:29 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-19 17:12:29 +0200 |
| commit | fc8a8bdb7f19db2032b7e6108ba8de9d57c7acd4 (patch) | |
| tree | 10da9a9fbe5baf0c0badfedef035a7da226a0fa8 | |
| parent | 3fb6993c8ddf433fab4b98ae2948b961482ef947 (diff) | |
| download | emacs-fc8a8bdb7f19db2032b7e6108ba8de9d57c7acd4.tar.gz emacs-fc8a8bdb7f19db2032b7e6108ba8de9d57c7acd4.zip | |
Move around defgeneric/defmethods in eieio
* lisp/emacs-lisp/eieio.el (object-print):
* lisp/emacs-lisp/eieio-base.el (eieio-object-set-name-string):
Move the defgeneric before the defmethod, because that makes more
sense.
| -rw-r--r-- | lisp/emacs-lisp/eieio-base.el | 11 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio.el | 25 |
2 files changed, 19 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index b6358bdd0f9..534613811d4 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el | |||
| @@ -508,11 +508,6 @@ instance." | |||
| 508 | (or (slot-value obj 'object-name) | 508 | (or (slot-value obj 'object-name) |
| 509 | (cl-call-next-method))) | 509 | (cl-call-next-method))) |
| 510 | 510 | ||
| 511 | (cl-defmethod eieio-object-set-name-string ((obj eieio-named) name) | ||
| 512 | "Set the string which is OBJ's NAME." | ||
| 513 | (cl-check-type name string) | ||
| 514 | (eieio-oset obj 'object-name name)) | ||
| 515 | |||
| 516 | (cl-defgeneric eieio-object-set-name-string (obj name) | 511 | (cl-defgeneric eieio-object-set-name-string (obj name) |
| 517 | "Set the string which is OBJ's NAME." | 512 | "Set the string which is OBJ's NAME." |
| 518 | (declare (obsolete "inherit from `eieio-named' and use (setf (slot-value OBJ \\='object-name) NAME) instead" "25.1")) | 513 | (declare (obsolete "inherit from `eieio-named' and use (setf (slot-value OBJ \\='object-name) NAME) instead" "25.1")) |
| @@ -521,6 +516,12 @@ instance." | |||
| 521 | (define-obsolete-function-alias | 516 | (define-obsolete-function-alias |
| 522 | 'object-set-name-string 'eieio-object-set-name-string "24.4") | 517 | 'object-set-name-string 'eieio-object-set-name-string "24.4") |
| 523 | 518 | ||
| 519 | (with-suppressed-warnings ((obsolete eieio-object-set-name-string)) | ||
| 520 | (cl-defmethod eieio-object-set-name-string ((obj eieio-named) name) | ||
| 521 | "Set the string which is OBJ's NAME." | ||
| 522 | (cl-check-type name string) | ||
| 523 | (eieio-oset obj 'object-name name))) | ||
| 524 | |||
| 524 | (cl-defmethod clone ((obj eieio-named) &rest params) | 525 | (cl-defmethod clone ((obj eieio-named) &rest params) |
| 525 | "Clone OBJ, initializing `:parent' to OBJ. | 526 | "Clone OBJ, initializing `:parent' to OBJ. |
| 526 | All slots are unbound, except those initialized with PARAMS." | 527 | All slots are unbound, except those initialized with PARAMS." |
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 400599a73ed..4b899cdc64a 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el | |||
| @@ -819,8 +819,18 @@ first and modify the returned object.") | |||
| 819 | ;; No cleanup... yet. | 819 | ;; No cleanup... yet. |
| 820 | nil) | 820 | nil) |
| 821 | 821 | ||
| 822 | (cl-defmethod object-print ((this eieio-default-superclass) &rest strings) | 822 | (cl-defgeneric object-print (this &rest _strings) |
| 823 | "Pretty printer for object THIS. Call function `object-name' with STRINGS. | 823 | "Pretty printer for object THIS. |
| 824 | |||
| 825 | It is sometimes useful to put a summary of the object into the | ||
| 826 | default #<notation> string when using EIEIO browsing tools. | ||
| 827 | Implement this method to customize the summary." | ||
| 828 | (declare (obsolete cl-print-object "26.1")) | ||
| 829 | (format "%S" this)) | ||
| 830 | |||
| 831 | (with-suppressed-warnings ((obsolete object-print)) | ||
| 832 | (cl-defmethod object-print ((this eieio-default-superclass) &rest strings) | ||
| 833 | "Pretty printer for object THIS. Call function `object-name' with STRINGS. | ||
| 824 | The default method for printing object THIS is to use the | 834 | The default method for printing object THIS is to use the |
| 825 | function `object-name'. | 835 | function `object-name'. |
| 826 | 836 | ||
| @@ -831,16 +841,7 @@ Implement this function and specify STRINGS in a call to | |||
| 831 | `call-next-method' to provide additional summary information. | 841 | `call-next-method' to provide additional summary information. |
| 832 | When passing in extra strings from child classes, always remember | 842 | When passing in extra strings from child classes, always remember |
| 833 | to prepend a space." | 843 | to prepend a space." |
| 834 | (eieio-object-name this (apply #'concat strings))) | 844 | (eieio-object-name this (apply #'concat strings)))) |
| 835 | |||
| 836 | (cl-defgeneric object-print (this &rest _strings) | ||
| 837 | "Pretty printer for object THIS. | ||
| 838 | |||
| 839 | It is sometimes useful to put a summary of the object into the | ||
| 840 | default #<notation> string when using EIEIO browsing tools. | ||
| 841 | Implement this method to customize the summary." | ||
| 842 | (declare (obsolete cl-print-object "26.1")) | ||
| 843 | (format "%S" this)) | ||
| 844 | 845 | ||
| 845 | (with-suppressed-warnings ((obsolete object-print)) | 846 | (with-suppressed-warnings ((obsolete object-print)) |
| 846 | (cl-defmethod cl-print-object ((object eieio-default-superclass) stream) | 847 | (cl-defmethod cl-print-object ((object eieio-default-superclass) stream) |