GNU bug report logs - #38252
27.0.50; Gnus server definitions and generic function specializers

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Eric Abrahamsen <eric@HIDDEN>; dated Sun, 17 Nov 2019 22:32:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 38252 <at> debbugs.gnu.org:


Received: (at 38252) by debbugs.gnu.org; 18 Nov 2019 20:43:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 18 15:43:47 2019
Received: from localhost ([127.0.0.1]:46333 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iWnsA-0003bF-Lk
	for submit <at> debbugs.gnu.org; Mon, 18 Nov 2019 15:43:46 -0500
Received: from ericabrahamsen.net ([52.70.2.18]:43230
 helo=mail.ericabrahamsen.net)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eric@HIDDEN>) id 1iWns8-0003b1-6Z
 for 38252 <at> debbugs.gnu.org; Mon, 18 Nov 2019 15:43:44 -0500
Received: from localhost (unknown [205.175.106.77])
 (Authenticated sender: eric@HIDDEN)
 by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 845A6FA087;
 Mon, 18 Nov 2019 20:43:38 +0000 (UTC)
From: Eric Abrahamsen <eric@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#38252: 27.0.50; Gnus server definitions and generic
 function specializers
References: <877e3yb0em.fsf@HIDDEN>
 <jwv1ru69cc0.fsf-monnier+emacs@HIDDEN>
 <87imnhan3t.fsf@HIDDEN>
 <jwvd0dp95h5.fsf-monnier+emacs@HIDDEN>
Date: Mon, 18 Nov 2019 12:43:37 -0800
In-Reply-To: <jwvd0dp95h5.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Sun, 17 Nov 2019 23:36:09 -0500")
Message-ID: <87v9rgncee.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38252
Cc: larsi@HIDDEN, 38252 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


On 11/17/19 23:36 PM, Stefan Monnier wrote:
>> But just so I don't feel like I wasted my afternoon: how *would* one
>> write the generalizer I'm talking about?
>
> Ah, that part.
> I guess It could look like (guaranteed 100% untested):
>
>     (defvar gnus--legacy-server-tag (make-symbol "gnus-legacy-server"))
>     (cl-generic-define-generalizer gnus-legacy-server-generalizer
>       90 (lambda (varname &rest _)
>            `(and (consp ,varname)
>                  (symbolp (car ,varname))
>                  (assq (car ,varname) nnoo-definition-alist)
>                  (stringp (cadr ,varname))
>                  gnus--legacy-server-tag))
>       (lambda (tag &rest _)
>         (when (eq tag gnus--legacy-server-tag) (list tag))))
>     
>     (cl-defmethod cl-generic-generalizers ((_ (eql gnus-legacy-server)))
>       "Dispatch on old-style Gnus server definitions."
>       (list gnus-legacy-server-generalizer))

That's perfect, thanks. I don't need tested code, I just needed to
understand the logic of which bit is responsible for what. I wonder if
it would be useful to have an example of this, either in the manual or
cl-generic.el code comments? 

There's still a lot of work to do before struct servers and cons servers
can coexist within Gnus, but it's nice to have this piece of the puzzle
solved.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38252; Package emacs. Full text available.

Message received at 38252 <at> debbugs.gnu.org:


Received: (at 38252) by debbugs.gnu.org; 18 Nov 2019 04:36:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 23:36:28 2019
Received: from localhost ([127.0.0.1]:43026 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iWYm2-0006GZ-T2
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2019 23:36:28 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21256)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1iWYlx-0006GI-Fx
 for 38252 <at> debbugs.gnu.org; Sun, 17 Nov 2019 23:36:22 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D715E81257;
 Sun, 17 Nov 2019 23:36:15 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 8028F8107A;
 Sun, 17 Nov 2019 23:36:14 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1574051774;
 bh=SPYtQUC50bQAPx8x2QmQ0LV8qLVdjear59PPuv/H18w=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=AwmLan/3XZXKcGBYlRWrJ7GU1J4FBmUjCB67meKLL/7uAxqCa3YtdCT5vMxXW3gyJ
 sJh8Bm+9bP4OeJ33jpjDue3ZZuiah3qPBcIX1r4hynumh105SGpSuRwtl4cIOnJdQW
 oPaYprEzAMAz248FyvGBQzE+pSHwhigeWrG9fyGEumokp9gVLcPPr/D514w54sv4zA
 l9r4CzhJueAI3c08rnYzIA5P1I4QIT0MUehMswGuJw8++gmKRNXEgLie1ow7bCqUOn
 qjyzf+qhtSROI7b6v1+ebcr9Uh13wgj2KB3mKR8qDygJZHObkAnGtxl2Scf025pY26
 O20iX0urt9lDQ==
Received: from alfajor (unknown [216.154.18.30])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id AC1BE12027A;
 Sun, 17 Nov 2019 23:36:13 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eric Abrahamsen <eric@HIDDEN>
Subject: Re: bug#38252: 27.0.50; Gnus server definitions and generic
 function specializers
Message-ID: <jwvd0dp95h5.fsf-monnier+emacs@HIDDEN>
References: <877e3yb0em.fsf@HIDDEN>
 <jwv1ru69cc0.fsf-monnier+emacs@HIDDEN>
 <87imnhan3t.fsf@HIDDEN>
Date: Sun, 17 Nov 2019 23:36:09 -0500
In-Reply-To: <87imnhan3t.fsf@HIDDEN> (Eric Abrahamsen's message of
 "Sun, 17 Nov 2019 19:18:30 -0800")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.058 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38252
Cc: larsi@HIDDEN, 38252 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> But just so I don't feel like I wasted my afternoon: how *would* one
> write the generalizer I'm talking about?

Ah, that part.
I guess It could look like (guaranteed 100% untested):

    (defvar gnus--legacy-server-tag (make-symbol "gnus-legacy-server"))
    (cl-generic-define-generalizer gnus-legacy-server-generalizer
      90 (lambda (varname &rest _)
           `(and (consp ,varname)
                 (symbolp (car ,varname))
                 (assq (car ,varname) nnoo-definition-alist)
                 (stringp (cadr ,varname))
                 gnus--legacy-server-tag))
      (lambda (tag &rest _)
        (when (eq tag gnus--legacy-server-tag) (list tag))))
    
    (cl-defmethod cl-generic-generalizers ((_ (eql gnus-legacy-server)))
      "Dispatch on old-style Gnus server definitions."
      (list gnus-legacy-server-generalizer))


-- Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38252; Package emacs. Full text available.

Message received at 38252 <at> debbugs.gnu.org:


Received: (at 38252) by debbugs.gnu.org; 18 Nov 2019 03:18:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 22:18:40 2019
Received: from localhost ([127.0.0.1]:42995 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iWXYl-0004MK-Vx
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2019 22:18:40 -0500
Received: from ericabrahamsen.net ([52.70.2.18]:48192
 helo=mail.ericabrahamsen.net)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eric@HIDDEN>) id 1iWXYk-0004M8-7H
 for 38252 <at> debbugs.gnu.org; Sun, 17 Nov 2019 22:18:38 -0500
Received: from localhost (c-73-254-86-141.hsd1.wa.comcast.net [73.254.86.141])
 (Authenticated sender: eric@HIDDEN)
 by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 3729FFA01D;
 Mon, 18 Nov 2019 03:18:32 +0000 (UTC)
From: Eric Abrahamsen <eric@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#38252: 27.0.50; Gnus server definitions and generic
 function specializers
References: <877e3yb0em.fsf@HIDDEN>
 <jwv1ru69cc0.fsf-monnier+emacs@HIDDEN>
Date: Sun, 17 Nov 2019 19:18:30 -0800
In-Reply-To: <jwv1ru69cc0.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Sun, 17 Nov 2019 21:03:00 -0500")
Message-ID: <87imnhan3t.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38252
Cc: larsi@HIDDEN, 38252 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


