Description
Hi There!
Due to the slight difference between definition and mention of (System)Verilog macro symbols, tag tables generation tools, like ctags family members (with particular reference to universal ctags, for its use model adopted by GNU Global) usually require to duplicate the tag identification with and without the ` prefix. With direct usage of universal ctags this is usually handable, even though a bit silly.
As ggtags.el uses GNU Global, reported to be quite more powerful than simple etags/ctags, and Global, on its turn, uses (among others) universal ctags, and controlling universal ctags in the GNU Global stack, even via the gtags.conf file, appeared NOT to work, even when adding the required extra tag entry
:regex-SystemVerilog=/^\s*`/define\b\s*(\w+)/`\1/d,define/:
(that worked with universal ctags when used stand-alone) a different approach was taken looking at the way ggtags+ElDoc perform the useful overlaying that allows to spot which elements can be subject of further inspection.
In facts ggtags uses, on its turn, elements from a quite historical Emacs package, thingatpt.
That was conceived to be extended by means of bound "providers", that, if present, are called in order until one returns non-nil. The current proposal uses that solution.
In essence it all goes down to provide the boundaries of the symbol at point, should it be a macrosymbol, removing the ` prefix, so that, then, GNU Global can properly handle it.
The solution I set up and tested with Emacs 31.0.50, and ggtags.el taken by straight (the header in my copy says "version: 0.9.0"), and working with GNU Global 6.6.10, and universal ctags 6.1.0:
Here's the code
(defun verilog-bounds-as-macro()
(save-excursion
(let (b e)
(backward-sexp)
(and (eq ?` (char-after))
(progn
(setq b (1+ (point)))
(forward-sexp)
(setq e (point))
(cons b e))))))
(setq-local bounds-of-thing-at-point-provider-alist '((symbol . verilog-bounds-as-macro)))
The last part needs to be placed somehow inside the verilog-mode.el file, so to let verilog files take that in action; I haven't included any wrapping precaution as I noticed bound-of-thing-at-point-provider-alist
to be nil
in all verilog buffers I checked.
HTH,
Andrea.