5

I know I can get case-insensitive filename completion in the minibuffer using read-file-name-completion-ignore-case, but this doesn't seem to apply to all filename completion in the minibuffer. Specifically, it doesn't seem to apply when I'm using shell-command. Example:

$ emacs -Q
M-: (setq read-file-name-completion-ignore-case t)
M-! touch /tmp/HelloThere
C-x C-f /tmp/hello<TAB>  <-- this completes to HelloThere, as expected
M-! shell-command<RET>ls /tmp/Hello<TAB>  <-- this completes to HelloThere, as expected
C-g
M-! shell-command<RET>ls /tmp/hello<TAB>   <-- no completion

Is there any way to get whatever is completing /tmp/HelloThere while reading from the minibuffer for a shell-command to respect read-file-name-completion-ignore-case?

mgalgs
  • 464
  • 4
  • 12

1 Answers1

-1

Bind tags-case-fold-search to t in a function that otherwise just calls tags-completion-at-point-function, and put that function on completion-at-point-functions.

The problem you are running into is that read-file-name-completion-ignore-case is not used, and that is because read-file-name is not used.

(Alternatively, you can bind tags-case-fold-search to non-nil and non-t, and bind case-fold-search to non-nil.)

Drew
  • 75,699
  • 9
  • 109
  • 225
  • So you mean like [this](https://gist.github.com/mgalgs/64b3d6282f9e14c698d7), right? Still doesn't work... :( – mgalgs Oct 14 '14 at 03:54
  • `completion-at-point-functions` should be a list of functions, not a single function. You can discover this using `C-h v completion-at-point-functions` or by reading the Elisp manual, node [`Completion in Buffers`](https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Completion-in-Buffers). – Drew Oct 14 '14 at 14:07
  • Even so, `tags-completion-at-point-function` seems to rely on `etags`. I'm not certain that `etags` is guaranteed to have all of your filename completions unless you have configured it to do so. Is that right? – nispio Oct 14 '14 at 16:31
  • @nispio: The point is that this is the kind of completion that `TAB` provides in shell mode. Whether it does what you want in all cases is not the point. You can of course change the behavior of shell-mode completion, as you can change nearly anything in Emacs. But `tags-completion-at-point` is the completion it provides out of the box. In my own code ([**Icicles**](http://www.emacswiki.org/Icicles)), for example, I provide a [different kind of completion for shell (comint) mode](http://www.emacswiki.org/Icicles_-_Shell-Command_Enhancements). – Drew Oct 14 '14 at 16:38
  • Whoever downvoted: Care to say why? Something you didn't like? – Drew Oct 14 '14 at 22:01
  • -1, This answer is not working for the OP, and it is not working for me either. It is either wrong, or needs more information to be helpful. – nispio Oct 15 '14 at 04:21
  • @nispio: Thx for the explanation. Sorry for your trouble. At least I explained why `read-file-name-completion-ignore-case` has no effect here. And the code I suggested might at least serve as food for thought, if it does not work out of the box for you. And if you are expecting not to have `etags` installed or not to use `etags` then, as I say, you will need to define a different function for shell-mode completion from what vanilla Emacs uses (`tags-completion-at-point`). The code here *assumes the same thing that Emacs assumes*: that you use `etags` - nothing more than that (AFAIK). – Drew Oct 15 '14 at 17:21
  • I am not *intentionally* avoiding `etags`, I'm just not sure what I need to do to make `etags` aware of the names in my directory tree. It would be helpful if you could add a code snippet that would work given `emacs -Q` (if that is possible). – nispio Oct 15 '14 at 17:27
  • @nispio: Someone else will need to do that. You can start with the Elisp manual, node `Tags` (and subnodes). But you will need to also have program `etags` (or equivalent) installed. And what gets tagged depends on your source language etc. That is really outside the current question, and I have no special expertise in it. – Drew Oct 15 '14 at 21:52