From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: 38252@debbugs.gnu.org
Cc: larsi@gnus.org, monnier@iro.umontreal.ca
Subject: bug#38252: 27.0.50; Gnus server definitions and generic function specializers
Date: Sun, 17 Nov 2019 14:31:13 -0800 [thread overview]
Message-ID: <877e3yb0em.fsf@ericabrahamsen.net> (raw)
I'm working on changing Gnus servers into structs, and replacing the
nnoo.el architecture with generic functions, and while I think I've got
a workable roadmap I'm running into some practical confusions. Stefan
I'm ccing you directly because I suspect you're the only one who knows
the answers to my questions :)
The approach is this: Change the server interface functions in
gnus-int.el into generic functions. Provide a generalizer that
recognizes current Gnus servers, and dispatches to the current function
definitions (using `gnus-get-function' and all that). Gradually change
the in-tree backends to be defined with cl-defstruct, and use normal
dispatching-on-struct for those. Eventually the legacy generalizer would
be left in place just to deal with old-style out-of-tree backends.
As an example, here's what `gnus-request-list' currently looks like:
--8<---------------cut here---------------start------------->8---
gnus-int.el:
(defun gnus-request-list (gnus-command-method)
(funcall (gnus-get-function gnus-command-method 'request-list)
(nth 1 gnus-command-method)))
nnimap.el:
(deffoo nnimap-request-list (&optional server)
<get IMAP group list>)
--8<---------------cut here---------------end--------------->8---
Afterward it would look like this:
--8<---------------cut here---------------start------------->8---
gnus-int.el:
(cl-defgeneric gnus-request-list (server)
"Docs and stuff.")
(cl-defmethod gnus-request-list ((server gnus-server-legacy))
(funcall (gnus-get-function server 'request-list)
(nth 1 server)))
nnimap.el:
(cl-defmethod gnus-request-list ((server gnus-server-imap))
<get IMAP group list>)
--8<---------------cut here---------------end--------------->8---
The nnimap version will dispatch on the `gnus-server-imap' defstruct,
that happens automatically. What I need is to be able to write a
generalizer/specializer that will recognize a legacy server (if calling
it "legacy" is annoying I can find something else) and dispatch on it.
The docstring of `cl-generic-define-generalizer' is gnomic, though I
found some better information in the docstring of
`cl-generic-generalizers', and looked at some of the existing
generalizer definitions.
Here's what I've worked up so far:
--8<---------------cut here---------------start------------->8---
(cl-generic-define-generalizer gnus-legacy-server-generalizer
90 (lambda (name &rest _) `(???)
(lambda (tag &rest _) (when (eq (car-safe tag) 'gnus-legacy-server)
(list tag))))
(cl-defmethod cl-generic-generalizers :extra "gnus-legacy-server" (thing)
"Dispatch on old-style Gnus server definitions."
(when wut?
(list gnus-legacy-server-generalizer)))
--8<---------------cut here---------------end--------------->8---
What I'm trying to do is fairly simple: if the argument is a list, and
the head of the list is a symbol that can be assoc'd into
`nnoo-definition-alist', and the second element is a string, then it's a
gnus-legacy-server. I just don't know where that test is supposed to go,
or why.
I understand this will probably be inefficient and ugly, but I hope that
before too long it would be a rare case that the generalizer is checked
at all.
Thanks,
Eric
next reply other threads:[~2019-11-17 22:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-17 22:31 Eric Abrahamsen [this message]
2019-11-18 2:03 ` bug#38252: 27.0.50; Gnus server definitions and generic function specializers Stefan Monnier
2019-11-18 3:18 ` Eric Abrahamsen
2019-11-18 4:36 ` Stefan Monnier
2019-11-18 20:43 ` Eric Abrahamsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877e3yb0em.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=38252@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.