Questions tagged [coding-conventions]
13 questions
16
votes
1 answer
Why do elisp files have end of file comments?
Why do elisp files usually end with
;;; file.el ends here?
Is there some historical reason why this was useful? I've seen it recommended in elisp style guides and I still see it in modern elisp packages. auto-insert-mode also adds such a comment…

Qudit
- 828
- 8
- 16
9
votes
3 answers
Closing parenthesis on own line unacceptable?
I've been using Emacs for quite a number of years now, but I only recently stumbled over the coding standards. There it is stated:
Don't make a habit of putting close-parentheses on lines by themselves; Lisp programmers find this…

Meaningful Username
- 777
- 5
- 14
9
votes
2 answers
Why does `eval-when-compile` run at file load and byte-compiled to .elc?
Common idiom to workaround macro expansion or resolve warning about undefined variables during byte-compilation:
(eval-when-compile
(require 'cl-lib))
But this require ... compiled into .elc file! I found that cl-eval-when have proper semantic…

gavenkoa
- 3,352
- 19
- 36
8
votes
2 answers
add-to-list vs add-hook?
What is the difference between add-to-list vs add-hook?
For example I see in progmodes/make-mode.el:
(add-hook 'completion-at-point-functions
#'makefile-completions-at-point nil t)
instead of add-to-list.
add-hook has interesting…

gavenkoa
- 3,352
- 19
- 36
4
votes
1 answer
Why do people add their initials to the names of tailor-made functions added to their config file?
Is it a namespace trick to prevent future problems?
I noticed a pattern in the Emacs community. When people create some tailor made function and insert it on their init files, they use a convention on the name prefixing it with their initials.
For…

Pedro Delfino
- 1,369
- 3
- 13
4
votes
1 answer
When to split long elisp files to separate files?
Some Lisp programmers advocate keeping code mainly into one file, following the concepts of Literate Programming in the Large, (note: the video is more about the method than Axiom, an open source computer algebra system written mostly in…

gsl
- 1,742
- 17
- 34
3
votes
2 answers
When to return nil vs. signal error?
This may be a more general programming question that just for Emacs Lisp, but I'm wondering when a function should signal an error vs. return nil.
Raising an error is "failing loudly", which is usually a good thing for debugging, etc. But for a…

Tianxiang Xiong
- 3,848
- 16
- 27
2
votes
3 answers
Macros prefixed with 'with'
Many emacs macros are prefixed with 'with' keyword in elisp. In an imperative language like python, with statement is used to create a temporary variable like this,
with controlled_execution() as tempVar:
some code
However, in macros like…

Madhavan
- 1,957
- 12
- 28
2
votes
1 answer
Giving faces compliant names
The description of defface in (info "(elisp) Defining Faces")
says that the name of a face should not end in -face. But
most faces declared in font-lock.el do use the suffix -face.
How does this fit together?

Andreas Matthias
- 195
- 1
- 8
0
votes
0 answers
How to detect whether current major-mode allows dashes ("-") in its symbol names?
To enable smart-dash ("an Emacs minor mode which redefines the dash key to insert an underscore within C-style identifiers and a dash otherwise") after falling in love with Kebab/Lisp case,
I want to check whether current programming language…

Daanturo
- 180
- 8
0
votes
1 answer
Best practice for long string literals in emacs lis?
What are best practices for handling long string literals in Emacs Lisp?
E.g.
(... stuff that causes indentation ...
(error "`my-config-alist' mapped command `%s' to `%S' instead of a major-mode"
…

kdb
- 1,561
- 12
- 21
0
votes
2 answers
Idiomatic conversion of non-nil to explicit t
Is there an idiomatic/commonly used/established convention to convert non-nil values to t that other Elisp programmers are likely to recognize?
Sometimes I have a non-nil value, say from calling member, that I want to return as either t or nil (so…

chwarr
- 105
- 6
0
votes
0 answers
Are super and hyper key modifier permitted in major/minor modes?
I looked to (info "(elisp)Key Binding Conventions") and (info "(elisp)Keymaps and Minor Modes") and (info "(elisp)Major Mode Conventions") and didn't found any restriction to use H- and s- modifier in modes.
I heavily relay on s- (super) key as user…

gavenkoa
- 3,352
- 19
- 36