]> code.delx.au - gnu-emacs-elpa/commitdiff
* ack.el (ack-buffer-name-function): New user variable
authorLeo Liu <sdl.web@gmail.com>
Sun, 18 Nov 2012 16:05:46 +0000 (00:05 +0800)
committerLeo Liu <sdl.web@gmail.com>
Sun, 18 Nov 2012 16:05:46 +0000 (00:05 +0800)
Thanks to scottj@irc.freenode.net for request and testing.

packages/ack/ack.el

index 8e8553105c28d79c1f0da897ab7e58a9f4326b22..d58a7ff1e8a277307471131a1cbed32e89351bf1 100644 (file)
@@ -57,6 +57,12 @@ environment variable and ~/.ackrc, which you can disable by the
   :type 'string
   :group 'ack)
 
+(defcustom ack-buffer-name-function nil
+  "If non-nil, a function to compute the name of an ack buffer.
+See `compilation-buffer-name-function' for details."
+  :type '(choice function (const nil))
+  :group 'ack)
+
 (defcustom ack-vc-grep-commands
   '((".git" . "git --no-pager grep --color -n -i")
     (".hg" . "hg grep -n -i")
@@ -364,7 +370,11 @@ minibuffer:
            project-root)))
   (let ((default-directory (expand-file-name
                             (or directory default-directory))))
-    (compilation-start command-args 'ack-mode)))
+    ;; Change to the compilation buffer so that `ack-buffer-name-function' can
+    ;; make use of `compilation-arguments'.
+    (with-current-buffer (compilation-start command-args 'ack-mode)
+      (when ack-buffer-name-function
+        (rename-buffer (funcall ack-buffer-name-function "ack"))))))
 
 (provide 'ack)
 ;;; ack.el ends here