Questions tagged [backquote]

41 questions
41
votes
2 answers

How to evaluate the variables before adding them to a list?

The below obviously doesn't work and hence this question. How do I correct the below code so that the value of somelist becomes '(("abc" . 123)) ? (setq x "abc") (setq y 123) (setq somelist nil) (add-to-list 'somelist '(x . y))
Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
25
votes
2 answers

What is the point of quote with single argument and comma? (quote ,arg)

(quote x) makes x not be evaluated, but adding a , in front of x within quote makes it evaluated. What is then the point of using quote with a single argument with a comma in front of it, like so: (quote ,x)? Motivated by line 59 from annoying…
The Unfun Cat
  • 2,393
  • 16
  • 32
5
votes
1 answer

Backward quote, what does it mean in elisp?

I was referring the source code of switch-to-buffer in elisp source code, window.el.gz. I am seeing some backward single quotes like, ` I know single quote is used to refer to symbols but what does backward single quote do? Source code is here. When…
Madhavan
  • 1,957
  • 12
  • 28
5
votes
1 answer

Is there any difference between \` and backquote?

I was surprised to find that if I use M-x ielm, I get a literal backquote: ELISP> (read "`foo") `foo However, if I use M-: (read "`foo") then *Messages* and the minibuffer show (\` foo). Are these two equivalent? Why doesn't (equal (read "`foo")…
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
5
votes
2 answers

defun vs defmacro and backquote vs list

While looking to exclude the uses of the list function through the backquote substitutes in defmacros, my attempt failed when combined with the let and `let* recipe, together with the gensym function (as a source of uninterned symbols, as…
sjb
  • 101
  • 7
4
votes
1 answer

“`(a \, b)” is equivalent to “`(a . ,b)”

I found this when playing at *ielm*: ELISP> `(emacs-version \, emacs-version) (emacs-version . "28.2") ELISP> `(emacs-version . ,emacs-version) (emacs-version . "28.2") ELISP> I have never heard of this usage of \,, is it a feature or bug? OP…
shynur
  • 4,065
  • 1
  • 3
  • 23
4
votes
2 answers

Elisp backquote comma eval puts a space in between

Here's an example: (defmacro test (arg) `(message foo-,arg)) (defmacro test-with-space (arg) `(message foo- ,arg)) (macroexpand-1 '(test-with-space bar)) (macroexpand-1 '(test bar)) Both eval to (message foo -bar). Intuitively to me it should…
Russ Kiselev
  • 464
  • 3
  • 10
3
votes
1 answer

Interpolating inside a nested backquote expression

Consider this macro helper function that returns a backquote expression: (defun make-headers () `(:headers `(("Authorization" . ,(get-auth))))) This returns the list (:headers `(("Authorization" . ,(get-auth)))), suitable for interpolating into a…
Sean
  • 929
  • 4
  • 13
3
votes
1 answer

How to highlight back-tick quoted strings in code-comments?

Since back-ticks are often used for literals, is there a way I can highlight these in code comments? So this: # This is a comment, this is a literal: `4 + 4`. # let's make things interesting (`literal_a`,`literal_b`). Can display like this:
ideasman42
  • 8,375
  • 1
  • 28
  • 105
3
votes
2 answers

How to evaluate a symbol in a lambda function when defining it?

For example, (lambda () (message "%s" x))) But I would like x to be evaluated -- the lambda function should always use that value, instead of the current value of x. How should I do it? Preferably lexical-binding is not required.
xuhdev
  • 1,839
  • 13
  • 26
2
votes
1 answer

Backquote List & Evaluate Vector or conversely

C-h f backquote: The whole structure acts as if it were quoted except for certain places where expressions are evaluated and inserted or spliced in. Vectors work just like lists. What does the 'spliced in' mean? ;; I expect for (1 2 3) `(1 ,@[2]…
shynur
  • 4,065
  • 1
  • 3
  • 23
2
votes
1 answer

Enable Lexical Binding by Binding “lexical-binding” to t

(Please see what is letrec first.) The following code is obviously fine and self-explanatory: ;; -*- lexical-binding: t; -*- (setq post-self-insert-hook `(,@(when (boundp 'post-self-insert-hook) …
shynur
  • 4,065
  • 1
  • 3
  • 23
2
votes
1 answer

Key binding to `C-<` and `C->` not working when creating minor mode

I wrote a couple of functions to automatically convert sequences like "<<" in «. (Yeah, I know that input methods can do the same, but I don't want the extra bindings: I'm planning to use a lot of apostrophes, and I don't want them to be joined). So…
2
votes
1 answer

Adding keywords programmatically using the display property

I've added some keywords using the following construct (where tag-todo and tag-note are variable holding a SVG image and tag-key () is a function returning a SVG image): (font-lock-add-keywords nil '(("\\(\:TODO\:\\)" 1 `(face nil display…
Nicolas Rougier
  • 487
  • 3
  • 15
2
votes
1 answer

eval and quotes

I am trying to execute the code here, which I copy below (defun buffer-local-set-key (key func) (interactive "KSet key on this buffer: \naCommand: ") (let ((name (format "%s-magic" (buffer-name)))) (eval …
Tohiko
  • 1,589
  • 1
  • 10
  • 22
1
2 3