leoliu / ggtags Goto Github PK
View Code? Open in Web Editor NEWEmacs frontend to GNU Global source code tagging system.
Home Page: http://elpa.gnu.org
Emacs frontend to GNU Global source code tagging system.
Home Page: http://elpa.gnu.org
Due to a bug in GNU Global it may erroneously report 0 matches, see this report http://article.gmane.org/gmane.comp.gnu.global.bugs/1615
Suppose my cursor is on a function call, foo()
:
M-.
(ggtags-find-tag-dwim) jumps to foo()
definition. M-.
switches to reference.M-*
(ggtags-navigation-mode-abort) to abort current ggtags navigation and returns to the original foo()
call. This is what I expected.Result: ggtags returns me to foo()
definition instead of the original where I invoked ggtags-find-tag-dwim
.
ggtags-find-tag-dwim
switches back and forth between a tag definition and its references of a tag. However, upon returning, it resets the current point on the reference buffer to its beginning location.
hi, i try seperate TAGS dir from source root path, like this
my code root path is /opt/redis ,and i create global tag path in $HOME/.globaltags/redis
GPATH GRTAGS GTAGS
when i open a c file in /opt/redis use vim ,and load gtags-cscope plugin automatically
my .vimrc content for GtagsCscope
let GtagsCscope_Auto_Load = 1
let GtagsCscope_Auto_Map = 1
let GtagsCscope_Quiet = 1
set cscopetag
:map <C-]> :GtagsCursor
but when i search func definition use <C-]> it say Error: GTAGS not found ,why?
i find problem is
1
../../root/.globaltags/redis/src/intset.c 81 static void _intsetSet(intset *is, int pos, int64_t value) {
../../root/.globaltags/redis/src/intset.c 81 static void _intsetSet(intset *is, int pos, int64_t value) {
relative path cause problem ,and how can i fix it? it seems gtags vim plugin problem!
I have a bit of a thing about clutter in my modeline. There's just not enough space for every minor mode to add whatever it wants to it. While I'm sure the ggtags project name is useful to many people, it isn't that useful to me, so I remove it. I'm currently doing this by adding (setq ggtags-mode-line-project-name "") to my init file.
This does work fine, so feel free to close this ticket as not-a-bug. But it would be nicer if instead of having to overwrite that variable there was another one for whether or not the project name is shown. e.g. ggtags-mode-show-project-name-in-modeline. And this should be configurable via customize.
Thanks
I'm used to, and completely happy with, the regular grep/compilation mode keybindings. Is there any way to disable navigation mode from being turned on?
Great package by the way, thanks!
Hi,
I've been using ggtags and there is a problem with ggtags-find-tag when the path to my project contains a symlink in it.
It seems that gnu global does not handle symlinks very well. When generating the GTAGS db it expands filenames. On the other hand, when you run 'global' and pass it a filename with symlinks, it does NOT expand it. It thinks the file is out of the source tree.
The problem in ggtags happens whenever my buffer points to a file and the path contains symlinks. The function 'ggtags-find-tag' uses 'expand-file-name' which does not expand symlinks. This path is then given to 'global' and we get the problem explained above.
Changing 'expand-file-name' to 'file-truename' (which does expand symlinks) solves the problem.
Thanks!
GNU Global generates these 3 files:
It would be nice if we can completely multiple tag database from multiple sources. This is useful if I want to load tag databases from sources outside of my project root, i.e. system include files or library code that does not belong to the current project.
Is it possible to load tag name with prefix GTAGS, GRTAGS, GPATH? For example, the default project has the name GTAGS, GRTAGS, GPATH. But I may name the external source code GTAGS2, GRTAGS2, GPATH2 and place these files in project root.
Hi, really useful package!
I've been using ggtags and there is one thing that It does that I think is kinda wrong:
It ignores the emacs settings for splitting windows.
Since we have these huge long monitors these days, I setup emacs to never split vertically automatically with (setq split-height-threshold nil).
Is it possible to remove the two 'let's that override split-window-default-function on ggtags? (this is what i did)
Or maybe have a config variable 'ggtags-force-vertical-split' that you can set to 't' when you really want to override the emacs default.
Thanks!
See upstream report http://debbugs.gnu.org/16933
I am getting the following error on my C source projects when I run M-. or M-] on a tag of interest. The files GTAGS, GRTAGS, and GPATH have been previously created in the root folder. (I haven't tried a C++ or Java project to replicate the error.)
`let' bindings can have only one value-form: process-environment,(if (ggtags-cache-ctags-p (ggtags-root-directory)) (cons "GTAGSLABEL=ctags" process-environment)), process-environment
Here is my version information:
OS: OS X 10.8.5
Emacs version: 24.3.1 installed via homebrew
Global version: 6.2.9 installed via source
ggtags version: From git commit 079b8d3
My barebones .emacs file:
setq load-path (cons "~/.emacs.d/ggtags" load-path))
(autoload 'ggtags-mode "ggtags" "" t)
Note: I haven't seen this issue on Ubuntu 12.04 with the same version of emacs, global and ggtags.
Thanks in advance.
Whenever I ggtags-query-replace
, I get:
call-interactively: Wrong number of arguments: (2 . 3), 4
Some of the key bindings used by ggtags are in conflict with these defined by ErgoEmacs mode. According to this: http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html appropriate hook should be used to modify keymap for given mode, but it seems that ggtags don't provide it. Am I missing something or maybe is there another way to modify default key bindings?
With "history" as the default, jumping back from a tag definition using ggtags-find-tag-dwim
returns to the previous match the cursor was on, not the first match.
I occasionally found this project and find it really interesting. The ggtags-navigation-mode is really great, and it makes the navigation much more friendly!!!
I am also a user of Source Insight. Some concepts of Source Insight are handy. For example, it instantly matches and shows the tags that user types, it instantly locates the file path, and it provides the ability to go back and go forward. Maybe this project could adopt some of the concepts, which I'm sure will increase the user experience.
I'm using
GNU Emacs 24.3.50.1
gtags - GNU GLOBAL 5.7.1
ggtags-20131221.36
in elpa/
ace-jump-buffer-20131221.759 goto-chg-20131228.1459
ace-jump-mode-20140207.530 key-chord-20080915.2156
archives magit-20140211.454
auto-complete-20140208.653 paredit-20140128.1248
company-20140211.2152 pkg-info-20131101.408
dash-20140208.1020 popup-20140207.1702
epl-20140211.524 powerline-20131126.1817
evil-20140209.836 projectile-20140212.110
evil-matchit-20140212.350 s-20131223.944
expand-region-20140127.112 smartparens-20140211.411
flx-20130728.820 smex-20140131.1006
flx-ido-20131030.1243 undo-tree-20140110.616
ggtags-20131221.36 xcscope-20140128.1356
git-commit-mode-20140125.1553 yasnippet-20140106.1009
git-rebase-mode-20140125.1553 zenburn-theme-20140212.457
I did:
emacs -q
(package-initialize)
C-x f somedirectory/somefile.c
(ggtags-mode)
(ggtags-find-tag-dwim)
I get this error only in certain directories...
use ctags backend? no
`gtags' in progress...
GTAGS generated in `/media/sf_company/project/some_driver/'
Error: (error "`global' non-zero exit: global: both of -s and -r are not allowed.")
After trying ggtags-find-tag-dwim:
-*- mode: ggtags-global; default-directory: "/media/sf_company/project/some_driver/" -*-
Global started at Wed Feb 12 10:18:04
global -v --result=grep -d ADS1248_Init
global: invalid option -- 'd'
Usage: global [-aGilnqrstTvx][-e] pattern
global -c[qrsv] prefix
global -f[anqrstvx] files
global -g[aGilnoOqtvx][-e] pattern
global -I[ailnqtvx][-e] pattern
global -P[aGilnoOqtvx][-e] pattern
global -p[qrv]
global -u[qv]
Global exited abnormally with code 2 at Wed Feb 12 10:18:04
Using vanilla gtags-mode seems to work fine though...
Ask for ggtags-mode-hook.
I have used xgtags for a long time, now completely switch to this ggtags: very simple and intuitive, very good job!
I'm wondering if it's easy to parse the output from global generally, to prioritize "Htree2::Htree2" the constructor in this example. (very common in C++ code, maybe post-process the output is a good idea, not sure there is a better way?)
I am trying to use ggtags with tramp. ggtags-create-tags works fine and creates GTAGS, GPATH, GRTAGS on the remote machine. But ggtags-find-reference and ggtags-find-file result in "No such directory found via CDPATH environment variable". The backtrace is as follows: It looks like the cd("/proj/src") is being done on the local machine instead of the remote machine.
Debugger entered--Lisp error: (error "No such directory found via CDPATH environment variable")
signal(error ("No such directory found via CDPATH environment variable"))
error("No such directory found via CDPATH environment variable")
cd("/proj/src/")
compilation-start("global -v --result=grep --path-style=shorter TestStruct" ggtags-global-mode)
ggtags-global-start("global -v --result=grep --path-style=shorter TestStruct")
ggtags-find-tag(definition "TestStruct")
ggtags-find-tag-dwim("TestStruct" nil)
call-interactively(ggtags-find-tag-dwim nil nil)
I am using Emacs 24.3.1 and ggtags-0.7.9.
Hi Leo,
Could you suggest a fix to Projectile's use of ggtags-completion-table
: bbatsov/projectile#322 ?
After jump to another file via ggtags-find-tag-dwim, it is good to have a command for jumping back to the previous buffer!
The old gtags.el provides gtags-pop-stack, but after popping the stack the history is discarded. Could you please add the feature to maintain the history so that people can go-back and go forward like a web browser. Maybe a queue or something similar could be used instead of a stack.
After doing a M-. to look up a tag, ggtags closes my ECB compilation window.
So far, I have been using xgtags, but that one leaves its tag window open all the time, which is also annoying.
If you do M-]
and you get some output in the *ggtags-global*
buffer then you can not do M-.
. You must press RET
or M-*
to make M-.
work again.
This can be also reproduced if you do M-.
and global
returns an error because the file is in a symbolink directory and the you immediately do C-u M-.
to force definition finding without --from-here
gtags-find-tag-from-here can be used to find tags, symbols and references but it seems that symbols finding feature is missing. Sometimes searching a variable is quite useful.
The default key-binding of ggtags is a little intrusive. It is good to make it controllable to apply these key-bindings or not.
I'm not sure if the title is exactly right or if this is a bug or not, but when I do a query-replace-regexp from dired (select a bunch of files and type Q), I get an error from ggtags "No global buffer found" whenever one continues the search with M-, within a file with ggtags-mode enabled. I know that ggtags-mode uses M-, but it is also a continuation command for several things.
HI, i use emacs in cygwin, i use this elisp for global, but i create database in ggtags-find-tag, but no result and return message:
cd: No such directory found via CDPATH environment variable
hi leo, thanks for this wonderful utility!
Could u please add a function "list all tags in current buffer" in next version?
M-.
finds reference or definition according to tag at point. However, upon returning from definition to reference, it does not keep the previous reference the cursor was on. This is inconvenient for a large number of matches: we have to switch to ggtags buffer and scroll down to move the cursor to previous reference to continue navigation.
ggtags cannot find some symbols that can be found with global
. The command used for retrieving symbols in ggtags is:
global -v --result=grep --path-style=shorter -s dhcpctl_new_object
ggtags produces nothing. Global is able to return the result:L
dhcpctl.h:109:dhcpctl_status dhcpctl_new_object (dhcpctl_handle *,
omapi_test.c:18: dhcpctl_new_object(&host, connection, "host");
2 objects located (using '/home/xtuudoo/test_gtags/GSYMS').
You can get the sample files from the issue I created in Global mailing list: http://lists.gnu.org/archive/html/bug-global/2014-04/msg00018.html
Edit: ggtags produces this error message:
Find tag NAME that is a reference without a definition.
From discussion b6c4f00
9cf2d44 might cause the trouble. I use this example to reproduce.
int main()
{
bar();
bar();
bar();
bar();
bar();
}
bar()
. ggtags-navigation-mode
is enabled in the C/C++ buffer correctly.ggtags-navigation-mode
doesn't enable on the C/C++ buffer. It is enabled on the ggtags-global buffer instead.I tried out your package but I get an error message when I execute any command.
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading cc-langs...done
Loading vc-git...done
Ggtags mode enabled
Making completion list...
compilation-start: Wrong type argument: window-live-p, ggtags-global-modeError during redisplay: (eval (ggtags-ensure-global-buffer (let ((index (when (get-text-property (line-beginning-position) (quote compilation-message)) (- (line-number-at-pos) 4)))) (\` ((:propertize (\, (if index (number-to-string (max index 0)) "?")) face success) "/"))))) signaled (error "No global buffer found")
Error during redisplay: (eval (ggtags-ensure-global-buffer (let ((index (when (get-text-property (line-beginning-position) (quote compilation-message)) (- (line-number-at-pos) 4)))) (\` ((:propertize (\, (if index (number-to-string (max index 0)) "?")) face success) "/"))))) signaled (error "No global buffer found")
I have version 20131202.1830
Emacs 24.3.1
global 6.2.9
I cannot change project root unless I use dired
or or open a file in another project. ggtags
should automatically change project root whenever user visits a directory that contains Global
files (GPATH, GRTAGS, GTAGS).
Edit: This is the case when I'm using shell
or eshell
to go to another project.
Example code:
#include <stdio.h>
typedef int (test_t) (int a);
struct test {
test_t *test_func;
};
int test_a (int a) {
return a + 1;
}
int main(int *argc, char argv[])
{
struct test a;
a.test_func = test_a;
return 0;
}
If you execute ggtags-find-tag-dwim
on tag test_t
, instead of jumping to typedef int (test_t) (int a);
, it opens a reference buffer. In other words, ggtags treats typedef definition as reference.
ggtags is really a good minor mode, and I like very much. But after some time's exploration, the "jump back" feature is missing from the original "gtags.el", consider the follow code:
void func() {
// do something here...
}
void test1() {
func();
}
void test2() {
// ...
func();
// ...
}
Now the cursor is at func()
invocation in function test2
, then I press M-.
to have a look at the definition of func
, and after that, of course I want to go back to test2
to continue my previous work, but after I press M-.
, it takes me to test1
and popup a window for me to choose, the code above only has two references of func
and it is easy for me to go back to test2
, but if there are so many references of func
, it should be a tough job to find previously where I was.
So I think the jump back feature is really helpful, hope it will be implemented later. :-)
If I generate GTAGS files at the project root, open files belong to that project and jump to a tag definition, ggtags can find that definition. But if I add new file, include an existing tag from the project and try to jump to that tag, ggtags
won't be able to find anything, except if I update using ggtags-update-tags
.
In
(defun ggtags-get-libpath ()
(split-string (or (getenv "GTAGSLIBPATH") "") ":" t))
":" is used as path separator which is not the case on windows platform. Instead path-separator variable could have been used. On windows platform Emacs documents it as:
path-separator is a variable defined in `C source code'.
Its value is ";"
Documentation:
String containing the character that separates directories in
search paths, such as PATH and other similar environment variables.
I'm just getting started with gtags, so this is probably just a silly mistake on my part, but perhaps if I can figure out what is going wrong, your README can be further improved to help other people.
I'm on OSX. Emacs 24.2.1.
I did brew install global, which installed global-6.2.4. I installed ggtags using m-x package-install and selecting ggtags.
I ran gtags (with no options) in my project root and then did m-x ggtags-mode.
I get the error message: "File GTAGS not found"
I tried gtags (not ggtags) and it did find the TAGS file I had generated, but complained that it wasn't a valid TAGS file.
Does anything jump out at you here? Obviously the problem is not with ggtags, as I said. But perhaps the documentation could help a n00b gets started quicker.
In gtags-mode it is possible to search for a tag simply by clicking on it with mouse-2. That is, without the need to move emacs pointer there.
Is there a way to achieve the same behavior in ggtags-mode?
Thanks in advance!
Using the linux kernel as an example, global -u
could take from 0 to 22 seconds. One possible solution is to use global --single-update
instead. Populating the tag names cache takes about 3 seconds due to the large number of definitions (1.1 million).
Also, ggtags-highlight-tag-at-point
should not trigger any cache update because it can be slow and as a result cursor movements become sluggish.
I'm not sure if this is expected behavior or if I am missing something, but the ggtags-after-save-function
hook only updates the DB if the project is oversized:
https://github.com/leoliu/ggtags/blob/master/ggtags.el#L1275
Surely if the project is non-oversized, the DB should also be automatically updated, irrespective of whether global --single-update
or global -u
is used to do the update?
Following on from that, I'm thinking that's its possible to just remove the oversize check in ggtags-after-save-function
and just call global --single-update
. Consider the following example - When a single source file is changed and then saved, one can assume that only tags related to that file have been changed, and as such, global --single-update
will produce exactly the same results as global -u
.
I altered the behavior on my install, by just running global --single-update
regardless of whether the project is oversized or not.
(defun ggtags-after-save-function ()
(when (ggtags-find-project)
(ggtags-project-update-mtime-maybe)
(when buffer-file-name
(ggtags-with-current-project
(process-file "global" nil 0 nil "--single-update"
(file-relative-name buffer-file-name))))))
Since a recent upgrade, ggtags is now slow as hell. I hit a recursion limit and get the following backtrace in this case:
Debugger entered--Lisp error: (error "Lisp nesting exceeds `max-lisp-eval-depth'")
(and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers)
(cons (quote cygwin-mount-map-drive-hook-function) (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers))
(cons (quote cygwin-mount-name-hook-function) (cons (quote cygwin-mount-map-drive-hook-function) (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers)))
(cons (quote tramp-completion-file-name-handler) (cons (quote cygwin-mount-name-hook-function) (cons (quote cygwin-mount-map-drive-hook-function) (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers))))
(let* ((inhibit-file-name-handlers (cons (quote tramp-completion-file-name-handler) (cons (quote cygwin-mount-name-hook-function) (cons (quote cygwin-mount-map-drive-hook-function) (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers))))) (inhibit-file-name-operation operation)) (apply operation args))
tramp-completion-run-real-handler(expand-file-name ("global" "/sbin"))
(if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate)))) (tramp-completion-run-real-handler operation args))
(let ((directory-sep-char 47) (fn (assoc operation tramp-completion-file-name-handler-alist))) (if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate)))) (tramp-completion-run-real-handler operation args)))
tramp-completion-file-name-handler(expand-file-name "global" "/sbin")
call-process("global" nil t nil "-pr")
apply(call-process "global" nil t nil "-pr")
process-file("global" nil t nil "-pr")
apply(process-file "global" nil t nil "-pr")
ggtags-process-string("global" "-pr")
#[0 "\301\302�!\303\304\305\"P!\207" [default-directory file-name-as-directory file-remote-p ggtags-process-string "global" "-pr"] 5 "\n\n(fn)"]()
ggtags-find-project()
ggtags-find-project()
[...]
ggtags-find-project()
ggtags-ensure-project()
ggtags-visit-project-root()
call-interactively(ggtags-visit-project-root nil nil)
Hi,
searching for class members fails under some circumstances, because global is called with a wrong (and unnecessary) parameter.
Example:
searching for the function definition of 'BreakBond', called by the line (with M-.):
model->particle_list[i].BreakBond();
leads to the following error:
Global exited abnormally with code 2
The actual command issued by ggtags is:
global -v --result=grep -d BreakBond
the correct command would have been:
global -v --result=grep BreakBond
(without '-d')
This error doesn't appear always, and I'm still figuring out the details. But when it occur its pretty annoying. Searching references still works.
Assume the following scenario:
/projectA/a.c
void aa() {
bb();
}
/projectB/b.c
void bb() {
aa();
}
In the /projectA
directory you have a symbolink of the /projectB
directory. So, /projectA/projectB/b.c
is valid. You run gtags
in the /projectA
directory.
Now, If you do M-.
over the bb();
, ggtags focus to bb
function of b.c
file as expected. But, if you do M-.
over the aa();
, ggtags will ask you the following:
File GTAGS not found; run gtags? (y or n)
Can you fix this?
Also if I do y
and then choose the /projectA
I get the following error:
global: '/projectB/b.c' is out of the source project.
Sometimes, jumping to a definition/reference puts the cursor at the bottom of the buffer. To read code, user has to recenter the buffer. To make it convenient, when jumping to a tag, ggtags should automatically recenter the cursor to top line.
Exiting from navigation mode with RET does not work when I've done something like this myself:
(add-hook 'c-mode-common-hook
(lambda ()
(local-set-key (kbd "<return>") 'c-context-line-break)
))
Is it possible to define keymap so that user defined key bindings would not hijack RET from ggtags in navigation mode?
Current implementation of compile.el
pops up the compilation window unconditionally which has an unfortunate disturbance for 0 or 1 match. See upstream bug report http://debbugs.gnu.org/13594.
This feature allows users to be easily query tags according to their interest. Users can group related tags into a group with the same label, later users can query the related tag by specifying a specific label. There should be a command to list all labels and user can quickly select one or multiple labels.
Rationale: During the course of code navigation, developers need to look into various tags. Not all of these tags are directly related to each others, but indirectly and need to develop in parallel.
For example, in developing client and server, response and request features are usually developed together and can be used to test each other. To understand, maintain and develop such a pair of features, usually a developer has to read the source code of both features back and forth. The developer wants to understand how the server stores request in a buffer and schedule which request got processed first. He got dozen of tags for this feature mixed with dozen of tags of other features in the same *Ggtags Search History*
. If he continues to work to understand this whole application, maybe there would be too many tags and the buffer becomes unmanageable. The developer feels like he brought almost his whole GTAGS database into *Ggtags Search History*
, to the point that the buffer is no longer useful. He either has to flush the buffer and start new again, spending time collecting already visited tags the next time he needs to work on the project again.
Why couldn't the developer reuse his knowledge from the last time he worked with his source code? After working with it once, he knows which tag related to which tag. Now, he has to open and looking around files, and potentially miss some important tags, which he worked last time; eventually he will have to come back to these important tags but it costs him time and effort on thing he already did. With labeling and saving features, he can save time by not repeating himself. Further more, if someone wants to work on things he already worked, he can give them his "experience".
My current workflow is similar to the example above. A worked on a feature. Few months later, I have to work on it again (fix bug or enhance it). But after few months (or a year, or a few years), I have to "restudy" by reading the source code again and jump to already jumped tags in the past, and I have to filter the related and unrelated tags to my feature. I would love to not repeat myself again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.