Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems for search macros/variables at-point for verilog projects #981

Open
guoqinglei opened this issue Apr 28, 2022 · 6 comments
Open

Comments

@guoqinglei
Copy link

guoqinglei commented Apr 28, 2022

The emacs.d from redguardtoo is the config I have been using for over three months.
One of the reasons I like this is the fast start speed and proved high programming efficiency.
Recently, I want to use this config to develop some verilog projects. However, this config is not suitable in some cases. For example, when I press C-] at the point of a Macro, i.e.,
`DEF_MACRO, it reported "No tag is found. Grep "`DEF_MACRO" at directory: /bin/bash: -c: line 0: unexpected EOF while looking for matching `.

I wonder what I could do to fix it.

Another similar feature I am eagerly to want is that I usually need to search the variable/word at point . I know the command counsel-etags-find-tag-at-point can be used, but It only shows some definitions of this variable/word. Actually, I want to know all the occcurences of the variable/word in the buffer, just like the way of swiper or occur command works. Is there a command like swiper-at-point or occur-at-point ?

@guoqinglei
Copy link
Author

guoqinglei commented Apr 28, 2022

I have found some commands: isearch-forward-symbol-at-point and swiper-thing-at-point, it's almost well although not perfect.

The remaining question is: how to use the counsel-etags-find-tag-at-point to search the tag of Macro in verilog projects ? It's a little special that the Macro in verilog always comes with a prefix `.

I think counsel-etags-find-tag-at-point need to ignore the first character ` when do the job in minor mode of verilog.

@guoqinglei guoqinglei changed the title Problems for search macros/variables at-point for verilog projects development Problems for search macros/variables at-point for verilog projects Apr 28, 2022
@redguardtoo
Copy link
Owner

redguardtoo commented Apr 28, 2022

You can change ~/.ctags, add your own regular expression to parse new tags. See https://github.com/redguardtoo/counsel-etags#ctags-setup

Besides, you can write Emacs Lisp to update TAGS, see https://github.com/redguardtoo/counsel-etags#insert-extra-content-into-tags-file-after-its-updated

@guoqinglei
Copy link
Author

guoqinglei commented May 1, 2022

I think the problem may still exist for me. Actually I still prefer to improve the function of counsel-etags-find-tag-at-point.
For string " `MACRO " in the verilog code,
when the mouse point is at character "M", the tag this command will get is actually "`MACRO" instead of "MACRO",
here the character "`" is the cause of the problem.
Then the question is: how to ignore the special character such as "`" in verilog when we want to get the tag of the point ?

@redguardtoo
Copy link
Owner

You can customise counsel-etags-find-tag-name-function.

@guoqinglei
Copy link
Author

guoqinglei commented Jun 23, 2022

I may get what you mean. Maybe I need to modify the function counsel-etags-find-tag-name-default defined as follow:

(defun counsel-etags-find-tag-name-default ()
  "Find tag at point."
  (let ((tag-name (find-tag-default)))
    (when (and (memq major-mode
                     counsel-etags-major-modes-to-strip-default-tag-name)
           (string-match "^\\(`.*`\\|=.*=\\|~.*~\\|\".*\"\\|'.*'\\)$" tag-name))
      (setq tag-name (substring tag-name 1 (1- (length tag-name)))))
    tag-name))

The key point is to modify the lines with "string-match", is that right ?

@redguardtoo
Copy link
Owner

Yes. The tag name at point is found here. It's used as a keyword for searching the TAGS file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants