help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Eli Zaretskii
Subject: Re: etags - Word separators with xref-find-definitions
Date: Sun, 25 Jul 2021 17:02:14 +0300

> From: Christian Barthel <bch@online.de>
> Date: Sun, 25 Jul 2021 10:56:01 +0200
> 
> I am using a TAGS file with a custom regex for SQL function, view
> and table definitions.  At the moment, I am using this:
> 
> --8<---------------cut here---------------start------------->8---
> etags --language=none \
>    --regex='/[ \t]*create\( or replace\)*[ \t][ 
> \t]*\(function\|view\|table\)[ \t]*\([^ (]*\)/\3/i'
>    *.sql
> --8<---------------cut here---------------end--------------->8---
> 
> The TAGS file contains identifiers like ‘schema.objectname’.
> However, when I am trying to use M-. (xref-find-definitions), it
> either searches for ‘schema’ or ‘objectname’ (depending on the
> location of the point).
> 
> 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.

> (Something similar happens for LaTeX references:  I am using
> \label{chapter:foobar}, but the : is lost and I can’t easily jump
> to the reference)

You could do the same there, just with a slightly different function.



reply via email to

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