aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/pcmpl-x.el30
2 files changed, 36 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ecec50e930d..cc928f5c57f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-11-21 Leo Liu <sdl.web@gmail.com>
2
3 Add completion for command `ag'.
4 * pcmpl-x.el (pcomplete/ag, pcmpl-x-ag-options): New functions.
5 (pcmpl-x-ag-options): New variable.
6
12013-11-21 Stefan Monnier <monnier@iro.umontreal.ca> 72013-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * emacs-lisp/byte-run.el (eval-when-compile): Fix edebug spec 9 * emacs-lisp/byte-run.el (eval-when-compile): Fix edebug spec
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."
247;;;###autoload 247;;;###autoload
248(defalias 'pcomplete/ack-grep 'pcomplete/ack) 248(defalias 'pcomplete/ack-grep 'pcomplete/ack)
249 249
250
251;;;; the_silver_search - https://github.com/ggreer/the_silver_searcher
252
253(defvar pcmpl-x-ag-options nil)
254
255(defun pcmpl-x-ag-options ()
256 (or pcmpl-x-ag-options
257 (setq pcmpl-x-ag-options
258 (with-temp-buffer
259 (when (zerop (call-process "ag" nil t nil "--help"))
260 (let (so lo)
261 (goto-char (point-min))
262 (while (re-search-forward "^ +\\(-[a-zA-Z]\\) " nil t)
263 (push (match-string 1) so))
264 (goto-char (point-min))
265 (while (re-search-forward
266 "^ +\\(?:-[a-zA-Z] \\)?\\(--[^ \t\n]+\\) " nil t)
267 (push (match-string 1) lo))
268 (list (cons 'short (nreverse so))
269 (cons 'long (nreverse lo)))))))))
270
271;;;###autoload
272(defun pcomplete/ag ()
273 "Completion for the `ag' command."
274 (while t
275 (if (pcomplete-match "^-" 0)
276 (pcomplete-here* (cdr (assq (if (pcomplete-match "^--" 0) 'long 'short)
277 (pcmpl-x-ag-options))))
278 (pcomplete-here* (pcomplete-dirs-or-entries)))))
279
250(provide 'pcmpl-x) 280(provide 'pcmpl-x)
251;;; pcmpl-x.el ends here 281;;; pcmpl-x.el ends here