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

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

Find tags with dot character


From: Pascal Quesseveur
Subject: Find tags with dot character
Date: Mon, 22 Jul 2019 15:51:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Hello,

In Delphi methods are defined using notation ClassName.Method. Very
often I find it more interesting to look for tags using the name
ClassName.Method instead of the name Method. For example on a line

var x := MyClass.Create;

when the point is inside Create, by default the find-tag function
looks for a tag named Create. This tag is found and it corresponds to
the declaration of Create method in class MyClass. Instead I would
prefer to look for the definition of MyClass.Create. In addition,
there are inevitably several classes with the Create method in the
project with leads to ambiguities.

I can edit the tag name in the minibuffer before validating, but in
that case i have to type MyClass.Create in the minibuffer what I find
quite painful.

So I decided to change the way the dot character is taken into account
to build the expression around point. The most obvious thing for me
was to change the syntax entry for words. So I defined a function
which changes the word syntax entry before calling find-tag-default
and then restores the syntax:

(defun my-find-tag-default-opascal ()
  (let (tag)
    (modify-syntax-entry ?. "w")
    (setq tag (find-tag-default))
    (modify-syntax-entry ?. ".")
    tag))

And in Delphi mode hook, I added:

(setq find-tag-default-function 'my-find-tag-default-opascal)

This works fine, but I am wondering if i'm not reinventing the wheel
because I missed something.


-- 
Pascal Quesseveur
pquessev@gmail.com




reply via email to

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