baohaojun / beagrep

Grep 2G source code in 0.23 second.
http://baohaojun.github.com/beagrep.html
Other
108 stars 20 forks source link

some advices about beagrep #1

Closed sunwayforever closed 8 years ago

sunwayforever commented 11 years ago

thanks for your great work, but there is some advice for beagrep

  1. ~/tmp/for-code-reading should be able to be customized
  2. beagrep will find nothing if the target source folder is a symbolic link
  3. the query result file name is too long, e.g. /media/sunway/storage3/android/frameworks/base/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java should be renamed to frameworks/base/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java since I make the index in /media/sunway/storage3/android
baohaojun commented 11 years ago

Thank you.

  1. I agree that ~/tmp/for-code-reading is a bad choice I made. But to allow it to be customized also cause me uneasiness, so maybe I can use another less obtrusive hardcoded value such as the ~/.cache/for-code-reading? What do you think? I checked my ~/.cache directory, seems a lot open source projects are using it already, so maybe it is part of FHS recommendation?
  2. Do you mean you have a subfolder which is a symlink in your main source folder, and beagrep will show nothing about code in that symlinked subfolder? In this case it is by design of the underlying beagle search engine, it will ignore symlinks.
  3. I agree with you. But please note that when you use it in Emacs, displaying the shortened filename may cause it unable to find the file, because the default directory could be not the same as the top indexed project directory. That's why I made this decision. Aslo, the absolute path make it easily for scripting in other programs.

    So I will add a -s|--short option, what do you think?

    You may have to add the make(1)'s Entering directory '/media/sunway/...' and tweak Emacs's grep-mode to behave like its parent compilation-mode to not ignore those Entering directory marks:

    (add-hook 'grep-mode-hook
     (lambda ()
       (setq compilation-directory-matcher (default-value 'compilation-directory-matcher))))
sunwayforever commented 11 years ago

"Do you mean you have a subfolder which is a symlink in your main source folder ....

Nop, for example, my code is located at /media/sunway/android, while /media/sunway is symbolic linked to /home/sunway/source, then if I run mkbeagrepidx in /media/sunway/android, the index file will be put into ~/tmp/for-code-reading/media/sunway/android, right? but when I run beagrep -e xxx in /home/sunway/source/android later, it will try to locate the index file in ~/tmp/for-code-reading/home/sunway/source/android, which does not exist. btw, it doesn't work even I build the index in /home/sunway/source/android, because the index file is still put into ~/tmp/for-code-reading/media/sunway/android ...

baohaojun commented 11 years ago

I see, it is a bug and I have fixed it for the master branch. The 1. and 3. still not fixed yet.

Thanks.

baohaojun commented 11 years ago
  1. and 3. are also fixed in master, please have a try.

Thanks!

Almost forgot: cd ~/tmp; mkdir -p ~/.cache; mv for-code-reading/ ~/.cache/

This will save you from rebuilding the index.