Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

http://www.gnu.org/software/emacs/manual/html_node/emacs/Completion-Options.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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