1

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?

2
  • "What if there are no any *-mode functions inside mode?" makes no sense. By strong convention, every Emacs mode should be a function named *-mode, so I don't understand what the "mode" at the end of your sentence refers to in this context, or which scenario you are considering where you might have this issue. Do you mean the file/library? No one would refer, even colloquially, to a library which did not define any mode as a "mode". – phils Apr 30 '20 at 22:57
  • "What if mode is library?" is a bit confused as well. A file of elisp code is a library; "library" is the term for that. A library may or may not include any modes. – phils Apr 30 '20 at 22:58
6

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).

1
  • 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.