It's possible to ask completion to not suggest files with particular file extensions, by:

(setq completion-ignored-extensions
      (append completion-ignored-extensions
               (".o" ".aux"))))

However, I'm not able to determine how to pattern-match on regular expressions before the "." and not just after it. For example, I don't want files that end with "_flymake.hs" to be suggested by completion modes. How could I accomplish this?

  • Did you happen to try adding "_flymake.hs" to the list to see if it worked? I'm wanting to say that extensions really just means "end of filename" Sep 29, 2015 at 11:31
  • @JonathanLeech-Pepin thanks, I tried that. It doesn't seem to work though, at least in a Helm find files buffer. Sep 29, 2015 at 11:38
  • Are those really regular expressions? Dot character has special meaning in regex, if you want to use literal dot, you need to escape it: \.. Also, you want to only match files where these string happen at the end of the string, i.e. "\\.\\(:?o\\|aux\\)$".
    – wvxvw
    Sep 29, 2015 at 12:20
  • I was using this document as my example: glue.umd.edu/afs/glue.umd.edu/system/info/olh/Text/Text_Editors/… , starting (setq completion-ignored-extensions ... ) Sep 29, 2015 at 12:27

2 Answers 2


The dot is not special in completion-ignored-extensions, so

(push "_flymake.hs" completion-ignored-extensions)

should do the job. If it doesn't, then I'd guess that it's either because completion-ignored-extensions is not used (or used incorrectly) by the completion system you're using, or because all the candidates would be eliminated by completion-ignored-extensions.

  1. Does your completion system/mode even support regexp matching? Vanilla Emacs completion does not, out of the box.

  2. At any rate, the patterns in completion-ignored-extensions are not regexps. They are not even filename glob patterns. They are literal text that file names must match at their ends. In particular, the . is not special, but matches a literal ..

  3. Adding "_flymake.hs" to completion-ignored-extensions should make completion ignore file names that end in that literal suffix. E.g., file name "foo_flymake.hs" should be ignored (not available as a completion candidates). Is this not what you see?

  4. Provide a recipe to reproduce your problem, given knowledge of #1-3, above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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