]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge ack master from github.com:leoliu/ack-el
authorLeo Liu <sdl.web@gmail.com>
Sat, 12 Sep 2015 12:38:19 +0000 (20:38 +0800)
committerLeo Liu <sdl.web@gmail.com>
Sat, 12 Sep 2015 12:39:18 +0000 (20:39 +0800)
1  2 
packages/ack/ack.el
packages/ack/pcmpl-ack.el

diff --combined packages/ack/ack.el
index c1f5328d799f0c94511a010ae887e51d3cec8c38,11c1f9367cca216a5e9d48eb362b4e19bdd1bd92..11c1f9367cca216a5e9d48eb362b4e19bdd1bd92
--- 2/ack.el
@@@ -1,9 -1,9 +1,9 @@@
- ;;; ack.el --- Interface to ack-like source code search tools   -*- lexical-binding: t; -*-
+ ;;; ack.el --- interface to ack-like tools           -*- lexical-binding: t; -*-
  
- ;; Copyright (C) 2012-2013  Free Software Foundation, Inc.
+ ;; Copyright (C) 2012-2015  Free Software Foundation, Inc.
  
  ;; Author: Leo Liu <sdl.web@gmail.com>
- ;; Version: 1.3
+ ;; Version: 1.5
  ;; Keywords: tools, processes, convenience
  ;; Created: 2012-03-24
  ;; URL: https://github.com/leoliu/ack-el
  ;;    the minibuffer
  ;; +  `TAB' completes ack options
  
+ ;;; Supported tools:
+ ;; + ack
+ ;; + grep
+ ;; + the_silver_search
+ ;; + git/hg/bzr grep
  ;;; Bugs: https://github.com/leoliu/ack-el/issues
  
  ;;; Code:
@@@ -140,6 -147,9 +147,9 @@@ Used by `ack-guess-project-root'.
  (defvar ack-error "ack match"
    "Stem of message to print when no matches are found.")
  
+ (defvar ack-finish-functions nil
+   "Value to use for `compilation-finish-functions' in ack buffers.")
  (defun ack-filter ()
    "Handle match highlighting escape sequences inserted by the ack process.
  This function is called from `compilation-filter-hook'."
@@@ -378,7 -388,8 +388,8 @@@ minibuffer
      ;; 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"))))))
+         (rename-buffer (funcall ack-buffer-name-function "ack")))
+       (current-buffer))))
  
  (provide 'ack)
  ;;; ack.el ends here
index 30293673d1c54b694b2005f7a168302a33f654c1,315eb04931d4d6c75e959ccbe7d0ecfce3cd6954..315eb04931d4d6c75e959ccbe7d0ecfce3cd6954
@@@ -1,6 -1,6 +1,6 @@@
- ;;; pcmpl-ack.el --- completion for ack    -*- lexical-binding: t; -*-
+ ;;; pcmpl-ack.el --- completion for ack and ag       -*- lexical-binding: t; -*-
  
- ;; Copyright (C) 2012-2013  Free Software Foundation, Inc.
+ ;; Copyright (C) 2012-2015  Free Software Foundation, Inc.
  
  ;; Author: Leo Liu <sdl.web@gmail.com>
  ;; Keywords: tools, processes, convenience
@@@ -27,6 -27,7 +27,7 @@@
  ;;
  ;; Install:
  ;;   (autoload 'pcomplete/ack "pcmpl-ack")
+ ;;   (autoload 'pcomplete/ag "pcmpl-ack")
  ;;
  ;; Usage:
  ;;   - To complete short options type '-' first
@@@ -137,5 -138,39 +138,39 @@@ long options.
  ;;;###autoload
  (defalias 'pcomplete/ack-grep 'pcomplete/ack)
  
+ (defvar pcmpl-ack-ag-options nil)
+ (defun pcmpl-ack-ag-options ()
+   (or pcmpl-ack-ag-options
+       (setq pcmpl-ack-ag-options
+             (with-temp-buffer
+               (when (zerop (call-process "ag" nil t nil "--help"))
+                 (let (short long)
+                   (goto-char (point-min))
+                   (while (re-search-forward "^ +\\(-[a-zA-Z]\\) " nil t)
+                     (push (match-string 1) short))
+                   (goto-char (point-min))
+                   (while (re-search-forward
+                           "^ +\\(?:-[a-zA-Z] \\)?\\(--\\(\\[no\\]\\)?[^ \t\n]+\\) "
+                           nil t)
+                     (if (match-string 2)
+                         (progn
+                           (replace-match "" nil nil nil 2)
+                           (push (match-string 1) long)
+                           (replace-match "no" nil nil nil 2)
+                           (push (match-string 1) long))
+                       (push (match-string 1) long)))
+                   (list (cons 'short (nreverse short))
+                         (cons 'long  (nreverse long)))))))))
+ ;;;###autoload
+ (defun pcomplete/ag ()
+   "Completion for the `ag' command."
+   (while t
+     (if (pcomplete-match "^-" 0)
+         (pcomplete-here* (cdr (assq (if (pcomplete-match "^--" 0) 'long 'short)
+                                     (pcmpl-ack-ag-options))))
+       (pcomplete-here* (pcomplete-dirs-or-entries)))))
  (provide 'pcmpl-ack)
  ;;; pcmpl-ack.el ends here