6 ms·
>very useful "grep for UI text" trick Just, one thing: for C/C++ code-bases such as gdb, stop using grep for things, people! Use cscope! 'tis a brilliant me
by mmjaa 9y ago
>very useful "grep for UI text" trick
Just, one thing: for C/C++ code-bases such as gdb, stop using grep for things, people! Use cscope! 'tis a brilliant means of navigating files and scoping out the contents of a project.
http://cscope.sourceforge.net http://cscope.sourceforge.net
$ cd gdb/src; cscope -R
- dahart 9y agoLooks handy! I think I'll start using it for a few things. But, I probably won't stop using grep, these tools don't really compete.
- mmjaa 9y agoOoh, grep is definitely useful, no question .. but cscope, in the right hands, can be far, far more productive .. try it and see!
- cryptonector 9y agocscope is a sine qua non of C (and even C++ and Java) development. Of course, with OOP languages a dumb lexical indexer is not that useful (this applies to OpenGrok and many others too) -- if you're looking for calls to the getName() method of a particular class (and sub-classes) in a huge codebase then you'll be in for a lot of pain. But for C cscope is absolutely fantastic and much much better than etags/ctags.
- bch 9y agoI use cscope in conjunction w ctags. cscope (which will launch an editor, appropriately ) for a top-level overview/dive, and ctags (from w/i my vi instance, whether vi was launched from cscope or not) when I’m zeroing-in on a problem and can chase down thoughts and maintain my way back out because navigation is pushing/popping on a stack. No need for either/or; use them both.
- mmjaa 9y agoI find that cscope integration in vim supersedes any need for ctags. For why is ctags not just a subset?
- bch 9y agoI'm a BSD nvi user, so no vim for me. I do apparently have access to cscope database from w/i nvi, but my finger muscle memory wrt (ex)ctags support gets me a long way (perhaps I could do better w/ cscope? Something to look into.) I'm not sure how to parse your last question -- rephrase ?
- cryptonector 9y agoYou would do better with cscope. Just try it. If you want I'll post the $CSCOPE_EDITOR wrapper script I use.
- bch 9y agoI did work out the (ex) usage for in-editor cscope in nvi (for the curious, in nvi(1) after building the cscope db: :cscope add ./cscope.out :cscope find g myfunc :cscope find e [Ss]ome.expres*ion Anyway, otherwise - yes, interested to see your $EDITOR script.
- cryptonector 9y agohttps://github.com/cryptonector/cscope_editor https://github.com/cryptonector/cscope_editor
- mmjaa 9y agoLast question: ctags is a sub-set of cscope, in that cscope does all that ctags does, and more. Anyway, I concur with your reasoning: bsd vi and muscle memory. Works for me!
- cryptonector 9y agoI find it easier to cut-n-paste (with tmux) the symbol I want to chase down, pasting it into cscope. The reason this is better is that ctags doesn't do what I want. I may want to see functions called by some symbol (ctags no help), functions calling that symbol (two ctags operations required), or assignments to a variable (ctags no help) or even just a full-text search (again, ctags no help). I don't need $EDITOR cscope integration because I have an easier time tracking appropriately-titled tmux windows than I do tracking $EDITOR buffers (not least because tmux windows are more general!), so I really want a new tmux window with a new $EDITOR instance. Thus the cut-n-paste approach, while it requires a few more keystrokes than I might like, works best. I could always do my own integration that uses tmux to programmatically write the symbol I want to the cscope window, but I don't feel the need.
- draw_down 9y ago“Grep” is like “Kleenex”. It doesn’t necessarily mean specifically grep.
- cryptonector 9y agoUpvote for cscope mention. I prefer cscope -Rqk. I run cscope on the zeroth window of a tmux/screen session with a $CSCOPE_EDITOR program that's a script that starts the real $EDITOR in a new window in the same session (with an appropriate window name) and in the background so that cscope gets control back immediately. This allows me to use cscope to drive large code investigations very easily.
- mmjaa 9y agoSounds cool. I use it in vim as a 'grok this C/C++/Lua/Textfiles' utility, pretty much every day. grep too of course, and there are times when you just wanna ack, but for full grok, cscope is cool however you do it.
- cryptonector 9y agoI have a shell function that generates shell functions that do find | xargs ... patterns. Thus I have 'fsg' == find source grep -- that is, find with -name arguments matching source | xargs grep ..., and fseg (find source egrep) and fmg (find make stuff grep). These functions take all non-option looking arguments and use them as directory arguments for find, then all remaining arguments are passed to grep, so I get to write: $ fsg foo bar -w foo which translates into something like: find foo bar \( -name '*.[chylm]' -o -name ... \) -print0 | xargs -0 grep "$@" Still, cscope is fantastic, and the first tool I reach for.
- xemdetia 9y agoCscope feels kind of lousy nowadays after I have been using opengrok. It handles multilang repos so much nicer and allows you to search all the codebases instead of just one.