all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christian Barthel <bch@online.de>
To: help-gnu-emacs@gnu.org
Subject: Re: etags - Word separators with xref-find-definitions
Date: Sun, 25 Jul 2021 19:52:58 +0200	[thread overview]
Message-ID: <87im0ys2kl.fsf@online.de> (raw)
In-Reply-To: <83o8aqwkyh.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 25 Jul 2021 17:02:14 +0300")

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
this:

--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	other threads:[~2021-07-25 17:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-25  8:56 etags - Word separators with xref-find-definitions Christian Barthel
2021-07-25 14:02 ` Eli Zaretskii
2021-07-25 17:52   ` Christian Barthel [this message]
2021-07-25 19:04     ` Eli Zaretskii
2021-07-26 14:45     ` Leo Butler

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=87im0ys2kl.fsf@online.de \
    --to=bch@online.de \
    --cc=help-gnu-emacs@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.