From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: cl-defgeneric vs random funcall in project.el Date: Tue, 28 Jul 2015 20:00:49 -0500 Message-ID: <86wpxj93r2.fsf@stephe-leake.org> References: <86oaiwa57v.fsf@stephe-leake.org> <55B79B3F.1060200@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438131701 15118 80.91.229.3 (29 Jul 2015 01:01:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Jul 2015 01:01:41 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 29 03:01:30 2015 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 1ZKFkP-0002I6-G1 for ged-emacs-devel@m.gmane.org; Wed, 29 Jul 2015 03:01:29 +0200 Original-Received: from localhost ([::1]:32957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKFkO-0002oH-EC for ged-emacs-devel@m.gmane.org; Tue, 28 Jul 2015 21:01:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKFkL-0002oA-2e for emacs-devel@gnu.org; Tue, 28 Jul 2015 21:01:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKFkH-0008Tn-Rr for emacs-devel@gnu.org; Tue, 28 Jul 2015 21:01:25 -0400 Original-Received: from gproxy2-pub.mail.unifiedlayer.com ([69.89.18.3]:35640) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ZKFkH-0008Tf-LW for emacs-devel@gnu.org; Tue, 28 Jul 2015 21:01:21 -0400 Original-Received: (qmail 14459 invoked by uid 0); 29 Jul 2015 01:01:14 -0000 Original-Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy2.mail.unifiedlayer.com with SMTP; 29 Jul 2015 01:01:14 -0000 Original-Received: from host114.hostmonster.com ([74.220.207.114]) by cmgw3 with id y7141q00B2UdiVW01717k2; Wed, 29 Jul 2015 01:01:13 -0600 X-Authority-Analysis: v=2.1 cv=Qc314Krv c=1 sm=1 tr=0 a=CQdxDb2CKd3SRg4I0/XZPQ==:117 a=CQdxDb2CKd3SRg4I0/XZPQ==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=9i_RQKNPAAAA:8 a=y7kgw_RnJtkA:10 a=hEr_IkYJT6EA:10 a=x_XPkuGwIRMA:10 a=zOBTXjUuO1YA:10 a=vaJtXVxTAAAA:8 a=kEt081gPuYpZE8hZQssA:9 Original-Received: from [76.218.37.33] (port=62911 helo=TAKVER2) by host114.hostmonster.com with esmtpa (Exim 4.84) (envelope-from ) id 1ZKFk0-0005z1-TD for emacs-devel@gnu.org; Tue, 28 Jul 2015 19:01:05 -0600 In-Reply-To: <55B79B3F.1060200@yandex.ru> (Dmitry Gutov's message of "Tue, 28 Jul 2015 18:09:51 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) X-Identified-User: {2442:host114.hostmonster.com:stephele:stephe-leake.org} {sentby:smtp auth 76.218.37.33 authed with stephen_leake@stephe-leake.org} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.89.18.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:188150 Archived-At: Dmitry Gutov writes: > On 07/28/2015 02:31 PM, Stephen Leake wrote: > >> But the default method uses 'project-search-path-function', which >> elisp-mode sets to `elisp-search-function'; elisp.el does not use >> cl-defmethod to override project-search-path. > > And if a project implementation has to provide its own implementation, > it's much cleaner, I think, if it only has to deal with > project-search-path-function, instead of being forced to > cl-call-next-method. Well, that's my question. I don't see that as "cleaner"; I much prefer object dispatching to random funcalls. Why would it use 'cl-call-next-method'? That would call the default method, which is wrong; that's why we're overriding it. > Further, this part seems like it'd be impossible to implement: "A > specialized implementation should use the value > `project-search-path-function', or, better yet, call and combine > the results from the functions that this value is set to by all > major modes used in the project". Right. I don't see that as a useful design. Just get rid of it. Nothing else in project.el currently suggests that 'project-search-path-function' should be a list; the default method for project-search-path doesn't treat it as a list. What is the use case for this? I remember seeing something in the email chain; did that get captured somewhere? > However, now that we've reached the consensus that project-search-path > doesn't need to include the directories inside the current project, I never agreed to that. In fact, I thought the only thing we _did_ agree on was that project-search-path included the main project. Sigh. > an implementation will only need to override it if it actually knows > search-path better than the major-mode. The "implementation" we are talking about here is presumably something that knows how to read project files defined by some third-party tool (Ada .gpr files, gradle files, etc). That would certainly know exactly what the project search path should be, and it should override all relevant project-* functions. As far as I can see, the _primary_ purpose of a project-* implementation is to provide the correct search-path and/or project-root, so the functions that use those do the right thing. >> Why do we need both dispatching methods? > > The alternative (which is more feasible now) is to use the context > specializer, like: > > (cl-defmethod project-search-path (_project &context (major-mode (eql > emacs-lisp-mode)))) That's one alternative. Another is to have the project backends provide a minor mode, that specifies the project implementation, by returning the proper value from (current-project). Or just let the major mode specify the project backend; that's what happens in elisp and Ada mode now. One implementation is to define a buffer-local current-project variable; that specifies the backend as well as any relevant information. In any case, we only need cl-defmethod in one form or another. -- -- Stephe