If you are talking about binding keys for your own use, then this is the rule: You can bind any keys you like.
If you want to be sure not to bind a key that might already be bound then use C-c followed by a letter. All such keys are reserved for users (see next).
If you are talking about binding keys in code (e.g., a library) that you write, for use by ...
Why do some people use -- in their function names?
This is a standard Elisp convention for indicating the function is internal, i.e. one that should not be used or depended on by external packages. Quoth (elisp) Coding Conventions:
You should choose a short word to distinguish your program from
other Lisp programs. The names of all global symbols in your
cl-destructuring-bind was designed more or less specifically to destructure data made of cons cells. pcase-let on the other hand is just a special case of pcase which was designed to handle arbitrary data and be extensible (and be able to discriminate rather than only destructure).
So cl-destructuring-bind has a slightly more concise syntax for the simple ...
Note that if your library is intended to be installed via package.el (or similar) and you have included an autoload cookie for foo-mode, and you choose to implement the auto-mode-alist manipulation, then you will want to use an autoload cookie for that as well. Otherwise the user would need to either load your library before visiting a *.foo file, or else ...
I don't think there's a very satisfactory answer, but here's what I used today for testing the new undo-redo command I installed into master:
(defun simple-tests--exec (cmds)
(dolist (cmd cmds)
(setq last-command this-command)
(setq this-command cmd)
I'd say yes. If the user has installed foo-mode, they have installed it to use with .foo files. When I run emacs -Q, there are 184 items in the list (including .org, .java, .xml, .letter, and more, so it's not kept too small.
@Drew's answer is much more nuanced and detailed.
This is a perfectly valid question! There is the convention that the C-x is reserved by emacs itself whereas the C-c prefix is used for user defined keybindings.
Take a look at this, especially the "Reserved keys" section. I am pretty sure that this information is stated in the emacs manual as well, but I ...
(and val t)
is the cleanest and clearest.
(if val t nil)
is also clear but is slightly more verbose and less clean.
There may be efficiency advantages to using
(not (not val))
as Stefan mentions. However, efficiency gains are likely minimal in most cases since negation is a cheap operation.
While double negation is clearly intentional, the reason ...
The better option is:
(not (not X))
Some of the advantages are in the ability of the byte-compiler to optimize it away. Also for me it's easy to visually see that it's a "virtual no-op" yet at the same time it makes it clear that it was introduced on purpose.
There are exceptions. ;-)
Some may be vestiges. In the Olden Days it was common to have both a variable for the face and the face itself, and the variable, or both, had a name that ended in -face.
Some are not just vestiges, at least for the variables. One reason to have a variable is to be able to bind it, to temporarily change which face is used. This is ...