Subject: Re: bug#57905: [PATCH] Fix eshell directory and executable completion on action t

From: Eli Zaretskii <[email-masked]>
Date: Sun, 18 Sep 2022 10:40:36 +0300

> From: Daniel Pettersson <[email-masked]>
> Date: Sun, 18 Sep 2022 00:55:48 +0200
> 
> +(defun eshell--pcomplete-executables ()
> +  "Complete amongs a list of directories and executables.
> +
> +Wrapper for `pcomplete-executables' or `pcomplete-dirs-or-entries',
> +depending on the value of `eshell-force-execution'.
> +
> +Adds path prefix to candidates independent of `action' value."
> +  ;; `pcomplete-entries' returns filenames without path on `action' t
> +  ;; use current string directory as done in `completion-file-name-table'
> +  ;; when `action' is nil to construct executable candidates.
> +  (let* ((table (if eshell-force-execution
> +                    (pcomplete-dirs-or-entries nil #'file-readable-p)
> +                  (pcomplete-executables))))
> +    (lambda (string pred action)
> +      (let ((cands (funcall table string pred action)))
> +        (if (eq action t)
> +            (let ((specdir (file-name-directory string)))
> +              (mapcar
> +               (lambda (cand)
> +                 (if (stringp cand)
> +                     (concat specdir cand)
> +                   cand))
> +               cands))
> +          cands)))))

Please don't use 'concat' to create a file name with leading
directories; instead, please use file-name-concat.