alezost / guix.el

Emacs interface for GNU Guix package manager
https://emacs-guix.gitlab.io/website/
GNU General Public License v3.0
141 stars 16 forks source link

Breaks tab completion in shell-mode buffers #58

Open ieure opened 11 months ago

ieure commented 11 months ago

When I type a command other than guix in my shell, I can complete fine. If I type:

l0p!ieure:~$ ls ~/Pro

...and then press TAB, it expands to:

l0p!ieure~$ ls ~/Projects/

If I do the same thing, but with any command beginning with guix, such as:

l0p!ieure~$ guix home reconfigure ~/Pro

...then tab completion doesn't work, and I get this error in my *Messages* buffer:

guix-geiser-eval: Error in evaluating guile expression: ice-9/boot-9.scm:1685:16: In procedure raise-exception:
/home/ieure/.config/guix/current/share/guile/site/3.0/guix/scripts/deploy.scm:176:7: Unknown # object: "#~"

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(emacs-guix) [5]> 

This is the stack trace up to that error:

Debugger entered--Lisp error: (error "Error in evaluating guile expression: ice-9/boot-9...")
  error("Error in evaluating guile expression: %s" "ice-9/boot-9.scm:1685:16: In procedure raise-excep...")
  guix-geiser-eval("(help-string )" #<buffer *Guix Internal REPL*>)
  guix-geiser-eval-read("(help-string )" #<buffer *Guix Internal REPL*>)
  guix-eval-read("(help-string )")
  guix-help-string(nil)
  guix-pcomplete-search-in-help("^   \\([[:word:]]\\(?:[[:word:]]\\|-\\)+\\)" 1)
  apply(guix-pcomplete-search-in-help "^   \\([[:word:]]\\(?:[[:word:]]\\|-\\)+\\)" 1 nil)
  #f(compiled-function (&rest commands) #<bytecode 0xa94b9d9a9533046>)()
  apply(#f(compiled-function (&rest commands) #<bytecode 0xa94b9d9a9533046>) nil)
  guix-pcomplete-commands()
  pcomplete/guix()
  pcomplete-completions()
  pcomplete-completions-at-point()
  comint-completion-at-point()
  completion--capf-wrapper(comint-completion-at-point all)
  completion-at-point()
  funcall-interactively(completion-at-point)
  command-execute(completion-at-point)

This happens for any command which begins with guix; if guix is in any position other than the start of the command, it works fine, so commands like ls guix are unaffected.

The immediate issue is that guix-help-string is called with a nil argument, which it can't handle and has no guard for. The potential larger issue is that this is being called when the thing needs to be completed isn't a guix command, but a file path.

Changing guix-help-string to return an empty string when commands is nil prevents the error, but completion of guix subcommands doesn't work, and I'm not convinced this is a proper fix.

I'm using guix.el on GuixSD, installed via Guix. My emacs-guix package version is 0.5.2-7.455272c. Here's the output of guix describe:

  guix 61f2d84
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 61f2d84e75c340c2ba528d392f522c51b8843f34
  katco-upstream-staging 80bfd9f
    repository URL: https://github.com/kat-co/guix-channels.git
    branch: upstream-staging
    commit: 80bfd9f61502dcc2df9da21d7804480732157e97
  atomized 7cdeec5
    repository URL: https://codeberg.org/ieure/atomized-guix.git
    branch: main
    commit: 7cdeec5154ab140d8463f38113b25bd4a334a080
  nonguix 0f7c8e3
    repository URL: https://gitlab.com/nonguix/nonguix
    branch: master
    commit: 0f7c8e3e2b72c19d8a60b2a7e94a9ca8783d4754