|
From: | Helmut Eller |
Subject: | Re: Generalizing find-definition |
Date: | Thu, 11 Dec 2014 19:36:44 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> Too bad that classes can't be autoloaded. I added this little hack to autoload classes: (defvar xref-backend 'etags-xref-backend "The class symbol used to create backend instances. It should be a subclass of `xref-backend-class'. The front-end calls `make-instance' with this symbol as argument.") (defun xref--maybe-autoload-class (symbol) (unless (class-p symbol) (let ((f (symbol-function symbol))) (when (autoloadp f) (autoload-do-load f symbol))))) (defun xref--backend () (let ((symbol xref-backend)) (xref--maybe-autoload-class symbol) (make-instance symbol))) And an autoloadable class is then defined as: ;;;###autoload (autoload 'etags-xref-backend "etags") (defclass etags-xref-backend (xref-backend-class eieio-singleton) ()) This works because defclass creates a constructor function with the same name as the classname. Would this be acceptable, from a style point of view? Helmut
[Prev in Thread] | Current Thread | [Next in Thread] |