From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel@gnu.org
Subject: Re: cl-defgeneric vs random funcall in project.el
Date: Tue, 28 Jul 2015 20:00:49 -0500 [thread overview]
Message-ID: <86wpxj93r2.fsf@stephe-leake.org> (raw)
In-Reply-To: <55B79B3F.1060200@yandex.ru> (Dmitry Gutov's message of "Tue, 28 Jul 2015 18:09:51 +0300")
Dmitry Gutov <dgutov@yandex.ru> 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
next prev parent reply other threads:[~2015-07-29 1:00 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 11:31 cl-defgeneric vs random funcall in project.el Stephen Leake
2015-07-28 15:09 ` Dmitry Gutov
2015-07-28 23:57 ` Stefan Monnier
2015-07-29 0:16 ` Dmitry Gutov
2015-07-30 21:26 ` Stefan Monnier
2015-07-29 1:00 ` Stephen Leake [this message]
2015-07-29 1:19 ` Dmitry Gutov
2015-07-29 14:24 ` Stephen Leake
2015-07-29 19:54 ` Dmitry Gutov
2015-07-30 7:04 ` Stephen Leake
2015-07-30 11:30 ` Dmitry Gutov
2015-07-30 15:29 ` Stephen Leake
2015-07-30 15:37 ` Stephen Leake
2015-07-30 16:10 ` Dmitry Gutov
2015-07-30 23:25 ` Stephen Leake
2015-07-30 17:16 ` Dmitry Gutov
2015-07-30 23:33 ` Stephen Leake
2015-07-31 0:37 ` Dmitry Gutov
2015-07-31 14:36 ` Stephen Leake
2015-07-31 22:52 ` Dmitry Gutov
2015-08-01 10:21 ` Stephen Leake
2015-08-01 12:09 ` Dmitry Gutov
2015-08-01 14:20 ` Stephen Leake
2015-08-01 16:49 ` Dmitry Gutov
2015-08-01 19:08 ` Stephen Leake
2015-08-04 19:59 ` João Távora
2015-08-04 20:56 ` Dmitry Gutov
2015-08-04 22:43 ` João Távora
2015-08-04 23:35 ` Dmitry Gutov
2015-08-10 1:09 ` Dmitry Gutov
2015-08-10 3:07 ` Stephen Leake
2015-08-10 8:45 ` João Távora
2015-08-10 16:50 ` Stephen Leake
2015-08-10 19:38 ` João Távora
2015-08-10 18:07 ` Dmitry Gutov
2015-08-10 19:21 ` João Távora
2015-08-10 19:37 ` Dmitry Gutov
2015-08-10 19:47 ` João Távora
2015-08-10 19:55 ` Dmitry Gutov
2015-08-10 18:02 ` Dmitry Gutov
2015-08-07 15:02 ` Stefan Monnier
2015-08-07 15:32 ` Dmitry Gutov
2015-08-07 17:36 ` Stefan Monnier
2015-08-05 7:02 ` Stephen Leake
2015-07-30 21:31 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86wpxj93r2.fsf@stephe-leake.org \
--to=stephen_leake@stephe-leake.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.