Skip to content

Conversation

@YorkZ
Copy link

@YorkZ YorkZ commented Sep 30, 2015

Hi Nikolaj,

I've been using full-ack for a few years now. Thank you very much for this useful tool. Please check out my two pull request, the font lock one has been a life saver for me.

Thanks,

York

Use the ack-grep line number and file name color code directly for font
lock. This is to address a problem that file name font lock wouldn't
work for a file name starts with numbers and dash. For example, if a
file name was "1234-5", it was recognized as a line number.
@nschum
Copy link
Owner

nschum commented Oct 3, 2015

Thanks. The changes look good. But can you tell me why the font locking changes are necessary, and an example what ack-before-search-starts might be used for?

@YorkZ
Copy link
Author

YorkZ commented Oct 3, 2015

But can you tell me why the font locking changes are necessary

full-ack uses this regexp:

(defconst ack-font-lock-regexp-line
  (concat "\\(" ack-font-lock-regexp-color-fg-begin "?\\)"
          "\\([0-9]+\\)"
          "\\(" ack-font-lock-regexp-color-end "?\\)"
          "[:-]")
  "Matches the line output from ack (with or without color).
Color is used starting ack 1.94.")

to identify line numbers in the ack-grep output. The problem is that, if file names in ack-grep output also begin with numbers followed by a dash (-), e.g., if a file name is "1234-5/foo.cpp", using ack-font-lock-regexp-line regexp, it will be mistakenly identified as a line number and therefore be font-locked as a line number, making the search results extremely hard to read.

ack-grep produces the output, it knows which part is the file name, and which part is the line number, and has marked them with different color codes. Therefore, I think the most reliable approach would be to simply use the ack-grep color codes in the line and file name regexp. This will work as long as one uses an ack version 1.94 or newer. Do you have other reliable solution without using the ack-grep color codes?

and an example what ack-before-search-starts might be used for?

I use speck.el for spell check, but I noticed that if speck is doing spell checking in the background, full-ack could be slowed down significantly. I added these hooks so that I could stop spell check before starting ack search and then re-start it after ack search is done.

York

@nschum
Copy link
Owner

nschum commented Oct 3, 2015

I understand. Sounds good.

What happens if the user configures ack to use different colors?
Shouldn't we add explicit --color-filename, --color-match and --color-lineno to ack-arguments-from-options to make sure they are what the regexp expects them to be?

@YorkZ
Copy link
Author

YorkZ commented Oct 3, 2015

Shouldn't we add explicit --color-filename, --color-match and --color-lineno
to ack-arguments-from-options to make sure they are what the regexp expects
them to be

That would be better. I was not 100% sure if ack-grep provided users the means to customize colors. Also, I thought probably very little people would want change the default colors. Please feel free to add the feature if you want. Otherwise, I might add it when I get some time.

By the way, I'm currently playing with the silver searcher. It's really much faster than ack-grep. Have you used it already? What's your opinion? I really love it's lightening speed, but I don't like the output from ag.el. I'm thinking about making full-ack.el work with ag. Thoughts?

York

@nschum
Copy link
Owner

nschum commented Oct 5, 2015

I'm going to leave this PR open until you or I get the chance to add this. I don't want to merge in a change that might cause problems for existing users.

Yes, I have switched to ag recently. I'm not doing my coding in Emacs right now, so I haven't had a reason to work support it. Any contribution would be very welcome.

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.

2 participants