37
votes
Accepted
How to evaluate the variables before adding them to a list?
The general issue is that you need x and y to be evaluated before they get inserted in somelist. The issue with the quoted list (with ' as reader syntax) is that quote is a special form that does not ...

Dan♦
- 31k
34
votes
Accepted
How to know when or when not to use the single quote before variable names?
Short answer
If you are trying to use the variable itself, then use 'some-variable. If you are trying to use the value stored in the variable, use some-variable.
boundp uses symbol so it will look ...
27
votes
Accepted
What is the difference between ' and #' in front of a symbol?
In Emacs Lisp, if foo is a symbol, then 'foo and #'foo are completely equivalent. The latter form (with #') is preferred when foo is a function, as it documents the fact that it is intended to be ...
23
votes
How to know when or when not to use the single quote before variable names?
A symbol which is in non-function position is treated as the name of a variable. In (function variable) function is in function-position (after the opening parenthesis) and variable is not. Unless ...
22
votes
Accepted
Why does a constant in `let` change with repeated calls?
Here is my answer to the identical question, appropriately edited:
The Bad
foo is self-modifying code. This is extremely dangerous. While the variable lst disappears at the end of the let form, its ...
20
votes
How to evaluate the variables before adding them to a list?
Do not quote the cons cell, because quoted expressions are not evaluated. That's exactly why one quotes - to prevent evaluation. But that's not what you want, so don't.
Instead use the form that ...
14
votes
Accepted
When should sharp quotes be used?
#' is just shorthand for function, just as ' is shorthand for quote.
You can use it anywhere where you want to indicate to the byte-compiler or the interpreter or a human reader that its argument is ...
11
votes
Accepted
Does a list contain this symbol?
Short version: remove the inner quote.
When you quote a list, it leaves the list's contents unevaluated:
'(a-symbol "a string" (+ 1 1)) => (a-symbol "a string" (+ 1 1))
So: if the list includes ...

Dan♦
- 31k
11
votes
Accepted
Error void-variable on function name
Short Answer
Replace func2 with #'func2:
(defun func2 (arg)
(if (listp arg)
(mapcar #'func2 arg)
arg))
Explanation
Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, ...
11
votes
When should sharp quotes be used?
#' (aka function) can be used in front of (lambda ...) but it's redundant there, so the only place where it's really meaningful is in front of a symbol, as in #'car. In ELisp, #'car and 'car are ...
11
votes
Accepted
Cannot use concat within org-capture template
Okay, figured it out! Because the template was quoted '(("j"... the concat expression was not being evaluated. What I needed to do was use backquote and then insert a , before the concat statement to ...
9
votes
Accepted
Don't pair quotes in electric-pair-mode
Add the following to your emacs init file:
(setq electric-pair-inhibit-predicate
(lambda (c)
(if (char-equal c ?\") t (electric-pair-default-inhibit c))))
Reference from my blog post: ...
9
votes
How to jump to matching (double or single) quote of a quoted string?
M-C-f (or M-C-right) bound to forward-sexp should do that.
I suggest you try all well-known motion commands with the prefix M-C- instead of C-.
M-C-b (or M-C-left) gives backward-sexp
M-C-u (or M-C-...
8
votes
Accepted
Can I eval a value in quote?
You have two options:
1) Don't use quotes at all, as in:
(list some-var "some-string")
2) Use a backquote. They work like quotes, but part of an expression can be evaluated by using , and ,@. For ...
6
votes
how to style block quotes in org-mode LaTeX export?
Interesting question. I put together this start based on this part of the manual. How you set this up will depend on how you want to use it. Based on my experiments, it seems easier to define a new ...
6
votes
Accepted
Can I tell prin1-to-string to use reader-macros?
Just bind print-quoted to a non-nil value around the call to prin1(-to-string).
6
votes
Invalid read syntax "#"
;; Broken. Which is weird, since it came straight from the *Help* for go-mode
This almost definitely indicates another case of the recently-introduced (25.1) text-quoting-style default behaviour ...
5
votes
Accepted
how to correctly pass around function as parameters?
Don't quote buffer-assassin when passing it to ninrod--protection. In your advice-functions, buffer-assassin is a variable, the value of which is the originial function. When you pass it quoted, ...
5
votes
Accepted
Proper reinitialization of a list? What is happening under the hood?
Maybe this will clear up some of the confusion:
Your function initilize does not initialize variable example. It sets it to a particular cons cell - the same cons cell each time it is called. The ...
5
votes
Proper reinitialization of a list? What is happening under the hood?
You can use (setq example (list 3)) to avoid this error.
What happens is init assigns an object that initially contains (3) to example.
It sets the value of the object only once. Subsequently, you ...
5
votes
Accepted
tell org to treat block quotes as a special environment?
After reading the comments, it appears you're really looking for this:
org-narrow-to-block to narrow the buffer to the current block
Place cursor within the boundary of a block, e.g. quote block
...
5
votes
Accepted
Order of evaluation of nested macros and backquotes
Comma and backquote are transformed by the reader into regular function calls with the following sexp as argument.
(read "`(list ,fill-column `(list ,fill-column))")
;; => (\` (list (\, fill-...
5
votes
Accepted
Hook with quoted lambda as an argument
(add-hook 'coffee-mode-hook '(lambda () (coffee-custom)))
Definitely not recommended.
Quoting lambdas like that is not good practice.
As you say, (add-hook 'coffee-mode-hook #'coffee-custom) would ...
5
votes
Accepted
How can I insert the backslash character ( \ ) before quotation marks (" ") in Emacs?
This is a feature of paredit. If you look at the minibuffer (the line at the bottom of your Emacs window) when you press \, you'll see you're being prompted for "Character to escape:". The ...
4
votes
Accepted
Variable not parsed inside other variable definition
The quote (') causes the following expression to be not evaluated, therefore blog-username and blog-password are not evaluated to their string values, but instead taken as symbols.
One way of getting ...
4
votes
Accepted
Why does one argument need to be quoted but not the other?
I don't see an issue. Just macroexpand your stuff and you'll see the obvious errors:
(add-annoying-arrows-advice
next-line
'(ace-jump-mode)
evil-next-visual-line
'(evil-search-backward))
;; =>
...
4
votes
Accepted
Invalid read syntax "#"
Use a straight quote ('), not a typographically correct one (’). This goes for programming in general, nearly all languages out there stick to the ASCII character set. Emacs helpfully displays the ...
3
votes
Accepted
How to tell emacs to separate paragaph by an empty line in quotes
If I understood correctly, you are looking for the command message-fill-yanked-message, which is bound to C-c C-q in message-mode by default. See the Message Manual node on Insertion for a brief ...
3
votes
Accepted
How to print a quoted sexp using '... (reader syntax) instead of using (quote ...)?
C-h v print-quoted:
print-quoted is a variable defined in C source code.
Its value is nil
Documentation:
Non-nil means print quoted forms with reader syntax.
I.e., (quote foo) ...
3
votes
Accepted
Pass function symbol as argument via function or single quote?
'foo and (quote foo) are identical: they prevent evaluation of foo.
#'foo and (function foo) are also identical: they extract the function binding of foo, including at compile time, which means that ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
quote × 78backquote × 13
functions × 10
org-mode × 9
elisp × 8
variables × 6
list × 6
regular-expressions × 4
eval × 4
key-bindings × 3
debugging × 3
font-lock × 3
symbols × 3
org-babel × 2
hooks × 2
customize × 2
minor-mode × 2
elisp-macros × 2
print × 2
mutability × 2
org-export × 1
latex × 1
shell × 1
faces × 1
fonts × 1