From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: arthur miller <arthur.miller@live.com>
Newsgroups: gmane.emacs.devel
Subject: RE: Docs for &optional and &rest arguments together
Date: Tue, 29 Dec 2020 17:06:52 +0000
Message-ID: <AM0PR06MB657775EB8ED0387AEA0EB09996D80@AM0PR06MB6577.eurprd06.prod.outlook.com>
References: <AM0PR06MB657709C899365FC0710F505496D80@AM0PR06MB6577.eurprd06.prod.outlook.com>,
 <87eej8ejhc.fsf@alphapapa.net>
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_000_AM0PR06MB657775EB8ED0387AEA0EB09996D80AM0PR06MB6577eurp_"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="10000"; mail-complaints-to="usenet@ciao.gmane.io"
To: Adam Porter <adam@alphapapa.net>, "emacs-devel@gnu.org"
 <emacs-devel@gnu.org>
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 29 18:08:08 2020
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>
Envelope-to: ged-emacs-devel@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 <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>)
	id 1kuITf-0002TF-O7
	for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Dec 2020 18:08:07 +0100
Original-Received: from localhost ([::1]:56650 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>)
	id 1kuITe-0002EX-Pm
	for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Dec 2020 12:08:06 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47940)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <arthur.miller@live.com>)
 id 1kuISw-0001ks-H8
 for emacs-devel@gnu.org; Tue, 29 Dec 2020 12:07:22 -0500
Original-Received: from mail-db8eur05olkn20800.outbound.protection.outlook.com
 ([2a01:111:f400:7e1a::800]:15552
 helo=EUR05-DB8-obe.outbound.protection.outlook.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <arthur.miller@live.com>)
 id 1kuISt-0006vY-6H
 for emacs-devel@gnu.org; Tue, 29 Dec 2020 12:07:22 -0500
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=nIlbXvg01WM92KzV+eZyoi87dBxlmz9X5VXixnkZWo5WhylaqJhOuOJ2os/YrVe4wBuCWsrlz01kbMqw6DfPbuH/TG9heh+OGPLccLt0GogDG7mXdiLo03eqfcF4ctDHe+aelcrnhL/UPWcdEatvFrzZa0bjDX672g8EDVe6Eg/HWWmMD9IGcbMdQyaBd5ACjQTtkyGOiXBZ1VC41HiLH8OCiCDemnrMFCinZWFZXr8383fO/ZR3F/uSZUQEWEAIbQ/1Bfwi279JH44TPVxev/SB2APc0rqWXiLnwKztfBj1IVPayssNu9Rj+tFrOQDwfqCMWKylQoSWHsTvoxARRw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=+ZUNV7tX6KZRQlhQrcpKsD7oHvuPY6lN+b5hjvN/t1Y=;
 b=Yf2FwW6o9fGsi0adrNMl1/x4s27cZHj8+bWpsuS25CDfW1eqlsMVP82xUAboEh5XtRTKL3mzEq7/z7NdLMkQVhys5ZZGnMhdLC5vIVYIntYooHFgMMYaHQWKvMbYoVJ2hw45TNTQwtpH9YMLQJ928p8v2AefeYXsUK96Z2I8d59N/sSk0kCLRcsZV5FOUtcCc9J08Tzjf7XT/H69GDeG5KOBimSZquug/Zszsq8TAp6di38uoJ6kDcJyIUCMUyVy9nnuJHOUeRzuRkAV5c08vMvB2ks/p2btULNyq0igNOGtajdJ9gtRLt0t1yTXpMQrBG7bF3qonlNa/rHaVSh2Lw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
 dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; 
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=+ZUNV7tX6KZRQlhQrcpKsD7oHvuPY6lN+b5hjvN/t1Y=;
 b=ZLSZ6FYt43Pj69JbC1t58VHzj6DTsTqHYkiIjfkvZL4aQ/S1PJQYDM2Fk9WCB74iBoE8uwDHlO8Gm+EyT0clDYN7Qep/Gjhc0FIAE/JGJzU0X2KQ8m/SuN9Zji7QqacuMBz+86aLjAQfcA7yYyegFlLlw4FP78OuQkEPsxjl6WQsZR+0at1Z/kDviriM4/dCJug6jsGKMWOggtdl8veCCEd+zj6++4k976FpJ24rxfmriu+/BK1TMLTmw0quoG+6lPduRKVIEN5s5XVEX2IDQvfIx9m9bwwm73xvZDFuv/o0yhO6mEh05IiI0plFRWhDWeK2Sh0y+o/cksAwHK2ZWg==
