Questions tagged [let-binding]
57 questions
13
votes
2 answers
Bind multiple values directly from list without binding the list itself
Is it possible to assign multiple return values directly to variables without going through a temporary variable in Emacs Lisp?
For example, let's say I have a function that returns a list of two lists:
(defun test-func ()
(setq a '(a b))
(setq…

Håkon Hægland
- 3,648
- 1
- 22
- 51
8
votes
2 answers
Is there any difference between '(let (var) ...)' and '(let ((var nil)) ...)'?
I've seen both (let (var) ...) and (let ((var nil)) ...) is there any difference between these statements?

ideasman42
- 8,786
- 1
- 32
- 114
3
votes
2 answers
Emacs Lisp: let with while
I am trying to search backwards and find [ but skip all square brackets within strings. I came across (nth 3 (syntax-ppss)); but I can't figure out how to use it with let in the following code:
(defun ext-ess-symbol-at-point-modified ()
"Return…

Arktik
- 972
- 4
- 17
2
votes
3 answers
How to let-bind multiple variables conditional on X?
Q: how can I let-bind multiple variables conditional on x?
Assume that I have three variables, a, b, and c, that I want
to let-bind conditional on some other x. How do I do that
concisely and idiomatically?
Here's an example that works, but is…

Dan
- 32,980
- 7
- 102
- 169
2
votes
1 answer
Why doesn't my keymap let-binding work?
I'm trying to define the keymap for a major mode but keep getting the error: Wrong type argument: keymapp.
What am I doing wrong?
(defun insert-text ()
(interactive)
(let ((x (read-string "Enter text to be printed: ")))
(insert…

Jacek
- 35
- 4
2
votes
1 answer
What is bds in Emacs speak?
I am trying to learn Elisp and just found this line that I don't understand, in a package that I use to send code from buffer to a terminal:
(let* ((region-active (region-active-p))
;; The region to be sent
(bds …

Amelio Vazquez-Reina
- 5,197
- 5
- 33
- 47
1
vote
1 answer
Using global variables inside functions using the `let` construct
Have the following code but want to use let in the function blink-cursor-timer-function. Have started doing the changes but do require some assistance with it. The variable names veak-indicator-point, veak-indicator-colour are long, and want to…

Dilna
- 1
- 3
- 11
1
vote
0 answers
Factoring code into a let block
I'm following the instruction here to set the default font:
(add-to-list 'default-frame-alist '(font . "Monospace 10"))
(set-face-attribute 'default t :font "Monospace 10")
This works. To avoid the repetition, I tried factoring the string out with…

Chris Martin
- 121
- 4
0
votes
1 answer
Moving position of variable in a let clause
I have the following code and wonder whether I can define the variable brace-stxcode in the let* part rather than I currently do (make a new let).
(let* ( (last-ppss-pos (point))
(ppss (syntax-ppss)) )
(while (> end (progn…

Dilna
- 1
- 3
- 11
0
votes
3 answers
lexically set referenced symbol of a symbol within let bind form
Is it possible to set a symbol that is the value of target symbol within the let bind form? because I am not setting a target symbol, I am not sure how to use let.
I am doing this because I am passing in a string that represents a library's name to…

Joann Morris
- 271
- 1
- 9
0
votes
1 answer
How to define a variable in a custom function?
I have a function for generating a new text file. The file is named automatically from date and time, following this format: yyyy-mm-dd--hh-mm-ss.txt.
However, I also need my function to insert the file name into the first line of the newly made…

myotis
- 1,119
- 1
- 13
- 31
0
votes
1 answer
Flagging or auto-correcting self-referential 'let' expressions
How do you catch the lisp programmer's error:
"I typed let, but I really meant let* and wasted five to ten seconds for the nth time today!"
I make this mistake all the time. Usually in a hurry or not anticipating the dependence of symbols I'm…

ebpa
- 7,449
- 29
- 55