From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: daanturo Newsgroups: gmane.emacs.bugs Subject: bug#49316: Add apply-partially's right version Date: Thu, 1 Jul 2021 23:24:22 +0700 Message-ID: References: <2315db79-00cf-b2f0-b5df-93cd53392292@gmail.com> <87czs2faas.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------FB754410FFEC91DC8766C690" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10375"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Cc: "Basil L. Contovounesios" To: 49316@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 01 18:25:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyzV3-0002Z4-Cf for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Jul 2021 18:25:13 +0200 Original-Received: from localhost ([::1]:51130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyzV1-0008HJ-GX for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Jul 2021 12:25:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyzUs-0008H9-FA for bug-gnu-emacs@gnu.org; Thu, 01 Jul 2021 12:25:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyzUs-0004r5-70 for bug-gnu-emacs@gnu.org; Thu, 01 Jul 2021 12:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyzUr-0006rj-Tw for bug-gnu-emacs@gnu.org; Thu, 01 Jul 2021 12:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: daanturo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jul 2021 16:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49316 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49316-submit@debbugs.gnu.org id=B49316.162515667226339 (code B ref 49316); Thu, 01 Jul 2021 16:25:01 +0000 Original-Received: (at 49316) by debbugs.gnu.org; 1 Jul 2021 16:24:32 +0000 Original-Received: from localhost ([127.0.0.1]:33586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyzUO-0006ql-4r for submit@debbugs.gnu.org; Thu, 01 Jul 2021 12:24:32 -0400 Original-Received: from mail-pj1-f54.google.com ([209.85.216.54]:53189) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyzUN-0006qW-BF for 49316@debbugs.gnu.org; Thu, 01 Jul 2021 12:24:31 -0400 Original-Received: by mail-pj1-f54.google.com with SMTP id kt19so4582133pjb.2 for <49316@debbugs.gnu.org>; Thu, 01 Jul 2021 09:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=VeeyhrCHyfAAf8BkJM5nAsZxzbEbnrVWz+DabnMAqxk=; b=XGCscEcz+4yqBoUjDzL4HWe3EvFWO4P0mgNa6YtA0SWBWqHt7rZI7PFKe1vm85z87u eqi+RrVn84cyiTA8bJeKmAH0tZbZGtkmyKC8qEIQjErzZa1k3F5M/pZ0UsVqnrlUzjwG NE+IOnOeKqU5qGcudr/LnB99beDoneXXFPywmaQvpvJ4H0IMkrkjS5Dc+/HMV24qyBd8 aRJ7ijj9Vvl5Dv6UxYwzdanbr28+A3E7SsEEhGDq5mbeMBLLDJ9MN5SZGpq/GRJ5+Cug sNdG2HBIKv9Rx2VpjbYDoy3wkvvep+Y5Pfo+VvicbR/QOG0llYfHupG59eUhC+SX3nkX zI7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=VeeyhrCHyfAAf8BkJM5nAsZxzbEbnrVWz+DabnMAqxk=; b=ChPuAGtY3ZJT/H8FZEhj8tMaH7VN8f86LILxFmmkUgkDiK5iJvVHSTmVFFW+hk3k2J ZH4xMJIkCH5/BCR7Xpj47q/EtkGCgedfGidWRwK3PtVXp7mzeWuACcg/HcQFGVfXqDnX tl++y7MOZh4h2eBQpJ3iGSPgDyL0XWmVYEQ2I1Di3DygeaCh492rTQHbz5DM63U5mm0K r+E/A9MkM3JcaNoV9uZNxudff9POkaXnMYlS2odlClqY1zkRZPeRg81DkKNJk2r1ooVq x+yiu3VgSbIDU9nAAHyJBwOd5I6hbj9f6E4Zh/czfEW4f1pjor2Zw9+41Rvl7A0xtivS O0Fw== X-Gm-Message-State: AOAM532rfONIk/oYRT5tmHVyXzD9Ii6NMMZoJ+VyxeqXqwZ6dTAwCz2R YsWjDYAvJBOZhfcQc+ifeRw= X-Google-Smtp-Source: ABdhPJzlSrbfKfZKd+KQX80orAUfaCYDcQvCZjoLIvIzCGg+xP7TpSj0xC02eQakHBFeNyOoOnSD5Q== X-Received: by 2002:a17:902:d4c6:b029:128:9982:511e with SMTP id o6-20020a170902d4c6b02901289982511emr588527plg.43.1625156665615; Thu, 01 Jul 2021 09:24:25 -0700 (PDT) Original-Received: from ?IPv6:2402:800:630f:53b:ee3a:5256:1634:1e03? ([2402:800:630f:53b:ee3a:5256:1634:1e03]) by smtp.gmail.com with ESMTPSA id o184sm352841pga.18.2021.07.01.09.24.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jul 2021 09:24:25 -0700 (PDT) In-Reply-To: <87czs2faas.fsf@tcd.ie> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209274 Archived-At: This is a multi-part message in MIME format. --------------FB754410FFEC91DC8766C690 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Added documentation in doc/lispref/functions.texi and etc/NEWS. Thank you. On 7/1/21 8:11 PM, Basil L. Contovounesios wrote: > tags 49316 + patch > quit > >> From c594d6fc396b80019c48e63918f8c5e485f2782f Mon Sep 17 00:00:00 2001 >> From: Daanturo >> Date: Thu, 1 Jul 2021 19:21:08 +0700 >> Subject: [PATCH] Define apply-rpatially > ^^^^^^^^^ > rpartially > >> Which is analogous to `apply-partially` but arguments are aligned on the right >> instead. > Nit: Missing changelog-style entry (see the guidelines in the file > CONTRIBUTE), e.g.: > > * lisp/subr.el (apply-rpartially): New function. > >> lisp/subr.el | 9 +++++++++ >> 1 file changed, 9 insertions(+) > This feature would probably also warrant an announcement in etc/NEWS and > a manual entry under (info "(elisp) Calling Functions"). > > Thanks, > -- Daanturo. --------------FB754410FFEC91DC8766C690 Content-Type: text/x-patch; charset=UTF-8; name="0002-Add-apply-rpartially-documents.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Add-apply-rpartially-documents.patch" >From b56a83f2765d3dfb1db011acc561bf107c934594 Mon Sep 17 00:00:00 2001 From: Daanturo Date: Thu, 1 Jul 2021 23:01:42 +0700 Subject: [PATCH 2/2] Add apply-rpartially documents * doc/lispref/functions.texi (Calling Functions): Add explanation and example usage * etc/NEWS (Lisp Changes in Emacs 28.1): Announce new function --- doc/lispref/functions.texi | 17 +++++++++++++++++ etc/NEWS | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 64883bf0f6..80d0c96687 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -845,6 +845,23 @@ built-in function: @end example @end defun +@defun apply-rpartially func &rest args +This function does mostly the same as @code{apply-partially}, but +@var{args} are aligned to the right of @var{func}'s parameters +instead. + +@example +@group +(defalias 'square (apply-rpartially #'expt 2) + "Return argument squared.") +@end group +@group +(square 3) + @result{} 9 +@end group +@end example +@end defun + @cindex functionals It is common for Lisp functions to accept functions as arguments or find them in data structures (especially in hook variables and property diff --git a/etc/NEWS b/etc/NEWS index 605c4d228f..252e6b4d0b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2909,6 +2909,11 @@ The former is now declared obsolete. * Lisp Changes in Emacs 28.1 ++++ +** New function 'apply-rpartially'. +Funcionally equivalent to 'apply-partially' but arguments are aligned +to the right instead. + +++ ** New function 'syntax-class-to-char'. This does almost the opposite of 'string-to-syntax' -- it returns the -- 2.32.0 --------------FB754410FFEC91DC8766C690 Content-Type: text/x-patch; charset=UTF-8; name="0001-Define-apply-rpartially.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Define-apply-rpartially.patch" >From 6af0d300d214c3fcf872641356a6c788b0aed771 Mon Sep 17 00:00:00 2001 From: Daanturo Date: Thu, 1 Jul 2021 22:03:05 +0700 Subject: [PATCH 1/2] Define apply-rpartially * lisp/subr.el (apply-rpartially): New function 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 --------------FB754410FFEC91DC8766C690--