changelog shortlog tags changeset files revisions annotate raw

ack-emacs.el

changeset 66: 5b737eefe5ea
parent:1fae210bc469
author: kim.vanwyk
date: Wed Nov 10 15:19:03 2010 +0200 (18 months ago)
permissions: -rw-r--r--
description: Adding CSharp Mode and Google Weather
1(require 'compile)
2(require 'thingatpt)
3
4(defvar ack-command "c:/utils/ack.pl" "The command run by the ack function.")
5
6(defvar ack-mode-font-lock-keywords
7 '(("^\\(Compilation\\|Ack\\) started.*"
8 (0 '(face nil message nil help-echo nil mouse-face nil) t))))
9
10(defvar ack-use-search-in-buffer-name t
11 "If non-nil, use the search string in the ack buffer's name.")
12
13(define-compilation-mode ack-mode "Ack"
14 "Specialization of compilation-mode for use with ack."
15 nil)
16
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)
25 ))
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))
32
33 (let (compile-command
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))))
44
45(provide 'ack-emacs)
46