]> code.delx.au - gnu-emacs-elpa/commitdiff
New command ack-yank-symbol-at-point and bind it to M-Y
authorLeo Liu <sdl.web@gmail.com>
Sat, 12 Jan 2013 17:47:50 +0000 (01:47 +0800)
committerLeo Liu <sdl.web@gmail.com>
Sat, 12 Jan 2013 17:47:50 +0000 (01:47 +0800)
Thanks to scottj@irc.freenode.net for request and testing.
Also update copyright years.

packages/ack/README
packages/ack/ack.el
packages/ack/pcmpl-ack.el

index 188562ecf35c44c77034c2b4af436edb373c1a68..8e90f7f3185a256743e52c2024c6ebe3104598cc 100644 (file)
@@ -15,6 +15,8 @@ key bindings may be useful:
 
 - `M-I' inserts a template for case-insensitive file name search
 - `M-G' inserts a template for `git grep', `hg grep' or `bzr grep'
+- `M-Y' inserts the symbol at point from the window before entering
+   the minibuffer
 - `TAB' completes ack options
 
 This package does not require `--nogroup' nor `--noheading'.
index d58a7ff1e8a277307471131a1cbed32e89351bf1..6b1655ddcac73689de8b1f523a5420982fc0dbb2 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ack.el --- Emacs interface to ack
 
-;; Copyright (C) 2012  Free Software Foundation, Inc.
+;; Copyright (C) 2012, 2013  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <sdl.web@gmail.com>
 ;; Version: 0.8
@@ -308,6 +308,16 @@ This gets tacked on the end of the generated expressions.")
     (delete-minibuffer-contents)
     (skeleton-insert '(nil cmd " '" _ "'"))))
 
+(defun ack-yank-symbol-at-point ()
+  "Yank the symbol from the window before entering the minibuffer."
+  (interactive)
+  (let ((symbol (and (minibuffer-selected-window)
+                     (with-current-buffer
+                         (window-buffer (minibuffer-selected-window))
+                       (thing-at-point 'symbol)))))
+    (if symbol (insert symbol)
+      (minibuffer-message "No symbol found"))))
+
 (defvar ack-minibuffer-local-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
@@ -316,6 +326,7 @@ This gets tacked on the end of the generated expressions.")
                            'pcomplete))
     (define-key map "\M-I" 'ack-skel-file)
     (define-key map "\M-G" 'ack-skel-vc-grep)
+    (define-key map "\M-Y" 'ack-yank-symbol-at-point)
     (define-key map "'" 'skeleton-pair-insert-maybe)
     map)
   "Keymap used for reading `ack' command and args in minibuffer.")
index ea504a89add7fc1da0166d6721d44370160fe7c9..766168a80477cf8bd04f1ef95dc6f33a9a660e53 100644 (file)
@@ -1,6 +1,6 @@
 ;;; pcmpl-ack.el --- completion for ack tool
 
-;; Copyright (C) 2012  Free Software Foundation, Inc.
+;; Copyright (C) 2012, 2013  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <sdl.web@gmail.com>
 ;; Keywords: tools, processes, convenience