4(defvar ack-command "c:/utils/ack.pl" "The command run by the ack function.")
6(defvar ack-mode-font-lock-keywords
7 '(("^\\(Compilation\\|Ack\\) started.*"
8 (0 '(face nil message nil help-echo nil mouse-face nil) t))))
10(defvar ack-use-search-in-buffer-name t
11 "If non-nil, use the search string in the ack buffer's name.")
13(define-compilation-mode ack-mode "Ack"
14 "Specialization of compilation-mode for use with ack."
17(defun ack (dir pattern args)
18 "Run ack, with user-specified ARGS, and collect output in a buffer.
19While ack runs asynchronously, you can use the \\[next-error] command to
20find the text that ack hits refer to. The command actually run is
21defined by the ack-command variable."
22 (interactive (list (read-file-name "Run ack in directory: " nil "" t)
23 (read-string "Search for: " (thing-at-point 'symbol))
24 (read-string "Ack arguments: " nil nil "-i" nil)
26 ; Get dir into an the right state, incase a file name was used
27 (setq dir (abbreviate-file-name
28 (file-name-as-directory (expand-file-name dir))))
29 ;; Check that it's really a directory.
30 (or (file-directory-p dir)
31 (error "ack needs a directory: %s" dir))
34 (compilation-error-regexp-alist grep-regexp-alist)
35 (compilation-directory default-directory)
36 (ack-full-buffer-name (concat "*ack-" pattern "*")))
37;; (save-some-buffers (not compilation-ask-about-save) nil)
38 ;; lambda defined here since compilation-start expects to call a function to get the buffer name
39 (compilation-start (concat ack-command " " args " " pattern " \"" dir "\"") 'ack-mode
40 (when ack-use-search-in-buffer-name
41 (function (lambda (ignore)
42 ack-full-buffer-name)))
43 (regexp-quote pattern))))