Ludovic Courtès (2015-06-08 22:19 +0300) wrote:

> PS: I wonder if something could also be done for “./pre-inst-env guix”...

IIUC there is no simple way to configure pcomplete for that.  Here is
an invasive hack I came up with:

--8<---------------cut here---------------start------------->8---
(defvar al/pcomplete-skipped-commands
  '("sudo" "pre-inst-env")
  "List of special commands for `al/pcomplete-reduce-args-maybe'.")

(defun al/pcomplete-reduce-args-maybe (&rest _)
  "Change some global variables to complete a special command properly.
If a command from `al/pcomplete-skipped-commands' is being
completed, skip it and perform completion as if the next argument
was the current command."
  (when pcomplete-args
    (let ((cmd (file-name-nondirectory (car pcomplete-args))))
      (when (member cmd al/pcomplete-skipped-commands)
        (setq pcomplete-args (cdr pcomplete-args)
              pcomplete-last (1- pcomplete-last))))))

(advice-add 'pcomplete-parse-arguments
  :after #'al/pcomplete-reduce-args-maybe)
--8<---------------cut here---------------end--------------->8---

-- 
Alex

Reply via email to