34

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 ...


27

The comma is used in the context of a backquoted (a.k.a. quasiquoted) list, which allows you to evaluate some portions of the list selectively. See also this thread for an example of a use for backquoting. A couple of simple examples: (setq a "a's value" b "b's value" c "c's value") '(a b c) ; => (a b c) `(,a b ,c) ...


20

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 ...


11

That's because it's inside a macro. A macro needs to return a Lisp form, which then in turn gets evaluated. For example, looking at the first invocation of this macro: (add-annoying-arrows-advice previous-line '(ace-jump-mode backward-paragraph isearch-backward ido-imenu smart-up)) We need the expansion to contain: (put 'previous-line 'aa-alts '(ace-...


10

Ask Emacs. C-h i, choose the Elisp manual. i backquote You'll get to node Backquote, where you'll find a complete explanation of how backquotes are used in Emacs Lisp. The first paragraph provides a summary description: "Backquote constructs" allow you to quote a list, but selectively evaluate elements of that list. In the simplest case, it is ...


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

The short answer is that this is expected behaviour. You seem to be expecting foo-,arg to be something like (intern (concat "foo-" (symbol-name ',arg))), but there's no reason why that should be the case. For starters ,arg evaluates arg to whatever arbitrary lisp object it has as its value, so there mightn't even be a sensible way to form the end of a ...


5

The value returned by the sexp (read "`foo") is `foo. You are confused by the form of the printing of the read value by the command you are using (eval-expression, bound to M-: by default). What it prints is a Lisp representation of the value. If you instead use pp-eval-expression then you see `foo, which is the (same) value printed for humans. (This is ...


5

It's not necessary to use a backquote inside another, that's the beauty of it. (defmacro m1 (a &optional b) (let ((z (gensym))) `(let ((,z (if (integerp ,b) (list ,a ,b) (list ,a)))) ,z))) But that isn't correct yet. The purpose of z isn't to add another variable for the fun of it, but to protect b from ...


4

LISP is simple business: function calls receive their arguments evaluated, their result is used verbatim macro calls receive their arguments un-evaluated, their result is used evaluated Other than that, you can almost look at macros as functions. In your case, since the arguments are strings, they're the same whether evaluated or not, so the difference ...


3

Use font-lock-add-keywords for to add extra fontification. See the documentation of font-lock-keywords. You especially need the OVERRIDE flag to override the normal fontification of the comment. Use a function as MATCHER. That function should search for the next comment or make sure that you are in one. Afterwards it should search for your literals. The ...


3

There are several things wrong with the code: You need #', (or just ',) in front of func. Inside a backquote expression, just func would result in the literal symbol func, not its value as a variable. Use comma (, to evaluate it. But then quote that evaluated result. You need to use kbd, or else you are trying to bind the key sequence C-x SPC k. You need ...


3

Nested backquotes require more commas. (defmacro m (a &optional b) ; line 4 (let ((z (gensym))) `(let* ((,z ,b)) (if (integerp ,z) `((,,a ,,z)) `((,,a))))))


2

Ok, I just found out about backquoting: (add-to-list 'default-frame-alist `(font . ,fontspec)) This quotes the (font . part and evaluates the fontspec. Nice!


2

You need to use a back quote if you want the variables with commas to be replaced. See here. But that's not where the error is coming from. You don't appear to have escaped the quote characters inside your preamble string. Reference


2

(defun fun2 (str) `((hello . ,str))) See the backquote section of the Emacs manual: https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html


2

As @Drew mentioned in the comments, you can accomplish this, almost, with quasi-quoting. The syntax is a little confusing. The variable org-structure-template-alist is initialized as an alist: '(("s" "#+BEGIN_SRC ?\n\n#+END_SRC") ("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE") ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE") ... ) You want to insert an element ...


1

It looks to me like you misunderstand the logic of the backquote. Even though it allows evaluation of code (instead of simply using the quoted value), it is still evaluated at runtime. That is, defcustom does receive a value in the same sense that a quoted list produces a value. Which is why if you look at the stored customizations in your custom.el file, ...


1

It's not clear (to me) what you want. The closest you seem to come to it is this, which is also not very clear: "I just want it to keep using the backquote instead. Or somehow dynamically embed the variable reference there. But I don't see a way to do this." Can you specify what you want as the value of the option, and how you want to be able to ...


1

A quoted list doesn't evaluate its args, so it consists of a string, a list containing a symbol and another string. You can selectively evaluate it using backquote and unquote: `("foo" ,(foobar) "bar") ;=> ("foo" "foobar" "bar") (string-join `("foo" ,(foobar) "bar") "|") ;=>...


1

This may get you there. (Do you really want/need a \ before each colon (:)?) (defun foo () "..." (font-lock-add-keywords nil (mapcar 'bar tags))) (defun bar (pat.fac) "..." (let ((pat (format "\\(%s\\)" (car pat.fac))) (fac (cdr pat.fac))) (when (eq fac 'tag-key) (setq fac '(tag-key (match-string 0)))) ...


1

According to (info "(org) Template elements"), when setting capture target, instead of supplying a filename, you can also use a function: (function function-finding-location) Most general way: write your own function which both visits the file and moves point to the right location. You can take a look at the following as an example, it picks a ...


1

You can use a few different approaches, but for your specific case maybe my favorite would be: (let ((rule-name 'commentary)) `(,'\` (s -- (cons ',rule-name s))))


1

You are passing a literal list as the second arg to setq. Instead, you want to substitute the value of the (car...) sexp. You can do that using a backquote construction, telling it to evaluate that (car...) sexp and use the result of the evaluation. You want this: (setq frame-title-format `("%b Desktop: " ,(car (last (split-...


1

Using setf instead of a let binding to set the value of print-level and print-depth worked, though I'm not sure I understand why: (progn (setf print-level 2 print-length 2) (pp `(deeply (nested (form (very (deeply (nested)))))))) (deeply (nested ...)) "(deeply\n (nested ...))\n" Setting to nil: (progn (setf print-level nil ...


1

Not that I'm advocating something like this... (defmacro with-intern-concat (&rest body) (declare (indent 0) (debug t)) (cons 'progn (intern-concat-map body))) (defun intern-concat-map (body) (with-temp-buffer (intern-concat-map-qq-symbols body (lambda (symbol) (erase-buffer) (save-excursion (insert (symbol-name symbol)))...


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