From: arthur miller <arthur.miller@live.com>
To: Adam Porter <adam@alphapapa.net>,
"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: RE: Docs for &optional and &rest arguments together
Date: Tue, 29 Dec 2020 17:06:52 +0000 [thread overview]
Message-ID: <AM0PR06MB657775EB8ED0387AEA0EB09996D80@AM0PR06MB6577.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <87eej8ejhc.fsf@alphapapa.net>
[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]
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 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 :-).
-------- Originalmeddelande --------
Från: Adam Porter <adam@alphapapa.net>
Datum: 2020-12-29 16:11 (GMT+01:00)
Till: emacs-devel@gnu.org
Ämne: 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/83a1b08d0711fdce07a5b33525535cc3a457c6ee/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 return 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)))))))
[-- Attachment #2: Type: text/html, Size: 4496 bytes --]
next prev parent reply other threads:[~2020-12-29 17:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 13:26 Docs for &optional and &rest arguments together Arthur Miller
2020-12-29 15:10 ` Adam Porter
2020-12-29 17:06 ` arthur miller [this message]
2021-01-01 14:33 ` Arthur Miller
2020-12-30 3:12 ` Lars Ingebrigtsen
2020-12-30 12:19 ` Arthur Miller
2020-12-30 12:54 ` Yuri Khan
2020-12-31 4:43 ` Lars Ingebrigtsen
2020-12-31 7:55 ` arthur miller
2020-12-31 11:26 ` tomas
2020-12-31 16:45 ` Drew Adams
2020-12-31 17:04 ` Drew Adams
2020-12-31 17:28 ` arthur miller
2020-12-31 18:19 ` Drew Adams
2020-12-31 20:01 ` arthur miller
2020-12-31 20:27 ` Drew Adams
2020-12-31 17:08 ` arthur miller
2020-12-31 17:30 ` Daniel Brooks
2020-12-31 19:53 ` arthur miller
2020-12-31 19:40 ` tomas
-- strict thread matches above, loose matches on Subject: below --
2020-12-31 20:04 arthur miller
2020-12-31 20:35 ` tomas
2020-12-31 23:18 ` arthur miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM0PR06MB657775EB8ED0387AEA0EB09996D80@AM0PR06MB6577.eurprd06.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=adam@alphapapa.net \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).