[Top][All Lists]

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

Re: etags - Word separators with xref-find-definitions

From: Christian Barthel
Subject: Re: etags - Word separators with xref-find-definitions
Date: Sun, 25 Jul 2021 19:52:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Sun, Jul 25 2021, Eli Zaretskii wrote:

>> Is it possible to customize the xref function such that it
>> recognize ‘schema.objectname’?  Are there any variables to
>> control the behavior of M-. ?
> You need to customize the etags.el function that is used to guess the
> symbol at point.  The function is this:
>   (defun find-tag--default ()
>     (funcall (or find-tag-default-function
>                (get major-mode 'find-tag-default-function)
>                #'find-tag-default)))
> So either customizing find-tag-default-function to point to a function
> of your choice, or making such a function local to the SQL major mode
> by putting the property on the major-mode's symbol, should do the
> job.  You will probably need to write the function itself, though.

OK, thanks so far.  My first draft for this looks something like

--8<---------------cut here---------------start------------->8---
(defun find-sql-identifier ()
  (when (thing-at-point-looking-at
         "\\([.a-zA-Z0-9]*\\)" 50)
    (if (match-beginning 1)
        (buffer-substring (match-beginning 1) (match-end 1))
(put major-mode 'find-tag-default-function 'find-sql-identifier)
--8<---------------cut here---------------end--------------->8---

This works for my contrived SQL file as expected, but I guess
that I need some further improvements when using this on a larger
sql code repository .

I think that I will execute the put function (setting
find-tag-default-function) in the sql-mode-hook or is there a
better place to do this?

Christian Barthel

reply via email to

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