My question is similar to this one, except for emacs instead of vim. The issue is that I have a cpp file that I want to open and when I type f[TAB] it autocompletes to foo the binary file foo instead of foo.cpp. Is there a way to turn of autocomplete for files with certain (or no) extension? Or is there a way to prioritize certain extensions?

EDIT: I've used this solution for autocompletion in the minibuffer, but I want a solution for Bash autocompletion.

EDIT: I've found that I can do export FIGNORE=.bin to ignore all files with the .bin extension in Bash autocomplete. The issue with this solution is that this doesn't work for a file with no extension, and also there's no way to make this occur only when there are no .cpp files in the same directory.


If you give it some extension (e.g. .bin) then you can ignore it with completion-ignored-extensions:

When completing file names, Emacs usually omits certain alternatives that are considered unlikely to be chosen, as determined by the list variable completion-ignored-extensions. Each element in the list should be a string; any file name ending in such a string is ignored as a completion alternative. Any element ending in a slash (/) represents a subdirectory name. The standard value of completion-ignored-extensions has several elements including ".o", ".elc", and "~". For example, if a directory contains ‘foo.c’ and ‘foo.elc’, ‘foo’ completes to ‘foo.c’. However, if all possible completions end in “ignored” strings, they are not ignored: in the previous example, ‘foo.e’ completes to ‘foo.elc’. Emacs disregards completion-ignored-extensions when showing completion alternatives in the completion list.


|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.