Questions tagged [apply]

15 questions
4
votes
2 answers

apply partially last arg

Is there something like apply-partially (apply-partially FUN &rest ARGS) Return a function that is a partial application of FUN to ARGS. ARGS is a list of the first N arguments to pass to FUN. The result is a new function which does the same as…
JAre
  • 175
  • 5
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
3
votes
1 answer

Rewriting `defadvice' as `advice-add' makes advice ineffective

I am trying to make undo-tree auto compress the history save file. The document suggests adding the following advice (defadvice undo-tree-make-history-save-file-name (after undo-tree activate) (setq ad-return-value (concat ad-return-value…
nalzok
  • 665
  • 6
  • 18
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
2
votes
1 answer

Why can't I directly invoke the result of apply-partially?

I'm confused about return value of apply-partially. Documentation states that it returns a function, and source of the function shows that it actually retruns a lambda. But I can't invoke the return value directly, only via funcall. Creating lambda…
Rogach
  • 267
  • 1
  • 5
2
votes
1 answer

Writing bytes to a file using library f.el

I'm trying to do something very simple, write bytes to a file using the f library: (require 'f) And I create a list of bytes: (setq random-data (loop for i from 0 to 40 collect (random 150))) So far, so good. However, the unibyte-string function…
Dave F
  • 553
  • 2
  • 13
2
votes
1 answer

turn a list into a set of arguments for a function

I have a defun get-quotes with one mandatory and 2 optional arguments. I would like to do something like this: (let ((articles '("/home/matt/art/mice.pdf" '("/home/matt/art/cats.pdf" "Smith, "Neural Pathways in Cat Brains" 3))) (dolist…
Matt
  • 105
  • 5
1
vote
1 answer

How can I apply function `max` to a list of numbers?

I want to find the max element in a list of numbers. (setq l (list 1 2 3 4 5)) What is an easy way to call the max function on l? So far I have this but this seems convoluted: (eval `(max ,@l)) It seems like there should be an easier way. No?
jds
  • 177
  • 7
1
vote
1 answer

Use Elisp macro instead of two function arguments?

Is the following sort of shortcut macro possible to implement? (defmacro region-end-beg () "Replacement for '(region-end) (region-begin)' in source code" (...)) So that (buffer-substring (region-end-beg)) (setq region-length (-…
user26109
  • 11
  • 1
1
vote
1 answer

Return Value of apply-partially

I'm playing around with apply-partially and I'm confused about what gets returned when calling this function. The documentation states that apply-partially returns a function, but then I'd expect to be able to do the following: (defun add-numbers (a…
flooose
  • 511
  • 6
  • 14
0
votes
2 answers

How to step into (apply ..) function when using Edebug?

When using edebug, stepping into a function call works. But if I change the function call from (foo args) to (apply '#foo args) edebug says apply is built-in function and won't let me step into. I can find the definition of foo and "instrument" it…
eugene
  • 481
  • 1
  • 5
  • 11
0
votes
1 answer

funcall/apply lambda

Please look at the following elisp expressions. (funcall 'lambda '() 1) ;; or (apply 'lambda '() 1 ()) The interpreter says that lambda is not a valid function for both the above expressions. Why? Is it because lambda is a macro? If so, is there a…
nomad
  • 247
  • 1
  • 6
0
votes
1 answer

Source C code of function 'apply'

I referenced C-h f apply for the source code of "apply", it prompts References C code is not yet loaded. but does not hint the destination file. Execute grep-find within Emacs repo thus return no results. find . -type f -exec grep --color -nH…
AbstProcDo
  • 1,231
  • 5
  • 15
0
votes
1 answer

Apply of a logic function over a list

I'm trying to apply a logic function over a list, but: e.g.(apply 'and some_list) give me Invalid function: and. There is a way to apply a logical function to a list?
Francesco Cadei
  • 327
  • 3
  • 17
0
votes
1 answer

How can I use a var to provide multiple arguments to a function?

Here is a simple example in which I would like to replace (start-process "ls" "*temp*" "ls" "-l" "-a" "-t" "-r") ; this works with (setq some-var ????) ; <-- Need to figure this part out (start-process "ls" "*temp*" "ls" some-var) But I cannot…
Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179