I am not sure when I should name file x-mode.el and when x.el.

Note that because of established practice mode writer should put (provide 'x) or (provide x-mode) to the end of file and end-users load your mode via (require 'x) or (require x-mode).

What if there are no any *-mode functions inside mode?

What if mode is library?

What if mode is minor mode?


Don't name your file x-mode.el if it does not actually provide a mode of some sort: that seems confusing. If you are providing library x, just call the file x.el.

From what I've seen, most modes (major or minor) do not actually use x-mode.el either. That naming convention is generally used in multi-file packages where the core functionality is implemented in one or more separate files, and then the x-mode.el file contains only the actual mode definition and perhaps related customization definitions.

The other typical usage I've found is for programming language modes. Emacs itself has a number of these, but file names are not consistent: see e.g. perl-mode.el and ruby-mode.el, vs. prolog.el and python.el.

But of course naming is subjective -- for any convention you'll be able to find counter-examples.

(Anecdotally I have about 65 packages installed at the moment and found 7 files named foo-mode.el. My Emacs installation has 48 such files, many of which are in progmodes or textmodes; and many of which follow the pattern where there is a library file + a mode file, e.g. help.el/help-model.el, calc.el/calc-mode.el, etc).

  • Most major mode packages I've seen use -mode as a suffix. Minor modes rarely do. – Tianxiang Xiong Mar 29 '17 at 22:28

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.