Questions tagged [funcall]

18 questions
4
votes
2 answers

Call function without calling advice defined on it

I sometimes want to bypass the advice I have defined on some function. Something like: (call-without-advice #'fn ...)
HappyFace
  • 751
  • 4
  • 16
4
votes
2 answers

Calling a function with a shorter but unknown argument signature length

Is there a terse idiomatic way of calling a function in the manner of funcall (dereferencing function symbols) when that function may have a variably shorter function signature? Say for example: a hook assumes a signature of (VALUE PARENT), but for…
ebpa
  • 7,319
  • 26
  • 53
3
votes
1 answer

Inconsistent behavior when calling #'funcall with a macro

I would have thought that both of the funcall's the follow would have yielded the same result, but they don't and I'm trying to understand why. (defmacro test/z () "z") (funcall (function test/z)) ;; => "z" (funcall (eval `(function ,(intern…
theia-jane
  • 80
  • 7
3
votes
1 answer

Difference between apply and funcall

(describe-function apply) says: apply is a built-in function in ‘src/eval.c’. …
Realraptor
  • 1,253
  • 6
  • 17
2
votes
2 answers

Call apply with a macro

Is there a way to expand a macro using a list of arguments? I tried using apply but then I get an error that the "function" my/x-becomes-nil is invalid. (defmacro my/x-becomes-nil (variable x) `(if (eq ,variable ,x) (setq ,variable…
Tohiko
  • 1,589
  • 1
  • 10
  • 22
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
1
vote
1 answer

How to call a function that is the value of a variable?

Can someone explain to me why the code below throws an error (void-function fn)? (let ((lexical-binding t) (fn (lambda (y) (+ y 4))) (x 4)) (pcase x (10 (- x 2)) (4 (fn x)))) and is there a way to fix it without defun'ing a…
Tohiko
  • 1,589
  • 1
  • 10
  • 22
1
vote
2 answers

Function within a function produces side-effect but failes to deliver logic test

This is a simple logic test that makes use of down-list and asks if another nested pair of parenthesis exits or not. (not (eql (point) (progn (ignore-errors (down-list)) (point)))) A weird thing occurred when this is…
Sati
  • 775
  • 6
  • 21
1
vote
1 answer

Why funcall doesn't work from a closure

I'm having difficulty to call a function passed as an argument. Why the following snippet doesn't work, and how can I make it work? lexical-binding is set to t (defun on-success (data) (print "This works!") (print data)) (defun send-req (url…
iLemming
  • 1,223
  • 9
  • 14
1
vote
1 answer

Evaluate allows for combinations whose operators are compound expressions

I find the amazing power of scheme in sicp Exercise 1.4. Observe that our model of evaluation allows for combinations whose operators are compound expressions. Use this observation to describe the behavior of the following procedure: …
AbstProcDo
  • 1,231
  • 5
  • 15
1
vote
2 answers

I want to simplify repeated calls in my init.el file

I've got a lot of: (desktop-save-mode 1) (show-paren-mode 1) which I'd like to collapse into: (mapcar (lambda (fn) (fn 1)) '(desktop-save-mode show-paren-mode)) but I get an error: Symbol’s function definition is void: fn How can I call a list of…
ftravers
  • 105
  • 3
1
vote
1 answer

function that takes a function as argument and returns a new function

I'd like to write an elisp-function that has a function as argument and returns a new function. Let's say the new function double-the-function should write the returned value of the argument-function twice. (The argument function operates on a…
rl1
  • 346
  • 1
  • 16
0
votes
3 answers

Is there a code example demonstrating a meaningful usage of the built-in function `funcall`?

In order to understand what the symbol funcall means I have checked out its documentation. If I understand it right after reading the docs this symbol represents a function which in my eyes can be always easily removed from the elisp expression…
Claudio
  • 410
  • 2
  • 11
0
votes
1 answer

Setting of face using funcall

I am using funcall to set a typeface by calling a function select-typeface. I would like to remove select-typeface, calling (face (funcall level-typeface depth match). Cannot simply do (let ( (face (funcall level-typeface depth match)) ) in…
Dilna
  • 1,173
  • 3
  • 10
0
votes
3 answers

Problems using a function reference from a plist

I'm trying to (funcall) a function reference I have in a plist. (defun helper-get-filename () "Argument Helper to get a filename." (read-file-name "-l : " "~/")) (let ((plist '(:flag "-l" :arg-helper #'helper-get-filename))) …
ocodo
  • 1,202
  • 11
  • 20
1
2