 (defvar ack-and-a-half-regexp-history nil
   "Regular expressions recently searched for with `ack-and-a-half'.")
 
+(defun ack-and-a-half-initial-contents-for-read ()
+  (when (ack-and-a-half-use-region-p)
+    (buffer-substring-no-properties (region-beginning) (region-end))))
+
+(defun ack-and-a-half-default-for-read ()
+  (unless (ack-and-a-half-use-region-p)
+    (thing-at-point 'symbol)))
+
+(defun ack-and-a-half-use-region-p ()
+  (or (and (fboundp 'use-region-p) (use-region-p))
+      (and transient-mark-mode mark-active
+           (> (region-end) (region-beginning)))))
+
 (defsubst ack-and-a-half-read (regexp)
-  (read-from-minibuffer (if regexp "ack pattern: " "ack literal search: ")
-                        nil nil nil
-                        (if regexp 'ack-and-a-half-regexp-history 'ack-and-a-half-literal-history)))
+  (let* ((default (ack-and-a-half-default-for-read))
+         (type (if regexp "pattern" "literal search"))
+         (history-var )
+         (prompt  (if default
+                      (format "ack %s (default %s): " type default)
+                    (format "ack %s: " type))))
+    (read-string prompt
+                 (ack-and-a-half-initial-contents-for-read)
+                 (if regexp 'ack-regexp-history 'ack-literal-history)
+                 default)))
 
 (defun ack-and-a-half-read-dir ()
   (let ((dir (run-hook-with-args-until-success 'ack-and-a-half-root-directory-functions)))

`ack-and-a-half-project-root-file-patterns'.  The user is only prompted, if
`ack-and-a-half-prompt-for-directory' is set."
  (interactive (ack-and-a-half-interactive))
  (ack-and-a-half-run directory regexp (ack-and-a-half-shell-quote pattern)))

;;;###autoload
(defun ack-and-a-half-same (pattern &optional regexp directory)

  :group 'tools
  :group 'matching)

(defcustom ack-and-a-half-executable (or (executable-find "ack")
                                         (executable-find "ack-grep"))
  "*The location of the ack executable"
  :group 'ack-and-a-half
  :type 'file)

(defcustom ack-and-a-half-buffer-name "*Ack-and-a-half*"
  "*The name of the ack-and-a-half buffer"
  :group 'ack-and-a-half
  :type 'string)

(defun ack-buffer-name (mode) ack-and-a-half-buffer-name)

(defcustom ack-and-a-half-arguments nil
  "*Extra arguments to pass to ack."
