From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#38252: 27.0.50; Gnus server definitions and generic function specializers Date: Sun, 17 Nov 2019 14:31:13 -0800 Message-ID: <877e3yb0em.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="190433"; mail-complaints-to="usenet@blaine.gmane.org" Cc: larsi@gnus.org, monnier@iro.umontreal.ca To: 38252@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 17 23:32:27 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iWT5m-000nRP-Pd for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Nov 2019 23:32:26 +0100 Original-Received: from localhost ([::1]:56758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWT5l-00076h-BY for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Nov 2019 17:32:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45494) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWT5R-00072V-5K for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2019 17:32:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWT5P-0005FX-Gt for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2019 17:32:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34067) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iWT5P-0005EO-5R for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2019 17:32:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iWT5O-0005rq-Kh; Sun, 17 Nov 2019 17:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: larsi@gnus.org, monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Nov 2019 22:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38252 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: larsi@gnus.org,monnier@iro.umontreal.ca Original-Received: via spool by submit@debbugs.gnu.org id=B.157402989322516 (code B ref -1); Sun, 17 Nov 2019 22:32:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Nov 2019 22:31:33 +0000 Original-Received: from localhost ([127.0.0.1]:42888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iWT4v-0005r5-Fp for submit@debbugs.gnu.org; Sun, 17 Nov 2019 17:31:33 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:50845) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iWT4t-0005qy-Ig for submit@debbugs.gnu.org; Sun, 17 Nov 2019 17:31:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45458) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWT4r-0006oV-I4 for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2019 17:31:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWT4p-0004Wh-JZ for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2019 17:31:29 -0500 Original-Received: from ericabrahamsen.net ([52.70.2.18]:50102 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iWT4p-0004Hl-Fg for bug-gnu-emacs@gnu.org; Sun, 17 Nov 2019 17:31:27 -0500 Original-Received: from localhost (unknown [205.175.106.140]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id D991EFA01D for ; Sun, 17 Nov 2019 22:31:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171874 Archived-At: 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) ) --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)) ) --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