Questions tagged [elisp-conventions]
12 questions
20
votes
2 answers
Convention about using C-x or C-c as prefix keys
What are the conventions for using C-x, C-c, or M- as prefix keys?
For example: is C-x, etc., for saving or visiting buffers? Is C-c, etc., for text editing?
Background
Maybe this is a silly question. I use a Spanish keyboard, and sometimes…

anquegi
- 739
- 5
- 21
6
votes
2 answers
Underscore in if-let
I often find myself wanting to do something like this:
(if-let* ((foo (get-foo))
(_ (conditionp foo))
(bar (get-bar-from-foo foo)))
...)
As an alternative to:
(let ((foo (get-foo)))
(when (and foo (conditionp foo))
…

C4ffeine Add1ct
- 460
- 3
- 8
5
votes
1 answer
Double hyphen in Elisp function names
Why do some people use -- in their function names? Here's an example from elfeed-search.el:
(defun elfeed-search--header ()
"Returns the string to be used as the Elfeed header."
(if (eql (car elfeed-search--header-cache) (buffer-modified-tick))
…

american-ninja-warrior
- 3,773
- 2
- 21
- 40
4
votes
1 answer
Buffer Name Surrounded by Asterisks (*)
For example, *scratch*, *Messages*.
Is this some kind of convention?
If so, what does it mean?

shynur
- 4,065
- 1
- 3
- 23
4
votes
1 answer
Idiomatic way to access values of an alist
The theme modus-vivendi exports an alist of named colors:
(deftheme modus-vivendi
"Elegant, highly legible and customizable dark theme.
Conforms with the highest legibility standard for color contrast
between background and foreground in any…

firstname gklsodascb
- 83
- 5
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
Difference between pcase-let & cl-destructuring-bind?
I noticed both pcase-let and cl-destructuring-bind seem to perform the same operation.
Is there any difference or reason to use one instead of the other?
eg:
(pcase-let ((`(,filename ,buf) (pop filename-and-buffer-list)))
;; do stuff.
)
Seems…

ideasman42
- 8,375
- 1
- 28
- 105
3
votes
1 answer
“Obarray” Got Its Name From ...?
What does the name “obarray” stand for?
Obarray seems to be a property unique to Elisp that is not found in other Lisp-like languages.
So its name probably came up with by the early Emacs developers; where did it come from?

shynur
- 4,065
- 1
- 3
- 23
3
votes
2 answers
When writing a new major mode, should it add itself to auto-mode-alist?
I am defining a new major mode, foo-mode, which is closely and only associated with .foo files. Should foo-mode.el fiddle with auto-mode-alist to add this association, or is that the user's responsibility?

Jack Kelly
- 135
- 6
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
1
vote
1 answer
How to automate user-testing with elisp?
Is it possible to automate testing user input?
An example of this could be multiple editing operations, undo, saving, reverting the buffer etc. Then checking the buffer contents is what the test expects.
The user input could be keyboard shortcuts or…

ideasman42
- 8,375
- 1
- 28
- 105
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