bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23736: Add companion to apply-partially


From: Rasmus
Subject: bug#23736: Add companion to apply-partially
Date: Thu, 09 Jun 2016 16:01:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Hi,

Could we add an ‘apply-rpartially’ or ‘apply-partially-last’ to subr.el?
Like ‘apply-partially’, but fixing the last arguments.  This is useful for
e.g. ‘set-face-attribute’ where one might a common :inherits to many
faces, e.g.

    (mapc (apply-rpartially ’set-face-attribute :inherit ’fixed-pitch) ’(list 
of faces))

I have used this in my init.el,

    (defun apply-rpartially (fun &rest args)
      "Return a function that is a partial application of FUN to ARGS.
    ARGS is a list of the last N arguments to pass to FUN.  The
    result is a new function which does the same as FUN, except that
    the last N arguments are fixed at the values with which this
    function was called."
      (lambda (&rest args1)
        (apply fun (append args1 args))))

If that’s good I can prepare a patch that also has documentation.  (I
couldn’t find past discussions about such a function)

Rasmus

-- 
Don't slow down Johnny, leave the Cadillac runnin'






reply via email to

[Prev in Thread] Current Thread [Next in Thread]