Skip to content

Instantly share code, notes, and snippets.

@timvisher
Created May 31, 2013 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timvisher/5682600 to your computer and use it in GitHub Desktop.
Save timvisher/5682600 to your computer and use it in GitHub Desktop.
(defun timvisher/ack-from-root (arg regexp)
(interactive "P")
(let ((current-prefix-arg (cond ((not arg) 4)
((= 4 (car arg)) 16)
((<= 16 (car arg)) nil))))
(call-interactively 'ack)))
(defun timvisher/isearch-ack-from-root (arg regexp)
(interactive
(list current-prefix-arg
(cond
((functionp isearch-word)
(funcall isearch-word isearch-string))
(isearch-word (word-search-regexp isearch-string))
(isearch-regexp isearch-string)
(t (regexp-quote isearch-string)))))
(let ((ack-command (concat "ag " regexp))
(current-prefix-arg 4))
(isearch-done nil)
(isearch-clean-overlays)
(call-interactively 'ack)))
(define-key isearch-mode-map (kbd "C-c r g") 'timvisher/isearch-ack-from-root)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment