szermatt / emacs-bash-completion

Add programmable bash completion to Emacs shell-mode
GNU General Public License v2.0
280 stars 33 forks source link

Autocompletion causes Lisp error #35

Closed noverby closed 5 years ago

noverby commented 5 years ago

I'm using emacs-bash-completion with emacs 26.1 for eshell autocompletion using the code: link

When I try to autocomplete with any bash command I'm getting the following error:

Debugger entered--Lisp error: (args-out-of-range #<buffer  bash-completion> 18 20)
  buffer-substring-no-properties(20 18)
  bash-completion-send("PROMPT_COMMAND='';PS1='\011$?\013'" #<process *bash-completion*> 30)
  bash-completion-require-process()
  bash-completion-dynamic-complete-nocomint(33 42)
  (nth 2 (bash-completion-dynamic-complete-nocomint (save-excursion (eshell-bol) (point)) (point)))
  (closure (t) nil (nth 2 (bash-completion-dynamic-complete-nocomint (save-excursion (eshell-bol) (point)) (point))))()
  pcomplete--here((closure (t) nil (nth 2 (bash-completion-dynamic-complete-nocomint (save-excursion (eshell-bol) (point)) (point)))) nil nil nil)
  (pcomplete-here (nth 2 (bash-completion-dynamic-complete-nocomint (save-excursion (eshell-bol) (point)) (point))))
  (while (pcomplete-here (nth 2 (bash-completion-dynamic-complete-nocomint (save-excursion (eshell-bol) (point)) (point)))))
  eshell-bash-completion()
  pcomplete-completions()
  pcomplete-completions-at-point()
  completion--capf-wrapper(pcomplete-completions-at-point optimist)
  run-hook-wrapped(completion--capf-wrapper pcomplete-completions-at-point optimist)
  company--capf-data-real()
  company--capf-data()
  company-capf(prefix)
  apply(company-capf prefix)
  company-call-backend-raw(prefix)
  apply(company-call-backend-raw prefix)
  company--force-sync(company-call-backend-raw (prefix) company-capf)
  company-call-backend(prefix)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer *eshell-1*> #<window 4 on *eshell-1*> 68 42)
  apply(company-idle-begin (#<buffer *eshell-1*> #<window 4 on *eshell-1*> 68 42))
  timer-event-handler([t 23616 52730 935312 nil company-idle-begin (#<buffer *eshell-1*> #<window 4 on *eshell-1*> 68 42) nil 201000])
szermatt commented 5 years ago

Thank you for the report.

Something is really odd, here, in the output of the bash process started by bash-completion-require-process. Setting PS1 did not have the expected effect: the status of the operation isn't returned as it should in the new prompt.

Which version of bash are you using, on which platform?

What are the values of bash-completion-prog and bash-completion-args? (To see and modify these values, M-x customize-group then choose group bash-completion)

Does it work if you set bash-completion-args to "--noediting --norc" ? If yes, there might be something in your .bashrc that is throwing off the communication between bash and bash-completion.el.

noverby commented 5 years ago

I found the source of the problem.

The error only occurs if bash is set to vi mode using:

set -o vi

Thanks for the help. It was useful for doing diagnostics. :)

szermatt commented 4 years ago

42 introduces work around for set -o vi, so completion works even when this option is set.