Hot answers tagged


apply-partially was most useful back when Emacs did not have lexical binding, since it let you build "closures". But for your example, you don't even need a closure: (defalias 'fix-a-c-in-foo (lambda (b) (foo "a_value" b "c_value"))) for a more general case, OTOH you do need closures, so you'll want to add -*- lexical-binding:t -*- to the first line of ...


You are looking for the function apply. Use it as follows: (setq some-var '("-l" "-a" "-t" "-r")) (apply #'start-process "ls" "*temp*" "ls" some-var)


(advice-add #'undo-tree :filter-return #'undo-tree-advice-history-save-file-name) This advises the function undo-tree, whereas the defadvice form advises undo-tree-make-history-save-file-name. The equivalent advice-add would be (advice-add 'undo-tree-make-history-save-file-name :filter-return #'undo-tree-advice-history-save-file-name)


You have everything you need in the emacs-lisp core language with fset, lambda expressions and backticks. The following source code is an extension of your second example. The comma expression allows you to easily substitute something in a back-tick quoted lambda expression and you can assign that expression to a symbol's function-cell with fset. (defun foo ...


You need to apply the function to the list of arguments: (f-write-bytes (apply 'unibyte-string random-data) "file.dat") (apply '+ '(1 2 3)) is equivalent to (+ 1 2 3). See the section about calling functions in the elisp manual for more details.


Something like this, the new function to learn is apply: (defun get-quotes (x &rest y) (cons x y)) (let ((articles '("/home/matt/art/mice.pdf" ("/home/matt/art/cats.pdf" "Smith, \"Neural Pathways in Cat Brains\"" 3)))) (dolist (thisarticle articles) (if (stringp thisarticle) (get-quotes thisarticle) ...


This is because and is not a function (it is a special form). Note that C-h f and tells you "and is a special form in `C source code'." apply must be used with a function. The manual says: ‘apply’ returns the result of calling FUNCTION. As with ‘funcall’, FUNCTION must either be a Lisp function or a primitive function; special forms and macros do not ...


I figured it out. As noted in my comment above, my code: (defun add2 (apply-partially 'add-numbers 2)) can't work because defun is a special form and (apply-partially 'add-numbers 2) is seen as the argument list to the special form, i.e. apply-partially never gets evaluated. This leaves us with the challenge of saving the call (apply-partially 'add-...

Only top voted, non community-wiki answers of a minimum length are eligible