[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Find tags with dot character
From: |
Stefan Monnier |
Subject: |
Re: Find tags with dot character |
Date: |
Mon, 22 Jul 2019 11:36:39 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> (defun my-find-tag-default-opascal ()
> (let (tag)
> (modify-syntax-entry ?. "w")
> (setq tag (find-tag-default))
> (modify-syntax-entry ?. ".")
> tag))
In case of an error (or a C-g) during the execution of find-tag-default,
this will fail to restore the syntax-table to its original state, so
I recommend:
(defun my-find-tag-default-opascal ()
(unwind-protect
(progn (modify-syntax-entry ?. "w")
(find-tag-default))
(modify-syntax-entry ?. ".")))
> And in Delphi mode hook, I added:
>
> (setq find-tag-default-function 'my-find-tag-default-opascal)
This likely affects the variable globally, so maybe you'd want to use
`setq-local` instead.
> This works fine, but I am wondering if i'm not reinventing the wheel
> because I missed something.
I know the general issue of namespaces is not handled very well by the
etags support. Your approach above will make thing worse in several
important use cases (e.g. when point is on "<var>.<method>" where we
won't find that tag anywhere (we'd have to lookup something like
"<class>.<method>" instead)), so it's not really something we can use as
is by default, but I think we'd welcome patches which try to improve on
this (e.g. by first trying with the dots and if that fails try again
without them).
Stefan