]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel-ag now works with ivy-occur-revert-buffer
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 4 Apr 2016 15:29:52 +0000 (17:29 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 4 Apr 2016 15:29:52 +0000 (17:29 +0200)
* ivy.el (ivy-occur-revert-buffer): Add `counsel-ag' to the list.

* counsel.el (counsel-ag-occur): Don't call `ivy-occur-grep-mode' unless
  needed.

> (string-match "\"\\(.*\\)\"" (buffer-name))

Is a hack to recover the old `ivy-text', since it's not a field in
`ivy-last', and may have changed in the meantime.

TODO: Fix this sort of hacks, all necessary session data should really be in `ivy-last'.

counsel.el
ivy.el

index cce85dc27f56d9697001ce913039e8850f85feeb..54729699b36b92e07d65373151c68a4ccfaa5324 100644 (file)
@@ -1337,11 +1337,14 @@ INITIAL-INPUT can be given as the initial minibuffer input."
 
 (defun counsel-ag-occur ()
   "Generate a custom occur buffer for `counsel-ag'."
-  (ivy-occur-grep-mode)
+  (unless (eq major-mode 'ivy-occur-grep-mode)
+    (ivy-occur-grep-mode))
   (setq default-directory counsel--git-grep-dir)
   (let* ((regex (counsel-unquote-regex-parens
                  (setq ivy--old-re
-                       (ivy--regex ivy-text))))
+                       (ivy--regex
+                        (progn (string-match "\"\\(.*\\)\"" (buffer-name))
+                               (match-string 1 (buffer-name)))))))
          (cands (split-string
                  (shell-command-to-string
                   (format counsel-ag-base-command (shell-quote-argument regex)))
diff --git a/ivy.el b/ivy.el
index 5b23a4e3d68eea31a4f64fbab0b8dae160e95eb0..8d25e28f6d478f82b3c1c5981c40c096fae603fc 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -2853,7 +2853,7 @@ updated original buffer."
              (let ((inhibit-read-only t))
                (erase-buffer)
                (funcall (plist-get ivy--occurs-list caller) t))))
-          ((memq caller '(counsel-git-grep counsel-grep))
+          ((memq caller '(counsel-git-grep counsel-grep counsel-ag))
            (let ((inhibit-read-only t))
              (erase-buffer)
              (funcall (plist-get ivy--occurs-list caller)))))))