Questions tagged [backquote]
The backquote tag has no usage guidance.
35
questions
0
votes
1
answer
27
views
My Org mode capture code returns "Invalid file location: nil"
I use the following code for the org mode capture functionality, but it returns the error "Invalid file location: nil". What is wrong? Thanks in advance for any help!
(setq org-capture-...
0
votes
1
answer
28
views
How to use a variable for an output :file path for call-process
I'm using call-process in an emacs/lisp file (in Spacemacs) to run an external command and write its output to a file. It works when I hard code the path like this:
(call-process "/bin/ls" ...
3
votes
1
answer
29
views
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 `(("...
1
vote
1
answer
29
views
How to pass a variable to a click handler?
I'm using this code to make clickable text in a buffer:
(defun q()
"Entry point."
(interactive)
(let ((buffer-name "q"))
(get-buffer-create buffer-name)
(switch-to-...
1
vote
1
answer
36
views
function accepts string literal, but not the result of expression
In my init.el I have a series of programming language specific hooks that I use to add font-lock patterns (namely adding a header style font to some of my comments). Here is an example for c-like ...
1
vote
1
answer
35
views
Why is :box on set-face-attribute not getting the current value from (face-background)?
Why is :box not getting the current background color?. It doesn't even work if I setq a variable with the color hardcoded, but if I set the hex color as a literal it works perfectly. If I evaluate ...
2
votes
1
answer
41
views
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 ...
0
votes
1
answer
25
views
Function argument does not seem to be visible inside of function
I use this code (found here) to highlight a single line in black:
(defun find-overlays-specifying (prop pos)
(let ((overlays (overlays-at pos))
found)
(while overlays
(let ((...
0
votes
1
answer
86
views
Cons interpolation
I want to be able to write a cons with some of the cells being placeholders for later evaluation. I know I can use backquote constructs, but it tries to evaluate the cons immediately.
To clarify, ...
1
vote
0
answers
19
views
Passing string as arg to apply function [duplicate]
I want to call clone-indirect-buffer or clone-indirect-buffer-other-window within a function dependent on the prefix. To do this, I assign the appropriate clone function to a variable using let. ...
0
votes
2
answers
49
views
How to properly use defcustom with backquote / comma grammar? (to edit a mode's font-lock-keywords)
I'm trying to edit a mode's font-lock-keywords variable to use defcustom instead of defconst (which it was using previously). Obviously, this is because I want to be able to easily customize the mode'...
0
votes
0
answers
33
views
What's the difference between ' (quote) and ` (grave accent) [duplicate]
I've seen both used to quote symbols and list.
What's the difference between them?
When should I use one or the other?
3
votes
1
answer
236
views
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 (`...
0
votes
1
answer
217
views
string-join list with function as list member
I want to string-join a list of strings, one of which is returned by a function call.
Like this:
(defun foobar () "foobar")
(string-join '("foo" (foobar) "bar") "|&...
1
vote
0
answers
22
views
Include an element in a backquoted list only if it is non-nil
This is the "am I missing something obvious?" kind of question.
I would like to use backquotes in some way to make a value appear in a list only if it's not nil. So, for instance, given x, ...
2
votes
1
answer
72
views
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
...
2
votes
1
answer
248
views
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" (...
2
votes
1
answer
230
views
Concat in Org Easy Templates [duplicate]
I have a variety of org easy templates. I have a new file template which includes a #+DATE header that I'd like to populate with the current date [at the time the template is called].
The ...
0
votes
1
answer
79
views
org-capture evaluate each time without currying
Recently my org-mode config broke. And i started using ` and , to get it to work again. But now i have the issue that a function call (dl/capture-report-date-file) gets evaluated once and curries the ...
0
votes
1
answer
49
views
cons a symbol with a variable and return as a symbol [duplicate]
How can I make fun2 return as the same as fun1?
(defun fun1 ()
'((hello . "test"))) ; <= returns ((hello . "test"))
(defun fun2 (str)
'((hello . str))) ; <= this is wrong! should return ((...
1
vote
1
answer
191
views
Unconsumed commas in double-backquoted lists
I'm writing a macro which calls a helper function. I need to return a list like this:
`(s -- (cons 'commentary s))
I have tried many combinations, but I can't seem to get what I need without an ...
1
vote
1
answer
80
views
What is missing to show the desktop-dirname in the frame title? [duplicate]
I tried to get the value of desktop-dirname into the title of a frame:
(setq frame-title-format '("%b Desktop: "
(car (last (split-string desktop-dirname "/" t)))))
The (...
0
votes
0
answers
41
views
elisp - construct a quasi-alist from variable [duplicate]
To construct a quasi-alist, case 1 is using hardcode string; case 2 is using a variable filename to replace the hadcode string. but case 2 doesn't work as expected (should the same as case 1).
#+...
0
votes
1
answer
63
views
prin1 abbreviates form with "..." despite expression-print-level?
I have the following function to produce a form that can be "printed" to a ~/.gnus file to configure gnus to use a certain stmp and imap server for an account:
(defun gnus-imap-smtp-form (email smtp-...
0
votes
1
answer
176
views
Problems with setting the default font
I'm trying to set the default font for my Emacs based on a variable (so I can use a different font on a different machine):
(setq fontspec (concat ck-font-name "-" (number-to-string ck-font-size)))
(...
0
votes
0
answers
108
views
alist error when value created using (concat string1 string2) [duplicate]
I'm really confused with what's happening here.
In my config for backups I've the line (setq backup-directory-alist '(("" . "~/.emacs.d/backup/per-save"))) and I've a defined a variable in my init....
2
votes
1
answer
212
views
How to use ,var-name (defvar) syntax in org-publish-project-alist? Init file is in form of org-mode
I have following function as part of my emacs configuration.org settings for publishing org to html.
(defvar website-html-preamble
"<nav>
<ul class="nav nav-tabs">
<li role="...
4
votes
2
answers
443
views
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 ...
5
votes
1
answer
1k
views
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 ...
5
votes
1
answer
365
views
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 ...
1
vote
1
answer
1k
views
Can I eval a value in quote? [duplicate]
I have a variable say some-var, its value is a string. I want to use its value in a quote expression.
'(some-var "some string")
The function who is using the above expression reports error because ...
1
vote
1
answer
79
views
Are there implicit evaluation rules for backquoted structures?
I was constructing a macro that nested another macro and I ran into something that confused me. If the backquoted macro was the last form in the defmacro it evaluated as expected. If added an ...
5
votes
2
answers
1k
views
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 ...
21
votes
2
answers
5k
views
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: (...
39
votes
2
answers
6k
views
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)
(...