New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel-git-grep-occur - Lisp error #1225

Closed
edkolev opened this Issue Oct 5, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@edkolev
Contributor

edkolev commented Oct 5, 2017

The following stopped working for me:

  • load counsel with (use-package counsel :ensure t)
  • counsel-git-grep some text
  • C-c C-o
  • I now get a lisp error, stack trace is pasted below.

I fixed the issue for me like so, however, I'm not sure if this is a proper fix:

git diff -U14
diff --git a/counsel.el b/counsel.el
index 2a3b10e..9c5cfa5 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1341,34 +1341,34 @@ If NO-ASYNC is non-nil, do it synchronously instead."
 (defun counsel-git-grep-occur ()
   "Generate a custom occur buffer for `counsel-git-grep'.
 When REVERT is non-nil, regenerate the current *ivy-occur* buffer."
   (unless (eq major-mode 'ivy-occur-grep-mode)
     (ivy-occur-grep-mode)
     (setq default-directory counsel--git-dir))
   (setq ivy-text
         (and (string-match "\"\\(.*\\)\"" (buffer-name))
              (match-string 1 (buffer-name))))
   (let* ((regex (funcall ivy--regex-function ivy-text))
          (positive-pattern (replace-regexp-in-string
                             ;; git-grep can't handle .*?
                             "\\.\\*\\?" ".*"
                             (if (stringp regex) regex (caar regex))))
-         (negative-patterns
-          (mapconcat (lambda (x)
-                       (and (null (cdr x))
-                            (format "| grep -v %s" (car x))))
-                     regex
-                     " "))
+         (negative-patterns (if (stringp regex) ""
+                              (mapconcat (lambda (x)
+                                           (and (null (cdr x))
+                                                (format "| grep -v %s" (car x))))
+                                         regex
+                                         " ")))

The error seems to be caused by the fact that the regex is a string, but the code expects it to be some other structure.

This is the stack trace that I get without the above patch:

Debugger entered--Lisp error: (wrong-type-argument listp 100)
  cdr(100)
  (null (cdr x))
  (and (null (cdr x)) (format "| grep -v %s" (car x)))
  (closure ((positive-pattern . "defun") (regex . "defun") smex-ido-cache smex-initialized-p info-lookup-mode t) (x) (and (null (cdr x)) (format "| grep -v %s" (car x))))(100)
  mapconcat((closure ((positive-pattern . "defun") (regex . "defun") smex-ido-cache smex-initialized-p info-lookup-mode t) (x) (and (null (cdr x)) (format "| grep -v %s" (car x)))) "defun" " ")
  (let* ((regex (funcall ivy--regex-function ivy-text)) (positive-pattern (replace-regexp-in-string "\\.\\*\\?" ".*" (if (stringp regex) regex (car (car regex))))) (negative-patterns (mapconcat (function (lambda (x) (and (null ...) (format "| grep -v %s" ...)))) regex " "))$
  counsel-git-grep-occur()
  funcall(counsel-git-grep-occur)
  (if occur-fn (funcall occur-fn) (ivy-occur-mode) (insert (format "%d candidates:\n" (length ivy--old-cands))) (read-only-mode) (ivy--occur-insert-lines (mapcar (function (lambda (cand) (concat "    " cand))) ivy--old-cands)))
  (let ((inhibit-read-only t)) (erase-buffer) (if occur-fn (funcall occur-fn) (ivy-occur-mode) (insert (format "%d candidates:\n" (length ivy--old-cands))) (read-only-mode) (ivy--occur-insert-lines (mapcar (function (lambda (cand) (concat "    " cand))) ivy--old-cands))))
  (save-current-buffer (set-buffer buffer) (let ((inhibit-read-only t)) (erase-buffer) (if occur-fn (funcall occur-fn) (ivy-occur-mode) (insert (format "%d candidates:\n" (length ivy--old-cands))) (read-only-mode) (ivy--occur-insert-lines (mapcar (function (lambda (cand) (c$
  (let* ((caller (progn nil (or (progn nil (and (vectorp ivy-last) (>= ... 25) (memq ... cl-struct-ivy-state-tags) t)) (signal (quote wrong-type-argument) (list (quote ivy-state) ivy-last))) (aref ivy-last 22))) (occur-fn (plist-get ivy--occurs-list caller)) (buffer (genera$
  (if (not (window-minibuffer-p)) (user-error "No completion session is active") (let* ((caller (progn nil (or (progn nil (and ... ... ... t)) (signal (quote wrong-type-argument) (list ... ivy-last))) (aref ivy-last 22))) (occur-fn (plist-get ivy--occurs-list caller)) (buff$
  ivy-occur()
  funcall-interactively(ivy-occur)
  call-interactively(ivy-occur nil nil)
  command-execute(ivy-occur)
  read-from-minibuffer("git grep" nil (keymap (keymap (3 keymap (13 . counsel-git-grep-switch-cmd)) (27 keymap (113 . counsel-git-grep-query-replace)) (12 . ivy-call-and-recenter)) keymap (escape . minibuffer-keyboard-quit) (21 lambda nil (interactive) (kill-region (point) $
  (if (and ivy-auto-select-single-candidate (= (length ivy--all-candidates) 1)) (progn (progn nil (or (progn nil (and (vectorp ivy-last) (>= (length ivy-last) 25) (memq (aref ivy-last 0) cl-struct-ivy-state-tags) t)) (signal (quote wrong-type-argument) (list (quote ivy-stat$
  (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (resize-mini-windows (cond ((display-graphic-p) nil) ((null resize-mini-windows) (quote grow-only)) (t resize-mini-windows)))) (if (and ivy-$
  (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (resize-mini-windows (cond ((display-graphic-p) nil) ((null resize-mini-windows) $
  (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (resize-mini-windows (cond ((display-graphic-p) nil) ((null resiz$
  (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook (quote minibuffer-setup-hook) setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history (quo$
  (unwind-protect (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook (quote minibuffer-setup-hook) setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist $
  (prog1 (unwind-protect (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook (quote minibuffer-setup-hook) setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* $
  (let ((ivy-recursive-last (and (active-minibuffer-window) ivy-last)) (transformer-fn (plist-get ivy--display-transformers-list (or caller (and (functionp collection) collection)))) (ivy-display-function (if (window-minibuffer-p) nil (cdr (assoc caller ivy-display-function$
  (progn (let ((extra-actions (delete-dups (append (plist-get ivy--actions-list t) (plist-get ivy--actions-list this-command) (plist-get ivy--actions-list caller))))) (if extra-actions (progn (setq action (cond ((functionp action) (cons 1 ...)) ((null action) (cons 1 ...)) $
  (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car --cl-keys--) (quote (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :unwind :re-builder :matcher :dynamic-collection :caller :allow-other-keys)$
  (let* ((predicate (car (cdr (plist-member --cl-rest-- (quote :predicate))))) (require-match (car (cdr (plist-member --cl-rest-- (quote :require-match))))) (initial-input (car (cdr (plist-member --cl-rest-- (quote :initial-input))))) (history (car (cdr (plist-member --cl-r$
  ivy-read("git grep" counsel-git-grep-function :initial-input nil :matcher counsel-git-grep-matcher :dynamic-collection nil :keymap (keymap (3 keymap (13 . counsel-git-grep-switch-cmd)) (27 keymap (113 . counsel-git-grep-query-replace)) (12 . ivy-call-and-recenter)) :actio$
  (let ((collection-function (if proj (function counsel-git-grep-proj-function) (function counsel-git-grep-function))) (unwind-function (if proj (function (lambda nil (counsel-delete-process) (swiper--cleanup))) (function (lambda nil (swiper--cleanup)))))) (ivy-read "git gr$
  (let ((proj-and-cmd (counsel--git-grep-cmd-and-proj cmd)) proj) (setq proj (car proj-and-cmd)) (setq counsel-git-grep-cmd (cdr proj-and-cmd)) (counsel-require-program (car (split-string counsel-git-grep-cmd))) (setq counsel--git-dir (if proj (car proj) (counsel-locate-git$
  counsel-git-grep(nil)
  funcall-interactively(counsel-git-grep nil)
  call-interactively(counsel-git-grep record nil)
  command-execute(counsel-git-grep record)
@dieggsy

This comment has been minimized.

Contributor

dieggsy commented Oct 7, 2017

Weirdly, I can reproduce this with emacs -q but not my own config.

@abo-abo abo-abo closed this in 6827edf Oct 7, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Oct 7, 2017

@edkolev Thanks, I applied your suggestion. Please test.

@edkolev

This comment has been minimized.

Contributor

edkolev commented Oct 7, 2017

It's fixed now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment