From 30ee26a9592a7784acccbc8a86e3060d5f1eca78 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 20 Oct 2008 23:14:36 +0000 Subject: [PATCH] (apply-partially): Move from subr.el to simple.el. --- lisp/ChangeLog | 6 ++++++ lisp/simple.el | 14 +++++++++++++- lisp/subr.el | 15 --------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index da6ed5796a9..d378478ce7e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2008-10-20 Eli Zaretskii + + * subr.el (apply-partially): Move from here... + + * simple.el (apply-partially): ...to here. + 2008-10-20 Andreas Schwab * subr.el (split-string-and-unquote): Simplify regexp. diff --git a/lisp/simple.el b/lisp/simple.el index 9636f118932..7327a88c362 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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 @@ objects of file handler invocation." (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 @@ works by saving the value of `buffer-invisibility-spec' and setting it to nil." 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) diff --git a/lisp/subr.el b/lisp/subr.el index a0077794b51..40311c4e1f4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3556,20 +3556,5 @@ is greater than \"1pre\" which is greater than \"1beta\" which is greater than \"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 -- 2.39.5