Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make emacs ignore some specific file names, for completion?

In emacs, when im typing the begining of a file name, and then press tab for autocompletion, here's what i get :

Possible completions are:

dummy.cmi dummy.cmx

dummy.ml dummy.o

I want emacs to ignore object files (.o, .cmx, .cmi) and directly complete with dummy.ml

Is there a way to specify that behaviour in emacs ? some sort .emacsignore mechanism like in git?

like image 322
ghilesZ Avatar asked Oct 18 '25 22:10

ghilesZ


1 Answers

The variable that controls ignored file extensions for completion is completion-ignored-extensions. It should already have a couple of extensions in it, but you can add your own.

If you do M-x customize-variable RET (i.e. Meta+x, type customize-variable and hit Enter) Then type in: completion-ignored-extensions Enter

You will now get a list of what's already in it. You can also delete entries and add new ones.

You can also add this to your init.el/.emacs:

(add-to-list 'completion-ignored-extensions ".blah")

To add multiple elements, instead of duplicating that line:

(setq completion-ignored-extensions
    (append completion-ignored-extensions
        (quote
        (".ext1" ".ext2" ".ext3"))))
like image 188
sbrk Avatar answered Oct 21 '25 00:10

sbrk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!