Questions tagged [lambda]

6 questions
12
votes
2 answers

Is it possible to attach generated doc string to a lambda?

Emacs docs say that when doc string is put inside of lambda or defun it's “stored directly in the function object”. However, we can change docs of named functions like this: (put 'my-function-name 'function-documentation "Blah.") But the same trick…
Mark Karpov
  • 4,893
  • 1
  • 24
  • 53
2
votes
2 answers

Lexical capture/access local scope in function, the same way as lambda

I'd like to use a function reference in place of a lambda, however the lambda in question captures a lot of locally scoped vars declared in an enclosing let. For example: (let ((x 1)(y 2)(z 3) (l '(1 2 3 4 5 6 7 8 9))) (mapcar (lambda (i)…
ocodo
  • 1,202
  • 11
  • 20
1
vote
1 answer

How do I call a function within a lambda?

I would like to define a function that generates lambdas, as such: (defun my-func (FUNCTION) (lambda () (FUNCTION))) But when I evaluate the following (defun my-func1 () (message "Hello World")) (funcall (my-func #'my-func1)) I am…
Tian
  • 288
  • 1
  • 8
0
votes
1 answer

How to call a interactive function with prompt from a lambda?

I have this little LaTeX helper function: (defun my--insert-chord (chord) "Prompt for a CHORD and insert it at point. TODO: make it agnostic to the package used." (interactive "MChord: ") (insert (concat "\\[" chord "]"))) that works like a…
0
votes
1 answer

How to disassemble an lambda/anonymous function given its hex adress but not name?

Assume that we have: (defalias 'my-f (lambda () (message "a"))) (byte-compile 'my-f) => #f(compiled-function () #) (setq my-g (byte-compile (lambda () (message "b")))) => #f(compiled-function () …
Daanturo
  • 180
  • 8
0
votes
1 answer

bind-keys with a macro for lambda functions

I am trying to bind keys to a lambda function using bind-key.el. I have the following factor macro ;; taken from Emacs Doom (defmacro cmd! (&rest body) (declare (doc-string 1) (pure t) (side-effect-free t)) `(lambda (&rest _) (interactive)…
Tohiko
  • 1,589
  • 1
  • 10
  • 22