* pcomplete filename on unregistered commands
@ 2021-10-11 1:01 Carlos Pita
2021-10-11 2:59 ` Carlos Pita
0 siblings, 1 reply; 2+ messages in thread
From: Carlos Pita @ 2021-10-11 1:01 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
in shell-mode there are a number of c-a-p functions registered:
comint-c-a-p-replace-by-expanded-history
shell-environment-variable-completion
shell-command-completion
shell-c-a-p-replace-by-expanded-directory
pcomplete-completions-at-point
shell-filename-completion
comint-filename-completion
Most of the time it is pcomplete-completions-at-point the one which
returns the completion candidates, and this works great as long as the
there is a pcomplete/xxx function registered for the command xxx.
Now, many usual commands like cp don't have a pcomplete handler so they
behave very poorly regarding completion, take for example:
cp <TAB>
this doesn't give me any completion candidate! If I instead do:
cp ./<TAB>
I then get filename completions (although not from pcomplete).
I find this behavior very inconvenient since often commands take
filenames as arguments and I would prefer filename completion to be
triggered by default for commands not known by pcomplete.
So what can I do? Is there a way to tell pcomplete to return filename
candidates by default? Or perhaps filename completion functions to
return candidates even upon an empty prefix?
Thank you in advance,
Carlos
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: pcomplete filename on unregistered commands
2021-10-11 1:01 pcomplete filename on unregistered commands Carlos Pita
@ 2021-10-11 2:59 ` Carlos Pita
0 siblings, 0 replies; 2+ messages in thread
From: Carlos Pita @ 2021-10-11 2:59 UTC (permalink / raw)
To: help-gnu-emacs
Doing some debugging reveals that this might be a bug.
In shell.el we have:
;; Don't use pcomplete's defaulting mechanism, rely on
;; shell-dynamic-complete-functions instead.
(setq-local pcomplete-default-completion-function #'ignore)
So pcomplete is falling back to the ignore (no-op) function. If you
kill the local binding in the shell buffer, then the default of the
default does complete paths.
And what are those dynamic complete functions that are favored in lieu of
pcomplete's default? I don't know, but next in the completion sequence
we have:
(defun comint-filename-completion ()
"Return completion data for filename at point, if any."
(when (comint--match-partial-filename)
(comint--complete-file-name-data)))
Here (comint--match-partial-filename) will never be true so, ultimately,
we get no completion at all.
Best regards,
Carlos
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-11 2:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-11 1:01 pcomplete filename on unregistered commands Carlos Pita
2021-10-11 2:59 ` Carlos Pita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).