gnu.org (original) (raw)

You should choose a short word to distinguish your program from other Lisp programs. The names of all global symbols in your program, that is the names of variables, constants, and functions, should begin with that chosen prefix. Separate the prefix from the rest of the name with a hyphen, ‘-’. This practice helps avoid name conflicts, since all global variables in Emacs Lisp share the same name space, and all functions share another name space35. Use two hyphens to separate prefix and name if the symbol is not meant to be used by other packages.

Occasionally, for a command name intended for users to use, it is more convenient if some words come before the package’s name prefix. For example, it is our convention to have commands that list objects named as ‘list-something’, e.g., a package called ‘frob’ could have a command ‘list-frobs’, when its other global symbols begin with ‘frob-’. Also, constructs that define functions, variables, etc., work better if they start with ‘define-’, so put the name prefix later on in the name.

This recommendation applies even to names for traditional Lisp primitives that are not primitives in Emacs Lisp—such ascopy-list. Believe it or not, there is more than one plausible way to define copy-list. Play it safe; append your name prefix to produce a name like foo-copy-list or mylib-copy-listinstead.

If you write a function that you think ought to be added to Emacs under a certain name, such as twiddle-files, don’t call it by that name in your program. Call it mylib-twiddle-files in your program, and send mail to ‘bug-gnu-emacs@gnu.org’ suggesting we add it to Emacs. If and when we do, we can change the name easily enough.

If one prefix is insufficient, your package can use two or three alternative common prefixes, so long as they make sense.