diff options
author | Leo Liu <sdl.web@gmail.com> | 2013-11-21 22:15:44 +0800 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2013-11-21 22:15:44 +0800 |
commit | b6ffa04a65caa59f4f41234fc7b2edc0d0e68a82 (patch) | |
tree | 0ccbf2f4702d4b4f03223651f45fe6bf993aa429 /lisp/pcmpl-x.el | |
parent | 7e8ed4f7f95f6f63198b0dd106f11cbff8e6aae2 (diff) | |
download | emacs-b6ffa04a65caa59f4f41234fc7b2edc0d0e68a82.tar.gz |
Add completion for command `ag'.
* pcmpl-x.el (pcomplete/ag, pcmpl-x-ag-options): New functions.
(pcmpl-x-ag-options): New variable.
Diffstat (limited to 'lisp/pcmpl-x.el')
-rw-r--r-- | lisp/pcmpl-x.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lisp/pcmpl-x.el b/lisp/pcmpl-x.el index 86d8dc652c3..b52a692a291 100644 --- a/lisp/pcmpl-x.el +++ b/lisp/pcmpl-x.el @@ -247,5 +247,35 @@ long options." ;;;###autoload (defalias 'pcomplete/ack-grep 'pcomplete/ack) + +;;;; the_silver_search - https://github.com/ggreer/the_silver_searcher + +(defvar pcmpl-x-ag-options nil) + +(defun pcmpl-x-ag-options () + (or pcmpl-x-ag-options + (setq pcmpl-x-ag-options + (with-temp-buffer + (when (zerop (call-process "ag" nil t nil "--help")) + (let (so lo) + (goto-char (point-min)) + (while (re-search-forward "^ +\\(-[a-zA-Z]\\) " nil t) + (push (match-string 1) so)) + (goto-char (point-min)) + (while (re-search-forward + "^ +\\(?:-[a-zA-Z] \\)?\\(--[^ \t\n]+\\) " nil t) + (push (match-string 1) lo)) + (list (cons 'short (nreverse so)) + (cons 'long (nreverse lo))))))))) + +;;;###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-x-ag-options)))) + (pcomplete-here* (pcomplete-dirs-or-entries))))) + (provide 'pcmpl-x) ;;; pcmpl-x.el ends here |