Original-Received: from VI1EUR05FT040.eop-eur05.prod.protection.outlook.com
 (2a01:111:e400:fc12::50) by
 VI1EUR05HT083.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::391)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27; Tue, 29 Dec
 2020 17:06:52 +0000
Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com
 (2a01:111:e400:fc12::47) by VI1EUR05FT040.mail.protection.outlook.com
 (2a01:111:e400:fc12::442) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend
 Transport; Tue, 29 Dec 2020 17:06:52 +0000
Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com
 ([fe80::9487:8c7d:da00:4993]) by AM0PR06MB6577.eurprd06.prod.outlook.com
 ([fe80::9487:8c7d:da00:4993%7]) with mapi id 15.20.3700.031; Tue, 29 Dec 2020
 17:06:52 +0000
Thread-Topic: Docs for &optional and &rest arguments together
Thread-Index: AQHW3eY5w8c4C21GEEWOLQaTEmz/fKoOLdxMgAAgWOk=
In-Reply-To: <87eej8ejhc.fsf@alphapapa.net>
Accept-Language: sv-SE, en-US
Content-Language: sv-SE
x-incomingtopheadermarker: OriginalChecksum:9CBA99BDAEE53C276A22005F949EBAAF44041FB7224807B9CE061E314F40644E;
 UpperCasedChecksum:0CB71FF3F42252721EC5D7D954930F0CCA10EC4E7C267CA79CB6144EF644CA1E;
 SizeAsReceived:6913; Count:44
x-ms-exchange-messagesentrepresentingtype: 1
x-tmn: [duKpe3ULm5z+daMzPhHOio+6eLidCQxe]
x-ms-publictraffictype: Email
x-incomingheadercount: 44
x-eopattributedmessage: 0
x-ms-office365-filtering-correlation-id: 38e66b9e-e980-4193-27db-08d8ac1c2359
x-ms-traffictypediagnostic: VI1EUR05HT083:
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: krovOhkjCzfJtYTe4p2XkKBXCMY/P/wGp+Nw1TMWmVt3d84vK4wHZr7uyOPcKwC0VpRKpu3VkshqhipnTzDhCDvb8kSCc28H7YkXx2YVuRDMJbA2mK66JCScZdmYQEfEEJCg4SChdyVFtoRw7Fvy+DnIx8zaVvtBnjebCavyE/waSILE2Qgh/R4Pm6e8jRQDt09NALPR7RLntX41YPq/npTFm1oKB/6HIOn5yKZHwxi6CDQsp1bEcgS60KOjtvwsH5yoREfScJMtrQoHeNuClmPMoKS9GiJhYU4oCOfTtWw=
x-ms-exchange-antispam-messagedata: /G7PlqLlDtYjXvn/2CEkBvrQyK3vx6t0c0FSTVkmoWTcxX2yEzCWc77edqzpsIr8isL83iCo8awyo6DUDkZoTo2L01i3KT2cV6LJ58TaEIjR2lYngyf4EH7myFpNgRa2KwJgkZjoZ2t2UVqGz1INYw==
x-ms-exchange-transport-forked: True
X-OriginatorOrg: live.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT040.eop-eur05.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 38e66b9e-e980-4193-27db-08d8ac1c2359
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Dec 2020 17:06:52.4365 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Internet
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR05HT083
Received-SPF: pass client-ip=2a01:111:f400:7e1a::800;
 envelope-from=arthur.miller@live.com;
 helo=EUR05-DB8-obe.outbound.protection.outlook.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org
Original-Sender: "Emacs-devel"
 <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>
Xref: news.gmane.io gmane.emacs.devel:262075
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/262075>

--_000_AM0PR06MB657775EB8ED0387AEA0EB09996D80AM0PR06MB6577eurp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thx Adam, I'll take a look at it some time.

It wasn't though much of a question, I just wanted to point out that docs m=
iss to make clear a case when optional and rest arguments are used together=
. Unless I don't misunderstand how it works. Maybe I do :-).






-------- Originalmeddelande --------
Fr=E5n: Adam Porter <adam@alphapapa.net>
Datum: 2020-12-29 16:11 (GMT+01:00)
Till: emacs-devel@gnu.org
=C4mne: Re: Docs for &optional and &rest arguments together

This doesn't exactly answer your question, but here's an alternative you
might be interested in: I wrote a similar macro a while back, and I
tried to follow CL-style arguments by using a list of options.

https://github.com/alphapapa/elexandria/blob/83a1b08d0711fdce07a5b33525535c=
c3a457c6ee/elexandria.el#L105

Here's the source code:

