Comments (6)
Hi @leoliu .
I'm sorry for lack of enough test before the commit but I found recent commit cause another problem.
Now xref-find-definitions
doesn't find definition correctly if project root, which has GTAGS file is upper directory.
Simply, if the project structure is as follows, the definition of the function in test1.c cannot be found correctly within test2.c.
.
├── GPATH
├── GRTAGS
├── GTAGS
└── a
├── test1.c
└── test2.c
// test1.c
int test1(void) {
return 1;
}
// test2.c
extern int test1(void);
int test2(void) {
return test1(); // Can't find test1 correctly.
}
I tested file-truename
fix and it worked fine for this case.
Thanks.
from ggtags.
I was the one who suggested it :( Will take a thorough look later today. BTW, file-truename
may move outside the project so it has some downside.
Leo
from ggtags.
Sorry for the delay.
The issue is ggtags-make-xref-location
tries to construct location using project root plus relative filename. So it is critical to make default-directory
agree with the project root. Could you test this patch? Thanks.
diff --git a/ggtags.el b/ggtags.el
index caba1a3c..ba14d883 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -2417,7 +2417,7 @@ (defun ggtags--xref-collect-tags (tag root colored)
with re = (cadr (assq 'grep ggtags-global-error-regexp-alist-alist))
while (re-search-forward re nil t)
for summary = (buffer-substring (1+ (match-end 2)) (line-end-position))
- for file = (expand-file-name (match-string 1) root)
+ for file = (expand-file-name (match-string 1))
for line = (string-to-number (match-string 2))
for column = (string-match-p tag summary)
if colored do (setq summary (ansi-color-apply summary)) end
@@ -2450,12 +2450,13 @@ (defun ggtags--xref-find-tags (tag cmd)
(ggtags-project-has-color project))))
(kill-buffer (current-buffer)))))
(ggtags-with-current-project
- (ggtags-global-output
- (get-buffer-create " *ggtags-xref*")
- (append
- (split-string (ggtags-global-build-command cmd))
- (list "--" (shell-quote-argument tag)))
- collect ggtags--xref-limit 'sync)
+ (let ((default-directory (ggtags-current-project-root)))
+ (ggtags-global-output
+ (get-buffer-create " *ggtags-xref*")
+ (append
+ (split-string (ggtags-global-build-command cmd))
+ (list "--" (shell-quote-argument tag)))
+ collect ggtags--xref-limit 'sync))
xrefs)))
(cl-defmethod xref-backend-definitions ((_backend (eql ggtags)) tag)
from ggtags.
@leoliu Thank you a lot for your patch. I tested in various way and the patch worked as good as file-truename
fix. However I found another problem from both 'file-truename' fix and your patch.
From the main.c of the first example project structure (#218 (comment)), if I find DEF_TEST2
which is defined in test1.h, ggtags-find-definition
jump to a/b/test1.h
, but both file-truename
fix and your patch makes jump to b/test1.h
. And it makes further searching unavailable(ex. finding DEF_TEST3 in test2.h)
So I think it would be much better if the fix would work as ggtags-find-definition
.
Thanks.
from ggtags.
@leoliu I think I confused test result of your patch and the result of file-truename
fix. Now I tested again and found your patch works as same as ggtags-find-definition
. I think it works good for all cases I mentioned above. Thank you so much!
from ggtags.
@tttuuu888, pushed. Thanks a lot for the thorough tests.
from ggtags.
Related Issues (20)
- How to use this gtags-cscope feature from ggtags.el
- CPU is pinned to 100%, with excessive gtags processes spawned HOT 6
- ‘global’ non-zero exit: sh: global: command not found HOT 2
- POSIX realpath required
- wrong-type-argument error on compilation-auto-jump timer
- ggtags causes company-capf to fail when GTAGS doesn't exist
- ggtags-fontify-code conflicts with hl-line-mode HOT 1
- ggtags doesn't work with xref in Emacs 27.2 since latest update HOT 3
- GTAGSLIBPATH not searched HOT 1
- `ggtags-fontify-code` should be called optionally HOT 2
- With tramp: Error running timer ‘compilation-auto-jump’: (wrong-type-argument stringp nil) HOT 5
- xref-pop-marker-stack doesn't return to previous location HOT 1
- Use default gtags backend unless GTAGSLABEL is set
- Enhancement: Use Emacs' sqlite API (built-in or via module)
- Make integration with xref and capf user configurable
- Compile warnings with latest emacs master
- final message interpreted as a match HOT 2
- Support for --literal argument
- Incompatibility with xref: xref--marker-ring, xref--history, etc.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggtags.