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

Args out of range #<killed buffer>, 0, 0 #13

Closed
amelio-vazquez-reina opened this issue Sep 9, 2015 · 11 comments
Closed

Args out of range #<killed buffer>, 0, 0 #13

amelio-vazquez-reina opened this issue Sep 9, 2015 · 11 comments

Comments

@amelio-vazquez-reina
Copy link

Original post in StackExchange here.


I have been trying to use visual-regexp-steroids without luck (a thread on this package can be found here)

When I do vr/replace (C-c p), I get a prompt in the minibuffer. I can enter regexps and Emacs shows interactively every match in the buffer. So far so good.

The problem comes when I click RET and then enter another string (the one I want to replace my matches with). If I now do RET (to do the actual replacements), I get the following message in the mini-buffer:

Args out of range #<killed buffer>, 0, 0

Why? How can I debug the problem and get it to work?

@benma
Copy link
Owner

benma commented Oct 9, 2015

Sorry for taking so long to respond, I have been away on travels.

Since I am not experiencing this problem, it would be helpful if you could provide a setup in which I can reproduce this (minimal init.el, emacs version, etc.).

To zero in on the problem:

  • Does visual-regexp (without the steroids add-on) work for you?
  • Does it work if you use the emacs engine? Use vr/select-replace, choose the emacs engine.

@amelio-vazquez-reina
Copy link
Author

Thanks @benma for looking into it. I will definitely try those suggestions this afternoon and post what I get.

@amelio-vazquez-reina
Copy link
Author

Hi @benma: vr/select-replace works perfectly well with the emacs engine, but it fails with Args out of range: #<killed buffer>, 0, 0 with the python engine. What Python version am I supposed to use with it? I think I am using Python 3.4.3 under the hood since my entire dev system is for Python 3.x.

@amelio-vazquez-reina
Copy link
Author

Also, vr/mc-mark works without problem, but vr/replace doesn't (I get the same error)

@amelio-vazquez-reina
Copy link
Author

In case it helps, I am using:

GNU Emacs 25.0.50.1 (x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F27))

@benma
Copy link
Owner

benma commented Oct 10, 2015

This Emacs and Python version should both work. Since you are seeing the matches when entering the search string, Emacs and Python are able to talk.

Please set debug-on-error to t (M-x toggle-debug-on-error) before you run vr/replace, and paste the stack trace after the error happens.
Do this while running emacs with emacs -q (which loads Emacs without any customizations), and try it in the default scratch buffer. You can use M-x load-library to load visual-regexp-steroids.

@amelio-vazquez-reina
Copy link
Author

Thanks @benma Below is the trace for a test with vr/select-replace with the python engine.

Debugger entered--Lisp error: (args-out-of-range #<buffer  *temp*> 0 0)
  match-string(1)
  vr--parse-replace("On GitHub as avazquez@xxx.com\n363 370 Zm9v\ncmVwbGFjZWQgMSBtYXRjaGVz\n")
  vr--run-command("python /Users/avazquez/.emacs.d/elpa/visual-regexp-steroids-20150411.416/regexp.py replace    --regexp \\(\\?m\\)arabica --replace foo" vr--parse-replace)
  ad-Advice-vr--get-replacements(#[(feedback feedback-limit) "\306\307\310\306\211\211r^Hq\210\311ed\")^Y^Z^[^\^]^^^[^^^\\3121\277^@\3131\263^@\314 ^V^\r^Hq\210^N^]b\210\315^^^^^N^^\205\255^@\3161C^@\3$
  apply(ad-Advice-vr--get-replacements #[(feedback feedback-limit) "\306\307\310\306\211\211r^Hq\210\311ed\")^Y^Z^[^\^]^^^[^^^\\3121\277^@\3131\263^@\314 ^V^\r^Hq\210^N^]b\210\315^^^^^N^^\205\255^@\316$
  vr--get-replacements(nil nil)
  vr--do-replace()
  vr/replace("arabica" "foo" 1 10602)
  funcall-interactively(vr/replace "arabica" "foo" 1 10602)
  call-interactively(vr/replace)
  vr/select-replace()
  funcall-interactively(vr/select-replace)
  call-interactively(vr/select-replace record nil)
  command-execute(vr/select-replace record)
  execute-extended-command(nil "vr/select-replace" "vr/select-re")
  funcall-interactively(execute-extended-command nil "vr/select-replace" "vr/select-re")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Let me know if there is anything else I can provide or test.

@benma
Copy link
Owner

benma commented Oct 12, 2015

Seems like your Python interpreter inserts "On GitHub as avazquez@xxx.com" on either stdout or stderr, which messes with the parsing.

Can you report the output of
echo arabica | python /Users/avazquez/.emacs.d/elpa/visual-regexp-steroids-20150411.416/regexp.py replace --regexp arabica --replace foo?

Does it contain the "On Github ..." string? If so, is it printed on stdout or stderr (if it is stderr, I can easily write a patch to fix it)? In any case, try to figure out where it comes from and get rid of it ;) I googled for that string but couldn't really find anything.

What happens if you use python2 (python2.7.x interpreter) instead of python3?

@amelio-vazquez-reina
Copy link
Author

Thank you @benma That did it! I removed the line that was printing that string to stdout. More specifically, I moved it from my .zshenv to .zshrc (zsh is my default shell), and that fixed it. I think I am all set! I appreciate your help on this. Thanks again!

@benma
Copy link
Owner

benma commented Oct 14, 2015

If you don't mind, please update the Stackoverflow post as solved.

@amelio-vazquez-reina
Copy link
Author

Thank you @benma. Of course. I just updated the Q&A with an answer and marked it as solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants