leoliu / ack-el Goto Github PK
View Code? Open in Web Editor NEWEmacs Interface to Ack-like Tools
Emacs Interface to Ack-like Tools
Being able to edit the matches from the search buffer is useful.
Is this a planned feature?
If the recommended solution is to use wgrep-ack, it mostly seems to work, but wgrep-exit
resets all colors to the ones compilation-mode
uses and unhighlights all matches.
Let me know if I should report it there, instead.
Howdy,
this is not really meant to be a bug report, rather a proposal to modify the behavior of ack.
I'm having two problems with it: when I start ack and search for something and the press q
then only the window is being closed, not the *ack*
buffer itself. So the next time I start ack, I just end up in that old buffer, it doesn't even ask me for a search term. I'm not sure if the keybinding q
is configured somewhere in my emacs config or if it's a default or an ack-mode setting. But this behavior is really annoying for me.
Another problem is, that if I start ack, a new window with the ack buffer will be created but I am not switched to it. So I have to manually switch to it every time. That's just one key stroke to much for my taste ;-)
So, here's my actual ack config in case someone has similar problems or if you consider to incorporate something like this into ack-mode:
;; https://github.com/leoliu/ack-el
(defun tvd-kill-ack()
"Close the *ack* window and kill the associated buffer along
with the ack process"
(interactive)
(let ((kill-buffer-query-functions nil))
(delete-window)
(kill-buffer "*ack*")))
(defun tvd-hook-kill-ack()
"set local keys in temporary ack buffer"
(local-set-key (kbd "q") 'tvd-kill-ack))
(use-package ack
:config
;; don't annoy me with git search & co
(setq ack-defaults-function 'ack-legacy-defaults)
;; focus the *ack* buffer directly
(advice-add 'ack-mode :after
'(lambda ()
(pop-to-buffer "*ack*")))
:init
(add-hook 'ack-mode-hook 'tvd-hook-kill-ack))
*ack* result buffer parses the numbers in a filename as the line number, breaking compile-goto-error
Using RET to visit a broken file results in a prompt "Find this ack match in" with a directory prompt, trying to find the partial match up until the filename's first hyphen.
abc-123-def.txt fails
abc-123.txt works
M-x ack RET
M-Y
expected: yank the symbol at point in the buffer from which I called ack
actual: "Previous command was not a yank"
Installed as per the readme with M-x package-install RET ack RET.
v0.9.
GNU Emacs 24.5.1
Did I miss something?
Commit b2c449c made ack-quickgrep-defaults
the default value for ack-defaults-function
.
In my day-to-day use, this is a less useful default than the legacy defaults. I often M-x ack
from a Dired buffer, for example, and I never want to search for the filename at point.
Looking at the commit, I see how to restore the legacy default for myself—so I wouldn't normally complain at all, except that the commit message invited me to 😉.
Thank you for a very useful package!
What is the actual command that gets called?
Hello again Leo,
In issue #9, I proposed that you add a ack-maybe-skel-vc-grep
(or that you remove the error raising behaviour in ack-skel-vc-grep
).
Here's another request. Since this might raise more objections, I made it a new issue. If the user uses C-u C-u M-x ack
, he wants to choose a directory. Let's assume he chooses a subdirectory of a git project. Does it make sense to add a vc skeleton to the root of the project, or should we should override with regular ack? I believe we should do the latter. If the use wants to use the root of the project he should have C-u M-x ack
'ed instead, right?
So, I propose this change, which already includes the fix for #9, too.
diff --git a/ack.el b/ack.el
index 11c1f93..0bc8445 100644
--- a/ack.el
+++ b/ack.el
@@ -285,16 +285,28 @@ This gets tacked on the end of the generated expressions.")
(let* ((regexp (concat "\\`" (regexp-opt
(mapcar 'car ack-vc-grep-commands))
"\\'"))
- (root (or (ack-guess-project-root default-directory regexp)
- (error "Cannot locate vc project root")))
- (which (car (directory-files root nil regexp)))
+ (guessed-root (ack-guess-project-root ack--project-root regexp))
+ (which (progn
+ (unless (equal
+ (file-truename ack--project-root)
+ (file-truename guessed-root))
+ (error "You asked to `ack' in %s but the project root is %s"
+ ack--project-root
+ guessed-root))
+ (car (directory-files guessed-root nil regexp))))
(backend (downcase (substring which 1)))
(cmd (or (cdr (assoc which ack-vc-grep-commands))
(error "No command provided for `%s grep'" backend))))
- (setq ack--project-root root)
(delete-minibuffer-contents)
(skeleton-insert `(nil ,cmd " '" _ "'"))))
+(defun ack-maybe-skel-vc-grep ()
+ "Try insert ta template for vc grep search.
+Don't do anything if that triggers an error (the previous
+template stays put)"
+ (interactive)
+ (ignore-errors (ack-skel-vc-grep)))
+
(defun ack-yank-symbol-at-point ()
"Yank the symbol from the window before entering the minibuffer."
(interactive)
I'd like to be able to specify ag
over ack
by calling a function provided by ack-el. Currently I have both ag
and ack
installed on my system. ack
is used simply because the order in the code dictates that.
Maybe it is time for a version bump for GNU ELPA?
It would be great to have a function that will automatically invoke a search using the symbol at point. Currently this requires three steps: invoke ack, keystroke to copy symbol at point to minibuffer, and hit enter.
Hi Leo,
I hope this project isn't abandoned. I recently discovered it and it's very well done. Thanks!
I have one small problem with it. Here's my ack-minibuffer-setup-hook
(add-hook 'ack-minibuffer-setup-hook 'ack-skel-vc-grep t)
(add-hook 'ack-minibuffer-setup-hook 'ack-yank-symbol-at-point t)
Obviously, the idea is to use git grep
and then yank the symbol at point. But what if I choose a directory without a vc project? M-x ack
will fail, because ack-skel-vc-grep
raises an error, since it can't work under those circunstances. If it didn't raise the error though, ack would be able to gracefully fallback to ack. So now I have the trivial.
(defun ack-maybe-skel-vc-grep ()
"Try insert ta template for vc grep search.
Don't do anything if that triggers an error (the previous
template stays put)"
(interactive)
(ignore-errors (ack-skel-vc-grep)))
in my config, which works very nicely. Is this something you would consider adding? If so I can make a PR (or take over maintenance if you've lost interest :-))
I just updated ack-el
. Now when I use M-x ack
the mini-buffer reports:
Symbol's value as variable is void: project-root
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.