Mercurial > emacs
changeset 98949:46d6efaefafc
(apply-partially): Move from subr.el to simple.el.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Mon, 20 Oct 2008 23:12:43 +0000 |
parents | 4db83db4783a |
children | d6f6dbaf9d02 |
files | lisp/simple.el lisp/subr.el |
diffstat | 2 files changed, 13 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/simple.el Mon Oct 20 19:54:28 2008 +0000 +++ b/lisp/simple.el Mon Oct 20 23:12:43 2008 +0000 @@ -29,6 +29,9 @@ ;;; Code: +;; This is for lexical-let in apply-partially. +(eval-when-compile (require 'cl)) + (declare-function widget-convert "wid-edit" (type &rest args)) (declare-function shell-mode "shell" ()) @@ -2478,7 +2481,6 @@ (if fh (apply fh 'start-file-process name buffer program program-args) (apply 'start-process name buffer program program-args)))) - (defvar universal-argument-map (let ((map (make-sparse-keymap))) @@ -6247,6 +6249,16 @@ buffer-invisibility-spec) (setq buffer-invisibility-spec nil))) +;; Partial application of functions (similar to "currying"). +(defun 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 FUN, except that +the first N arguments are fixed at the values with which this function +was called." + (lexical-let ((fun fun) (args1 args)) + (lambda (&rest args2) (apply fun (append args1 args2))))) + ;; Minibuffer prompt stuff. ;(defun minibuffer-prompt-modification (start end)
--- a/lisp/subr.el Mon Oct 20 19:54:28 2008 +0000 +++ b/lisp/subr.el Mon Oct 20 23:12:43 2008 +0000 @@ -3556,20 +3556,5 @@ \"1alpha\"." (version-list-= (version-to-list v1) (version-to-list v2))) - -;; This is for lexical-let in apply-partially. It is here because cl -;; needs various macros defined above. -(eval-when-compile (require 'cl)) - -(defun 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 FUN, except that -the first N arguments are fixed at the values with which this function -was called." - (lexical-let ((fun fun) (args1 args)) - (lambda (&rest args2) (apply fun (append args1 args2))))) - - ;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc ;;; subr.el ends here