[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generalizing find-definition

From: Stephen Leake
Subject: Re: Generalizing find-definition
Date: Tue, 04 Nov 2014 17:13:42 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.94 (windows-nt)

Stefan Monnier <address@hidden> writes:

>> I would also, but I would not expect a generic Emacs function to return
>> that.  It certainly requires a backend function.
> Agreed.
>> I'm still not clear what 'identifier-at-point' is good for outside "goto
>> definition", "show uses", and completion. Since the meaning is highly
>> backend specific, I don't see what other parts of Emacs might use it.
> I just know that it's used commonly.  Maybe it's always used by
> backend-specific code, so it could stay completely in each backend, but
> I don't see any reason why we couldn't standardize the name of that
> backend function, in case some non-backend specific code wants to
> use it.

The reason we can't standardize it is that "identifier-at-point" appears
to have different meanings/different results in different situations.

For "goto definition" and "show uses", ada-mode needs the simple word at
point (no dots; 'baz' in the example), together with the file name,
line, and column. "ada-identifier-at-point" only returns the simple
word, not all the information needed by "goto definition". Python needs
the file name, buffer text, line and column; it does not have an
implementation of "identifier-at-point", apparently.

For "completion", Python also apparently needs the same information as
for "goto definition". Ada mode will probably need the same info as for
"goto definition" as well.

None of these make sense for something called "identifier at point".
"xref-info-at-point" might make sense.

So without a list of other uses, it's hard to know how to define

I grepped thru ada-*.el for "-at-point", and found:


    Adjust case of the simple word before point according to the casing
    mode (typically capitalize first letter). Does _not_ call
    ada-identifier-at-point. "word" is defined by the syntax classes
    word and symbol. 


    discussed above

(thing-at-point 'symbol)

    Used to retrieve the simple word for the external xref engine, when
    in a C++ buffer; same meaning as ada-identifier-at-point. The
    external xref engine used by ada-mode is multi-lingual (see
    gpr-query in the ada-mode sources).

Note that thing-at-point does _not_ have an option 'identifier. Also
note that the meaning of 'symbol is not given anywhere; the docstring
for thing-at-point says "see thingatpt.el", but I don't see a definition
there. So apparently the definition is "whatever (thing-at-point
'symbol) returns", which is not very helpful.

The default implementation of (thing-at-point 'symbol) relies on the
word and symbol syntax classes, which is why it works for C++ mode. That
won't work for Ada mode, because "*" is an identifier for a function
that overrides *. (Hmm, I'm not sure 'symbol works for overloaded C++
operators, now that I think about it).

Note that the default implementation can be overridden by setting symbol
properties. So we could require a backend to do that to return the above
info, so "goto definition" could start by calling (thing-at-point
'symbol). But if we did take that approach, I'd argue it should be
(thing-at-point 'xref) instead.

So I'm still puzzled as to what other uses "identifier-at-point" might
have. If they are all either satisfied by thing-at-point or are strictly
back-end-specific, then we don't need anything new.

I grep'd thru emacs/lisp/* for "identifier-at-point"; there were _no_

I started grep'ing thru emacs/lisp/* for "-at-point". So far I've found
(ignoring things that don't return strings):

allout-parse-symbol-at-point - appears to be specific to allout

highlight-symbol-at-point - uses find-tag-default-as-symbol-regexp,
    which defaults to word and symbol syntax classes; could be
    (thing-at-point 'symbol).

thing-at-point - used by calc, cmuscheme, others

number-at-point - used by calc, defined in thingatpt.el, uses
    (thing-at-point 'sexp)

completion-at-point-functions - bound by functions in semantic, other modes

semantic-completion-at-point-function - defaults to
    semantic-ia-complete-symbol, which uses parse results. I'll call
    that backend-specific.

variable-at-point - used by cus-edit.el, uses word and symbol syntax
    classes, then does some more checks on whether it is a lisp symbol.
    could use (thing-at-point 'symbol)

... and I got tired. So far it's either backend or (thing-at-point
'symbol). There are about 1900 matches; that's a lot of information to
sort thru. 

-- Stephe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]