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

add --scope' argument support when global' command is built. #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thekondor
Copy link

The motivation for this change is be able to specify search scope for global command execution. Currently that is impossible and a user should override ggtags-global-build-command implementation to add the corresponding argument.

@thekondor
Copy link
Author

Hello,

Sure, I can. In my case I have a large project (~6Gb source). The project consists of subprojects. When I am sure in which subproject to search in, I would specify the scope explicitly:

  • That reduces the total search time.
  • That reduces the total amount of results.

@leoliu
Copy link
Owner

leoliu commented Jun 9, 2015

The option seems to take a directory so the patch won't work as is. the good news is there is a new feature in global that allows sorting tags by current directory first then parent directories. The new feature seems superior to -S or -l. Could you try it out? See #99 for details.

@thekondor
Copy link
Author

Hello @leoliu,

Thank you very much for the feature with the sorting; it works like a charm. I have noticed when a scope dir through --scope is explicitly set the total CPU and IO usage is much less (at least in my environment).

option seems to take a directory so the patch won't work

Actually it is :). I use the patch in the following way (here I have simplified my actual snippet due for clarity):

    (defun my-ggtags-grep ()
      (interactive)
      (let ((ggtags-global-search-scope nil))
        (when (derived-mode-p 'dired-mode)
          (let ((scope-dir (dired-replace-in-string (ggtags-current-project-root) "" (dired-current-directory))))
            (if (> (length scope-dir) 0)
                (setq ggtags-global-search-scope (directory-file-name scope-dir)))))
        (ggtags-grep)))

So when a buffer with dired is active the current directory is considered as a scope to search within. I find that is very handy.

@leoliu
Copy link
Owner

leoliu commented Jun 23, 2015

Hi @thekondor,

Thanks for the feedback. Am I right in assuming that you want to limit the search to current directory? Let me think and find a way to have this in ggtags.

Leo

@mnp
Copy link

mnp commented Mar 22, 2018

I love this idea and have a different use case. I too have a giant project and would like to limit tagging to a subset. One option is adding a gtags.conf file, which might work but it's super hostile and inconvenient if you just want to say "do these two directories". Using something like this, I'd like instead to drop a .dir-locals.el file into the project and specify this config var in there.

This has its limits though, unless --scope or -l can be repeated, because what I really want is more like find MY_SPECS | gtags -f -.

PS. I bit the bullet and decided to use gtags.conf to generate its own gtags.files via the hook function, new in version 6.5.6. For the best writeup with examples see the release notes. Mine looks like this, by copying the system gtags.conf file to local project, then edit the gtags or default target:

...
gtags:\
        :gtags_hook=find mydir1 mydir2 mydir3 -name \*.java -print > gtags.files:
        :tc=common:\
        :tc=builtin-parser:
...

@leoliu
Copy link
Owner

leoliu commented Mar 23, 2018

@mnp Nesting projects is possible since the beginning of ggtags when I used the linux kernel source as a test ground. M-x ggtags-create-tags and find the sub directory tree to index. Hereafter ggtags will treat that subdirectory as a project. This might predate --scope. Last time (quite a while ago) I checked --scope there were some subtleties that made it less useful. I will find time to look into it again.

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

Successfully merging this pull request may close these issues.

3 participants