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

Using ggtags programmatically #120

Closed
csantosb opened this issue Nov 28, 2015 · 2 comments
Closed

Using ggtags programmatically #120

csantosb opened this issue Nov 28, 2015 · 2 comments

Comments

@csantosb
Copy link

I try to implement some logic on top of ggtags to manage vhdl sources. To achieve this, I need to act programmatically on buffer switching.

Say for example I am in buffer A. Then I declare

(defun test()
  (interactive)
  (search-backward-regexp "something")
  (previous-line)
  (end-of-line)
  (backward-char 2)
  (ggtags-find-definition (thing-at-point `symbol))
  (insert "test"))

to locate a tag "something" in buffer A, get to its definition in buffer B, and then insert some text in buffer B. However, when doing so I am inserting text in buffer A, even if point is at buffer B.

What am I doing wrong ?

@leoliu
Copy link
Owner

leoliu commented Nov 28, 2015

Hi @csantosb

ggtags is async so when ggtags-find-definition is fired you are still in buffer A. I think a more natural solution might be something along these lines.

  1. Set a custom ggtags-bounds-of-tag-function to tell ggtags how to get the tag at point; the default is to use the symbol at point.
  2. provide a function to ggtags-find-tag-hook that does the insertion of your text.

HTH,
Leo

@csantosb
Copy link
Author

I understand now: using the hook is the right approach. Thanks a lot !

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