Hot answers tagged

30

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 evaluate its argument. According to the docstring: (quote ARG) Return the argument, without evaluating it. (quote x) yields x. Warning: quote does ...


24

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 at anything that can be bound, including functions. It only cares whether there is a symbol that matches, not what the value is. bound-and-truep uses var and ...


21

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 initial value persists in the function object, and that is the value you are modifying. Remember that in Lisp a function is a first class object, which can be ...


21

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 funcalled. Your two forms are therefore completely equivalent, and the one with #' is preferred. Edit: as pointed out by Malabarba, this is not quite true: #' on ...


19

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 creates a cons cell from two evaluated values, its arguments. (cons x y) Of course you can also quasiquote but that doesn't really make sense here, and looks ...


17

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 explicitly quoted variables are replaced with their values. If you were to write (boundp my-variable) that would mean "is the symbol which is stored in the value ...


11

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 symbols, a quoted list will return a list of symbols. Here's the rub: because quoting is so common, there's a special reader syntax for it: '. So: 'kittens ...


11

#' 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 expected to be (is treated as) a function. In many contexts the context determines how the argument is treated if, for example, you simply quote it (use quote ...


9

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-up) gives backward-up-list M-C-n (or M-C-down) gives forward-list


9

#' (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 almost completely equivalent, so one of the main purpose is simply to document the intention (i.e. to indicate to whoever reads this code that you intend to use ...


8

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 example: `(,some-var "some-string")


7

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, Scheme). I.e., every symbol in ELisp has a "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "...


6

Just bind print-quoted to a non-nil value around the call to prin1(-to-string).


6

;; 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 screwing things up for people in hard-to-notice ways :( I recommend two things: Submit a bug report for go-mode. The docstring in question will need to use the ...


5

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, buffer-assassin in ninrod--protection will have the value 'buffer-assassin (i.e. the symbol itself), so apply will try calling a (global) function named like that, ...


5

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: https://www.topbug.net/blog/2016/09/29/emacs-disable-certain-pairs-for-electric-pair-mode/


5

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 first time initilize is called, the setq assigns example to a new cons cell, which is the result of evaluating '(3). Subsequent calls to initilize just reassign ...


5

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 modify this value. Here's your example in C++, if you understand that better: #include <stdio.h> #include <string.h> char* example; char* storage = ...


5

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-column) (\` (list (\, fill-column))))) You can look-up the backquote macro's help. Comma is actually not a macro, but like a marker for backquote, i.e. it's ...


5

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 allow this part to evaluate: (setq org-capture-templates `(("j" "Journal" entry (file+datetree "~/org/journal.org") ,(concat "* " (format-time-string ...


5

(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 be better (for many reasons). In coffee-mode.el you can see similar hook call "... Add `'(lambda () (coffee-cos-mode t))' to `coffee-mode-hook' This one at ...


4

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 around this is using the list function to explicitly quote symbols when necessary (note that the colon automatically quotes keywords): (setq org2blog/wp-...


4

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)) ;; => (progn (add-to-list (quote annoying-commands) (quote next-line)) (put (quote next-line) (quote aa--alts) (...


4

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 #+BEGIN_VERSE Verse Block #+END_VERSE #+BEGIN_VERBATIM Verbatim Block #+END_VERBATIM #+BEGIN_QUOTE Quote Block #+END_QUOTE Type C-x n b The buffer will ...


4

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 quotes in the typographically correct way, this breaks copy-pasting them into your own code.


3

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 description of this command, including a caveat. In fact, message-mode is so powerful and flexible that I recommend reading its whole manual, which is relatively ...


3

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) prints as 'foo, (function foo) as #'foo.


3

It appears you cannot. The various customizations only allow you to add pairs. If you're willing to use a different package to do your pairing, you can try smartparens. You can set quotation marks to not pair as follows: (sp-pair "'" nil :actions :rem) (sp-pair "\"" nil :actions :rem)


3

'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 the function gets compiled. So, if you want a symbol, use 'foo: (make-variable-buffer-local 'my-local-var) if you want a function, use #'foo: (setq my-after-...


3

It's not clear what you're attempting to do with your command. However, the error message you're getting is due to the fact that you have a quoted symbol ('origami-open-node) where elisp is expecting an unquoted symbol. Here's a rough way to think about how lisp understands what you want it to do: (verb noun noun noun noun...) The first element of the ...


Only top voted, non community-wiki answers of a minimum length are eligible