How can I get Emacs to ignore, say, both .pdf and .PDF files without listing both ".pdf" and ".PDF" in completion-ignored-extensions?

  • The question seems unclear. (1) Do you want to ignore only the file names .pdf and .PDF or any file name that ends in those? (2) Ignore where/when? Just during completion when reading a file name (e.g. read-file-name)?
    – Drew
    Nov 10, 2018 at 18:52

2 Answers 2


Quoth (emacs) Completion Options, the paragraph just before completion-ignored-extensions is described:

   When completing file names, case differences are ignored if the
variable ‘read-file-name-completion-ignore-case’ is non-‘nil’.  The
default value is ‘nil’ on systems that have case-sensitive file-names,
such as GNU/Linux; it is non-‘nil’ on systems that have case-insensitive
file-names, such as Microsoft Windows.  When completing buffer names,
case differences are ignored if the variable
‘read-buffer-completion-ignore-case’ is non-‘nil’; the default is ‘nil’.

If read-file-name-completion-ignore-case is nil, and completion-ignored-extensions includes only ".pdf", then ".PDF" will not be ignored.

If you customise read-file-name-completion-ignore-case to be non-nil, and completion-ignored-extensions includes only ".pdf", then both ".pdf" and ".PDF" will be ignored.

If you want general file name completion (e.g. on the non-extension part) to be case-sensitive, and only completion-ignored-extensions matching to be case-insensitive, then you need to include both ".pdf" and ".PDF" in completion-ignored-extensions.

  • I want completion to stay case sensitive but I'd like the convenience of excluding files from ido's completion just by listing their lowercase extension. What I was looking for was something like running upcase on each extension using dolist (I didn't know about them back then). But in the end just having ".JPG" ".PDF" ".PNG" in the list is enough to cover the great majority of cases. Sep 5, 2020 at 16:46

Guessing that you want to include file names that end in .pdf and .PDF, except for the two file names that are just those strings (nothing before the dot).

If you use Icicles then you can do this by setting or binding option icicle-file-no-match-regexp to a regexp that excludes matching file-name candidates. You could use "^[.]pdf$" (or "^[.][pP][dD][fF]$").

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.