Emacs Lisp Naming Convention
reddit discussion, on emacs naming convention
- Using dashes only, as in
package-prefix-function-name, is the convention of the mothership, FSF GNU emacs.
- Using slash to separate package and function name, as in
package-prefix/function-name, is popular nonstandard convention.
many gnu elisp conventions, are kinda vague, some are out-dated, some are ill-designed.
many packages outside GNU emacs do not adhere to them, but are tolerated. For example, the most popular packages on MELPA, dash, s, break these conventions.
it's a gray area, between conservative and progressive.
if you chose progressive, the problem is that huge amounts of existing lisp code are not gonna change (lots work, risking bug to fix but little benefit, or packages not maintained but still used, etc.), you end up with inconsistency.
if you chose conservative, then you reduce progress and adoptation.
For example, let's say the naming convention. Besides the prefix:
• predicate function names could end in “?” (as in Scheme/Racket Lisp, ruby, clojure) instead of “p”. Since question mark is more intuitive, is easier to identify, and can be syntactically verified by machine. (p can't because not all functions ending in p is a predicate.)
• the double dash for internal methods (aka auxiliary functions) is kinda unsaid convention, and code out there may or may not conform. (if we go strict about this, you'll find huge amount of functions need to be renamed.)
• variable beginning with low line _ as form-filler unused var is another unsaid convention. It kinda came from modern (say after 2010) practices in other langs (i think python ruby).
• in function doc string, it's GNU emacs convention to use ALLCAPS for parameters. This is also not a perfect convention, since elisp is case sensitive. This make it hard to actually have parameters that's ALLCAP or camelCase or single capital letter such as Z. Also, using ALLCAPS is a weak, ambiguous markup, since it prevents the normal English convention of using ALLCAPS for emphasis.
but as most coding convention goes, they are not systematically designed. They came by-and-by via practice and evolution. It'd be nice if the language enforce syntactic conventions. For example, var of ALLCAPS has semantics of global var. (sigils in perl, ruby, golang, and other lang feature these) An extreme case would be syntax algebra, where the syntax alone is the semantics and can be processed/manipulated (like highschool algebra). Formal Languages are such case.
- The Sigils WAR, Language Design and Coding Convention (2016)
- Docstring Convention: Python vs Emacs Lisp
- Sigil for Variable Names
Emacs Lisp Misc Essays
- Text Processing vs Structured
- Elisp coding style: let forms
- ELisp Naming Convention
- Some and Every
- What is the Function fn?
- Symbol vs String
- Meaning of Lisp List, Function Type, and Syntax Coloring
- Elisp vs Perl: Validate File Links
- Emacs Lisp: Relation of Curor Position to Begin/End of Matching Pairs in Source Code
- Text Processing: ELisp vs Perl
- Controversy of Common Lisp Package in ELisp
- Lisp List Problem
- Lisp-1 vs Lisp-2
- ELisp Problems: Trim String, Regex Match Data, Lacking Namespace
- Functional Programing: Function Output Should Always Have the Same Structure