(cl-defmacro with-file-buffer (path options &body body)
  "Insert contents of file at PATH into a temp buffer, and evaluate and ret=
urn the value of BODY in it.
OPTIONS is a plist accepting the following options:

`:must-exist': If non-nil, raise an error if no file exists at
PATH.

`:write': If non-nil, write the contents of the buffer to file at
PATH after evaluating BODY.

`:overwrite': If nil (or unset), raise an error instead of
overwriting an existing file at PATH.  If `ask', ask for
confirmation before overwriting an existing file.  If t,
overwrite a file at PATH unconditionally.

`:append': Passed to function `write-region', which see.

`:visit':  Passed to function `write-region', which see."
  (declare (indent 2))
  `(with-temp-buffer
     (if (file-readable-p ,path)
         (insert-file-contents ,path)
       (when ,(plist-get options :must-exist)
         (error "File not readable: %s" ,path)))
     (prog1
         (progn
           ,@body)
       ,(when (plist-get options :write)
          `(write-region nil nil path
                         ,(plist-get options :append)
                         ,(plist-get options :visit)
                         ,(pcase-exhaustive (plist-get options :overwrite)
                            ('nil ''excl)
                            ((or 'ask ''ask) ''ask)
                            ('t nil)))))))



--_000_AM0PR06MB657775EB8ED0387AEA0EB09996D80AM0PR06MB6577eurp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<meta name=3D"Generator" content=3D"Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; pad=
ding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div dir=3D"auto">
<div dir=3D"auto">Thx Adam, I'll take a look at it some time.</div>
<div dir=3D"auto"><br>
</div>
<div dir=3D"auto">It wasn't though much of a question, I just wanted to poi=
nt out that docs miss to make clear a case when optional and rest arguments=
 are used together. Unless I don't misunderstand how it works. Maybe I do :=
-).</div>
<div dir=3D"auto"><br>
</div>
<div dir=3D"auto"><br>
</div>
<div dir=3D"auto"><br>
</div>
<div id=3D"x_composer_signature" dir=3D"auto">
<div dir=3D"auto" style=3D"font-size:85%; color:#575757"><br>
</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>-------- Originalmeddelande --------</div>
<div>Fr=E5n: Adam Porter &lt;adam@alphapapa.net&gt; </div>
<div>Datum: 2020-12-29 16:11 (GMT+01:00) </div>
<div>Till: emacs-devel@gnu.org </div>
<div>=C4mne: Re: Docs for &amp;optional and &amp;rest arguments together </=
div>
<div><br>
</div>
</div>
<font size=3D"2"><span style=3D"font-size:11pt;">
<div class=3D"PlainText">This doesn't exactly answer your question, but her=
e's an alternative you<br>
might be interested in: I wrote a similar macro a while back, and I<br>
tried to follow CL-style arguments by using a list of options.<br>
<br>
<a href=3D"https://github.com/alphapapa/elexandria/blob/83a1b08d0711fdce07a=
5b33525535cc3a457c6ee/elexandria.el#L105">https://github.com/alphapapa/elex=
andria/blob/83a1b08d0711fdce07a5b33525535cc3a457c6ee/elexandria.el#L105</a>=
<br>
<br>
Here's the source code:<br>
<br>
(cl-defmacro with-file-buffer (path options &amp;body body)<br>
&nbsp; &quot;Insert contents of file at PATH into a temp buffer, and evalua=
te and return the value of BODY in it.<br>
OPTIONS is a plist accepting the following options:<br>
<br>
`:must-exist': If non-nil, raise an error if no file exists at<br>
PATH.<br>
<br>
`:write': If non-nil, write the contents of the buffer to file at<br>
PATH after evaluating BODY.<br>
<br>
`:overwrite': If nil (or unset), raise an error instead of<br>
overwriting an existing file at PATH.&nbsp; If `ask', ask for<br>
confirmation before overwriting an existing file.&nbsp; If t,<br>
overwrite a file at PATH unconditionally.<br>
<br>
`:append': Passed to function `write-region', which see.<br>
<br>
`:visit':&nbsp; Passed to function `write-region', which see.&quot;<br>
&nbsp; (declare (indent 2))<br>
&nbsp; `(with-temp-buffer<br>
&nbsp;&nbsp;&nbsp;&nbsp; (if (file-readable-p ,path)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (insert-file-contents ,pat=
h)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (when ,(plist-get options :must-exist)=
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (error &quot;File not read=
able: %s&quot; ,path)))<br>
&nbsp;&nbsp;&nbsp;&nbsp; (prog1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (progn<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,@body)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,(when (plist-get options :write)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `(write-region nil n=
il path<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,(pli=
st-get options :append)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,(pli=
st-get options :visit)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,(pca=
se-exhaustive (plist-get options :overwrite)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; ('nil ''excl)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; ((or 'ask ''ask) ''ask)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; ('t nil)))))))<br>
<br>
<br>
</div>
</span></font>
</body>
</html>

--_000_AM0PR06MB657775EB8ED0387AEA0EB09996D80AM0PR06MB6577eurp_--