Subject: bug#49316: Add apply-partially's right version

From: daanturo <[email-masked]>
Date: Thu, 1 Jul 2021 19:40:20 +0700

--=-=-=
Content-Type: text/plain

Tags: patch

Define apply-rpartial.

The equivalent function in dash.el is widely used by other packages so
it's beneficial to include it by default.

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.29, cairo version 1.17.4)
of 2021-06-25 built on c6
Repository revision: e288348c0a785537d95b7ef2fff0cda729a29677
Repository branch: makepkg
Windowing system distributor 'System Description: Arch Linux

Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
--with-sound=alsa --with-modules --without-gconf --without-gsettings
--with-native-compilation --with-pgtk --with-x-toolkit=gtk3
--without-xaw3d --without-m17n-flt --with-cairo --with-xwidgets
--without-compress-install 'CFLAGS=-march=x86-64 -mtune=generic -O2
-pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat
-Werror=format-security -fstack-clash-protection -fcf-protection -g
-fuse-ld=gold -g -fuse-ld=gold'
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

--=-=-=
Content-Type: text/patch
Content-Disposition: attachment; filename=0001-Define-apply-rpatially.patch

 From c594d6fc396b80019c48e63918f8c5e485f2782f Mon Sep 17 00:00:00 2001
From: Daanturo <[email-masked]>
Date: Thu, 1 Jul 2021 19:21:08 +0700
Subject: [PATCH] Define apply-rpatially

Which is analogous to `apply-partially` but arguments are aligned on the 
right
instead.
---
lisp/subr.el | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/lisp/subr.el b/lisp/subr.el
index e49c277335..5965655d48 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -465,6 +465,15 @@ was called."
(lambda (&rest args2)
(apply fun (append args args2))))

+(defun apply-rpartially (fun &rest args)
+ "Return a function that is a partial application of FUN to ARGS to the 
right.
+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))))
+
(defun zerop (number)
"Return t if NUMBER is zero."
;; Used to be in C, but it's pointless since (= 0 n) is faster anyway 
because
-- 
2.32.0

--=-=-=--

-- 
Daanturo.

>From c594d6fc396b80019c48e63918f8c5e485f2782f Mon Sep 17 00:00:00 2001
From: Daanturo <[email-masked]>
Date: Thu, 1 Jul 2021 19:21:08 +0700
Subject: [PATCH] Define apply-rpatially

Which is analogous to `apply-partially` but arguments are aligned on the right
instead.
---
 lisp/subr.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/subr.el b/lisp/subr.el
index e49c277335..5965655d48 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -465,6 +465,15 @@ was called."
   (lambda (&rest args2)
     (apply fun (append args args2))))
 
+(defun apply-rpartially (fun &rest args)
+  "Return a function that is a partial application of FUN to ARGS to the right.
+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))))
+
 (defun zerop (number)
   "Return t if NUMBER is zero."
   ;; Used to be in C, but it's pointless since (= 0 n) is faster anyway because
-- 
2.32.0