On 11/17/19 21:03 PM, Stefan Monnier wrote:
>> I'm ccing you directly because I suspect you're the only one who knows
>> the answers to my questions :)
>
> I doubt it, there's a lot of people around here more familiar with
> CLOS-style programming than I.
>
>> --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)))
>
> Why not just:
>
>     (cl-defmethod gnus-request-list (server)
>       (funcall (gnus-get-function server 'request-list)
>     	       (nth 1 server)))
>
> which means "use it as a fallback".  The downside is that it will be
> used for non-legacy servers if there is no specific implementation for
> that server, but presumably you can detect it and signal an appropriate
> error somewhere inside gnus-get-function.
>
>> 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.
>
> Why not just use a `cons` specializer?
>
> IIUC all the non-legacy servers will use structs, so you don't need to
> use a specializer that's so specific that it has to check "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".

Okay, perhaps I was overthinking this. I don't want to assume that the
fallback is an old-style server (we might want to use the fallback for
other purposes), but you're right that 'cons is pretty much sufficient.
If anyone feeds a cons value into a Gnus server interface function that
*isn't* a server definition, that falls into "serves you right"
territory.

But just so I don't feel like I wasted my afternoon: how *would* one
write the generalizer I'm talking about?

Thanks,
Eric




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38252; Package emacs. Full text available.

Message received at 38252 <at> debbugs.gnu.org:


Received: (at 38252) by debbugs.gnu.org; 18 Nov 2019 02:03:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 21:03:15 2019
Received: from localhost ([127.0.0.1]:42986 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iWWNn-0002Ub-4J
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2019 21:03:15 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30756)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1iWWNj-0002UK-Dl
 for 38252 <at> debbugs.gnu.org; Sun, 17 Nov 2019 21:03:12 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 07ADD81257;
 Sun, 17 Nov 2019 21:03:05 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 982238124E;
 Sun, 17 Nov 2019 21:03:03 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1574042583;
 bh=5fL2xzBijvRu3b9NgKvL43xHxBWDDK1N86NPOtPeBYM=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=OWLJMTA+lc6+FlYyqRyMV7q8Kdbykwu/4bU2URwhCgzGLM8123E9cgyb4k3pgu1wS
 CN6AVpOvFPBqoIg6yfueK7O3QEGSI9CFYGuXV93OEZyZJ+a6OehCLNEqY4p+6qbFoy
 rwAGLmAmo1sL9Lmp+f8DQIKSEFE2ahFUlX1LVwqemqsWbFszLlKe02WH149uvwz9gN
 /9VGHpLRlBjXVoRY598RNTaQ0x11VYRJF87IsqSWsde+4R0ql9Pg1v1OACOCE4L8BQ
 I9r7BYEc0FnUgHejxRVFNSNrZTcfxJXs393k7lZu/pL0nd67yINzjU3QZo//5IC9vu
 LZjxbe07uhlDw==
Received: from alfajor (unknown [216.154.18.30])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 10580121106;
 Sun, 17 Nov 2019 21:03:03 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eric Abrahamsen <eric@HIDDEN>
Subject: Re: bug#38252: 27.0.50; Gnus server definitions and generic
 function specializers
Message-ID: <jwv1ru69cc0.fsf-monnier+emacs@HIDDEN>
References: <877e3yb0em.fsf@HIDDEN>
Date: Sun, 17 Nov 2019 21:03:00 -0500
In-Reply-To: <877e3yb0em.fsf@HIDDEN> (Eric Abrahamsen's message of
 "Sun, 17 Nov 2019 14:31:13 -0800")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.058 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38252
Cc: larsi@HIDDEN, 38252 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> I'm ccing you directly because I suspect you're the only one who knows
> the answers to my questions :)

I doubt it, there's a lot of people around here more familiar with
CLOS-style programming than I.

> --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)))

Why not just:

    (cl-defmethod gnus-request-list (server)
      (funcall (gnus-get-function server 'request-list)
    	       (nth 1 server)))

which means "use it as a fallback".  The downside is that it will be
used for non-legacy servers if there is no specific implementation for
that server, but presumably you can detect it and signal an appropriate
error somewhere inside gnus-get-function.

> 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.

Why not just use a `cons` specializer?

IIUC all the non-legacy servers will use structs, so you don't need to
use a specializer that's so specific that it has to check "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".


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38252; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Nov 2019 22:31:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 17 17:31:33 2019
Received: from localhost ([127.0.0.1]:42888 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iWT4v-0005r5-Fp
	for submit <at> debbugs.gnu.org; Sun, 17 Nov 2019 17:31:33 -0500
Received: from lists.gnu.org ([209.51.188.17]:50845)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eric@HIDDEN>) id 1iWT4t-0005qy-Ig
 for submit <at> debbugs.gnu.org; Sun, 17 Nov 2019 17:31:32 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45458)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eric@HIDDEN>) id 1iWT4r-0006oV-I4
 for bug-gnu-emacs@HIDDEN; Sun, 17 Nov 2019 17:31:31 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_MED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eric@HIDDEN>) id 1iWT4p-0004Wh-JZ
 for bug-gnu-emacs@HIDDEN; Sun, 17 Nov 2019 17:31:29 -0500
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 <eric@HIDDEN>)
 id 1iWT4p-0004Hl-Fg
 for bug-gnu-emacs@HIDDEN; Sun, 17 Nov 2019 17:31:27 -0500
Received: from localhost (unknown [205.175.106.140])
 (Authenticated sender: eric@HIDDEN)
 by mail.ericabrahamsen.net (Postfix) with ESMTPSA id D991EFA01D
 for <bug-gnu-emacs@HIDDEN>; Sun, 17 Nov 2019 22:31:19 +0000 (UTC)
From: Eric Abrahamsen <eric@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.0.50; Gnus server definitions and generic function specializers
X-Debbugs-CC: larsi@HIDDEN,monnier@HIDDEN
Date: Sun, 17 Nov 2019 14:31:13 -0800
Message-ID: <877e3yb0em.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 52.70.2.18
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

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




Acknowledgement sent to Eric Abrahamsen <eric@HIDDEN>:
New bug report received and forwarded. Copy sent to larsi@HIDDEN, monnier@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to larsi@HIDDEN, monnier@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#38252; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.