From 265331858f3cd63f3ab593461ca4f2931780ba5e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 18 Oct 2014 22:14:58 -0400 Subject: [PATCH] * lisp/emacs-lisp/eieio: A bit more cleanup, removing compat code. * lisp/emacs-lisp/eieio-core.el (eieio-compiled-function-arglist): Remove. (eieio--with-scoped-class): Use `declare'. (eieio-defclass): Remove compatibility code. (no-method-definition, no-next-method, inconsistent-class-hierarchy) (invalid-slot-type, unbound-slot, invalid-slot-name): Use define-error. * lisp/emacs-lisp/eieio-opt.el (eieio-lambda-arglist): Remove. Use help-function-arglist instead. --- lisp/ChangeLog | 13 ++++++- lisp/emacs-lisp/eieio-core.el | 72 +++++++---------------------------- lisp/emacs-lisp/eieio-opt.el | 15 ++------ lisp/emacs-lisp/eieio.el | 2 +- 4 files changed, 30 insertions(+), 72 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index afb6f696712..af4d5e0e055 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2014-10-19 Stefan Monnier + + * emacs-lisp/eieio-opt.el (eieio-lambda-arglist): Remove. + Use help-function-arglist instead. + + * emacs-lisp/eieio-core.el (eieio-compiled-function-arglist): Remove. + (eieio--with-scoped-class): Use `declare'. + (eieio-defclass): Remove compatibility code. + (no-method-definition, no-next-method, inconsistent-class-hierarchy) + (invalid-slot-type, unbound-slot, invalid-slot-name): Use define-error. + 2014-10-18 Jan Djärv * cus-start.el (x-gtk-whole-detached-tool-bar): Remove. @@ -33,7 +44,7 @@ 2014-10-17 Michal Nazarewicz - * textmodes/tildify.el (tildify--pick-alist-entry): rename from + * textmodes/tildify.el (tildify--pick-alist-entry): Rename from tildify-mode-alist. 2014-10-17 Stefan Monnier diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 4637de5fd3e..4aae9900f11 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el @@ -33,20 +33,6 @@ (require 'cl-lib) -;; Compatibility -(if (fboundp 'compiled-function-arglist) - - ;; XEmacs can only access a compiled functions arglist like this: - (defalias 'eieio-compiled-function-arglist 'compiled-function-arglist) - - ;; Emacs doesn't have this function, but since FUNC is a vector, we can just - ;; grab the appropriate element. - (defun eieio-compiled-function-arglist (func) - "Return the argument list for the compiled function FUNC." - (aref func 0)) - - ) - (put 'eieio--defalias 'byte-hunk-handler #'byte-compile-file-form-defalias) ;;(get 'defalias 'byte-hunk-handler) (defun eieio--defalias (name body) @@ -117,12 +103,12 @@ default setting for optimization purposes.") (defmacro eieio--with-scoped-class (class &rest forms) "Set CLASS as the currently scoped class while executing FORMS." + (declare (indent 1)) `(unwind-protect (progn (push ,class eieio--scoped-class-stack) ,@forms) (pop eieio--scoped-class-stack))) -(put 'eieio--with-scoped-class 'lisp-indent-function 1) ;;; ;; Field Accessors @@ -678,26 +664,12 @@ See `defclass' for more information." ;; Else - Some error? nil? nil))) - (if (fboundp 'gv-define-setter) - ;; FIXME: We should move more of eieio-defclass into the - ;; defclass macro so we don't have to use `eval' and require - ;; `gv' at run-time. - (eval `(gv-define-setter ,acces (eieio--store eieio--object) - (list 'eieio-oset eieio--object '',name - eieio--store))) - ;; Provide a setf method. It would be cleaner to use - ;; defsetf, but that would require CL at runtime. - (put acces 'setf-method - `(lambda (widget) - (let* ((--widget-sym-- (make-symbol "--widget--")) - (--store-sym-- (make-symbol "--store--"))) - (list - (list --widget-sym--) - (list widget) - (list --store-sym--) - (list 'eieio-oset --widget-sym-- '',name - --store-sym--) - (list 'getfoo --widget-sym--)))))))) + ;; FIXME: We should move more of eieio-defclass into the + ;; defclass macro so we don't have to use `eval' and require + ;; `gv' at run-time. + (eval `(gv-define-setter ,acces (eieio--store eieio--object) + (list 'eieio-oset eieio--object '',name + eieio--store))))) ;; If a writer is defined, then create a generic method of that ;; name whose purpose is to set the value of the slot. @@ -2099,30 +2071,12 @@ is memorized for faster future use." ;;; Here are some special types of errors ;; -(intern "no-method-definition") -(put 'no-method-definition 'error-conditions '(no-method-definition error)) -(put 'no-method-definition 'error-message "No method definition") - -(intern "no-next-method") -(put 'no-next-method 'error-conditions '(no-next-method error)) -(put 'no-next-method 'error-message "No next method") - -(intern "invalid-slot-name") -(put 'invalid-slot-name 'error-conditions '(invalid-slot-name error)) -(put 'invalid-slot-name 'error-message "Invalid slot name") - -(intern "invalid-slot-type") -(put 'invalid-slot-type 'error-conditions '(invalid-slot-type error nil)) -(put 'invalid-slot-type 'error-message "Invalid slot type") - -(intern "unbound-slot") -(put 'unbound-slot 'error-conditions '(unbound-slot error nil)) -(put 'unbound-slot 'error-message "Unbound slot") - -(intern "inconsistent-class-hierarchy") -(put 'inconsistent-class-hierarchy 'error-conditions - '(inconsistent-class-hierarchy error nil)) -(put 'inconsistent-class-hierarchy 'error-message "Inconsistent class hierarchy") +(define-error 'no-method-definition "No method definition") +(define-error 'no-next-method "No next method") +(define-error 'invalid-slot-name "Invalid slot name") +(define-error 'invalid-slot-type "Invalid slot type") +(define-error 'unbound-slot "Unbound slot") +(define-error 'inconsistent-class-hierarchy "Inconsistent class hierarchy") ;;; Obsolete backward compatibility functions. ;; Needed to run byte-code compiled with the EIEIO of Emacs-23. diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el index ca9b91bed58..6f1d01c211f 100644 --- a/lisp/emacs-lisp/eieio-opt.el +++ b/lisp/emacs-lisp/eieio-opt.el @@ -356,7 +356,7 @@ are not abstract." (insert "' " (aref prefix i) " ") ;; argument list (let* ((func (cdr (car gm))) - (arglst (eieio-lambda-arglist func))) + (arglst (help-function-arglist func))) (prin1 arglst (current-buffer))) (insert "\n" (or (documentation (cdr (car gm))) @@ -374,13 +374,6 @@ are not abstract." (insert "\n"))) (setq i (1+ i))))))) -(defun eieio-lambda-arglist (func) - "Return the argument list of FUNC, a function body." - (if (symbolp func) (setq func (symbol-function func))) - (if (byte-code-function-p func) - (eieio-compiled-function-arglist func) - (car (cdr func)))) - (defun eieio-all-generic-functions (&optional class) "Return a list of all generic functions. Optional CLASS argument returns only those functions that contain @@ -419,15 +412,15 @@ function has no documentation, then return nil." (fboundp after))) nil (list (if (fboundp before) - (cons (eieio-lambda-arglist before) + (cons (help-function-arglist before) (documentation before)) nil) (if (fboundp primary) - (cons (eieio-lambda-arglist primary) + (cons (help-function-arglist primary) (documentation primary)) nil) (if (fboundp after) - (cons (eieio-lambda-arglist after) + (cons (help-function-arglist after) (documentation after)) nil)))))) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 22e247937e8..d7c60dc6dd5 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -910,7 +910,7 @@ Optional argument GROUP is the sub-group of slots to display. ;;;*** -;;;### (autoloads nil "eieio-opt" "eieio-opt.el" "99b94c63a73593402e3c825178a44f4f") +;;;### (autoloads nil "eieio-opt" "eieio-opt.el" "889c0a935dddf758dbb65488470ffa06") ;;; Generated autoloads from eieio-opt.el (autoload 'eieio-browse "eieio-opt" "\ -- 2.39.5