From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: Generalizing find-definition Date: Thu, 11 Dec 2014 19:36:44 +0100 Message-ID: References: <20141102151524.0d9c665c@forcix> <85ppc0qf9a.fsf@stephe-leake.org> <85zjb3o09d.fsf@stephe-leake.org> <85tx1amnyg.fsf@stephe-leake.org> <85egsem1u2.fsf@stephe-leake.org> <867fy0or7p.fsf@yandex.ru> <86ppbqn841.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1418323207 12297 80.91.229.3 (11 Dec 2014 18:40:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2014 18:40:07 +0000 (UTC) Cc: Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 11 19:40:00 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xz8ed-0000HF-64 for ged-emacs-devel@m.gmane.org; Thu, 11 Dec 2014 19:39:59 +0100 Original-Received: from localhost ([::1]:53143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz8ec-0001D6-PR for ged-emacs-devel@m.gmane.org; Thu, 11 Dec 2014 13:39:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz8cT-0006lf-86 for emacs-devel@gnu.org; Thu, 11 Dec 2014 13:38:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xz8bh-0002vI-Gw for emacs-devel@gnu.org; Thu, 11 Dec 2014 13:37:45 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:58827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz8bh-0002v6-B9 for emacs-devel@gnu.org; Thu, 11 Dec 2014 13:36:57 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Xz8bg-0005KB-0j for emacs-devel@gnu.org; Thu, 11 Dec 2014 19:36:56 +0100 Original-Received: from 212.46.172.140 ([212.46.172.140]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Dec 2014 19:36:56 +0100 Original-Received: from eller.helmut by 212.46.172.140 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Dec 2014 19:36:56 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 212.46.172.140 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:Kbz5ESuaDeVHh8C9CyeRxPitYSs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:179816 Archived-At: > 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