Skip to content
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-grep-or-swiper failure #1644

Closed
rnadler opened this issue Jun 29, 2018 · 15 comments

Comments

@rnadler
Copy link

commented Jun 29, 2018

I have one particular org file (~1200 lines) that always fails (folded or unfolded) on C-s with:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("[ \f\011\n\015\013]+" nil 0)
split-string(nil)
counsel-grep(nil)
counsel-grep-or-swiper()
funcall-interactively(counsel-grep-or-swiper)
call-interactively(counsel-grep-or-swiper nil nil)
command-execute(counsel-grep-or-swiper)

I do not see this problem on any other files (org or otherwise). Does that particular org file have something toxic in it?

counsel-20180625.634
swiper-20180615.1400

Config:

(use-package counsel
  :diminish ivy-mode counsel-mode
  :bind (("C-s" . swiper)
         ...
         :map counsel-mode-map
         ([remap swiper] . counsel-grep-or-swiper)
         ...

GNU Emacs 26.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32) of 2018-05-29

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jun 30, 2018

What is your value of counsel-grep-base-command? Can you reproduce this from emacs -Q? Have you tried making a copy of the Org file in question, and recursively removing (bisecting) half of the file to pin point which part of it (if any) is causing counsel-grep to fail?

@rnadler

This comment has been minimized.

Copy link
Author

commented Jun 30, 2018

I went through a bisecting-like process where I removed different portions of the offending file
(todo.org). I found that the issue is somehow length related and specific to org mode, but is not due to text content. I.e the same content in non-org mode works fine -- rename the file (cp todo.org todo.txt) and remove the "#-- mode: org --" line, C-s works fine in the todo.txt buffer.

Org mode version 9.1.13

I will continue to investigate.

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jul 1, 2018

Instead of typing C-s, I suggest invoking either swiper or counsel-grep directly, to further reduce the number of variables in the equation (counsel-grep-or-swiper delegates to either one or the other subject to, amongst other things, buffer size). I also suggest recursively commenting-out parts of your configuration to rule out the possibility of some setting or package you use being guilty.

@rnadler

This comment has been minimized.

Copy link
Author

commented Jul 2, 2018

counsel-grep-base-command = "grep -E -n -e %s %s"
M-x swiper works fine.
M-x counsel-grep and M-x counsel-grep-or-swiper both fail:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("[ \f\011\n\015\013]+" nil 0)
split-string(nil)
counsel-grep()
funcall-interactively(counsel-grep)
call-interactively(counsel-grep record nil)
command-execute(counsel-grep record)
#f(compiled-function (cmd) #<bytecode 0xe962d5>)("counsel-grep")
ivy-call()

In the process of capturing the debug ouput I found a single line of text that causes the error. It's a 145K bytes long, but note that counsel-grep works fine if you are not in org mode. See attachment: ivy-read.zip

@abo-abo abo-abo closed this in 770936b Jul 3, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jul 3, 2018

Thanks, please test.

@rnadler

This comment has been minimized.

Copy link
Author

commented Jul 3, 2018

Hmmm... updated to counsel-20180703.818, but the change is not there. Will the change be in a subsequent release?

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Jul 3, 2018

I don't know if a new release was published already. Probably not, it takes at least 4 hours to publish all packages. But you can test with the master branch of this git repo.

@rnadler

This comment has been minimized.

Copy link
Author

commented Jul 3, 2018

Got counsel.el from master with the changes, but it still fails in the same place for me. Will investigate as time allows.

@rnadler

This comment has been minimized.

Copy link
Author

commented Jul 3, 2018

Error is occurring before (counsel.el#L2653) the changes you added.

(counsel-require-program (car (split-string counsel-grep-base-command)))

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jul 4, 2018

If that's the line that errors, then something is setting or binding counsel-grep-base-command to nil for some reason.

@rnadler

This comment has been minimized.

Copy link
Author

commented Jul 4, 2018

Here's why counsel-grep-base-command is nil: Centaur Emacs init-ivy.el#L119. I don't have either rg or ag installed so the variable is set to nil. Maybe @seagle0128 can resolve this.

I'm still not sure why the behavour was intermittent before...

Thanks for all your help!

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jul 4, 2018

In that case, I suggest closing this issue and opening another one at https://github.com/seagle0128/.emacs.d/issues

seagle0128 added a commit to seagle0128/.emacs.d that referenced this issue Jul 5, 2018
@seagle0128

This comment has been minimized.

Copy link
Contributor

commented Jul 5, 2018

I just noticed this thread. Since I am using rg, I didn't encounter this issue.
@rnadler I've fixed in seagle0128/.emacs.d@c8f3c32. Please test.

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Jul 5, 2018

Oops, sorry; I didn't notice this issue was already closed.

@rnadler

This comment has been minimized.

Copy link
Author

commented Jul 5, 2018

@seagle0128, Fix works fine. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.