From d3755e2917dcfb20dc3b7687636783558f984ea3 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Sun, 13 Jan 2013 01:47:50 +0800 Subject: [PATCH] New command ack-yank-symbol-at-point and bind it to M-Y Thanks to scottj@irc.freenode.net for request and testing. Also update copyright years. --- packages/ack/README | 2 ++ packages/ack/ack.el | 13 ++++++++++++- packages/ack/pcmpl-ack.el | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/ack/README b/packages/ack/README index 188562ecf..8e90f7f31 100644 --- a/packages/ack/README +++ b/packages/ack/README @@ -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'. diff --git a/packages/ack/ack.el b/packages/ack/ack.el index d58a7ff1e..6b1655ddc 100644 --- a/packages/ack/ack.el +++ b/packages/ack/ack.el @@ -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 ;; 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.") diff --git a/packages/ack/pcmpl-ack.el b/packages/ack/pcmpl-ack.el index ea504a89a..766168a80 100644 --- a/packages/ack/pcmpl-ack.el +++ b/packages/ack/pcmpl-ack.el @@ -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 ;; Keywords: tools, processes, convenience -- 2.39.2