unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Re: Turning Gnus groups into real objects
Date: Fri, 19 Jul 2019 11:47:49 -0700	[thread overview]
Message-ID: <87ftn17tey.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 877e8e89os.fsf@mouse.gnus.org

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> My original long-term plan was to replace the nnoo machinery with Emacs'
>> built-in object stuff: defvoo would become object slots, and deffoo
>> would become generic functions. Would this be a bad idea for the same
>> reason? That would also be a bummer, but at the same time save me a lot
>> of work :)
>
> The reason the voo stuff is like it is is for backwards-compatibility
> with out-of-tree backends.  If we want to keep that, then rewriting to
> use a proper object system would require two pairs of interface
> functions.

I guess it seems unlikely that a lot of external code is messing with
server internals, but I suppose it's possible that some Gnus astronauts
have written entire new backends for themselves. But maintaining two
pairs of interface functions would be a nightmare, and likely negate
most of the potential benefit of using generic functions.

> But I think rewriting that stuff is a more self-contained operation
> because the nn* interface at least is defined as an interface (which the
> group/info structures are not).  So I think that's a much better thing
> to be rewritten.
>
> I.e., first define what the interface should be, then rewrite the
> backends, one by one, to use that new and better interface.  People who
> have customisations to the code will find that their customisations
> don't work in the new versions, but that's OK, I think.

Okay, cool. Just for clarity, we'd end up with something looking like:

(defclass gnus-server ()
  ((address :type string)
  ...))

(defclass gnus-nnimap (gnus-server)
  ((capabilities
    :type string)
   (newlinep
    :type boolean)
   ...))

(cl-defmethod gnus-request-list ((server gnus-nnimap))
  (when (nnimap-change-group nil server)
    (with-current-buffer nntp-server-buffer
      (erase-buffer)
      (let ((groups
	     (with-current-buffer (nnimap-buffer)
	       (nnimap-get-groups)))
	    sequences responses)
	...))))

I'd aim at a few general principles:

1. Move more code into the methods, in particular the base methods.
2. Where possible, give servers their own process buffer (for if we ever
   want to make Gnus threaded).
3. Let all servers keep track of a list of "their" groups.
4. Wherever possible, pass servers as arguments instead of guessing them
   from the environment.
5. Keep a "real" list of servers, equivalent to `(cons gnus-select-method
   (append gnus-secondary-select-methods gnus-server-alist))', so we
   don't have to keep looking for them.

I can try to start off with the absolute smallest change possible, but
something tells me it won't work to switch the backends over gradually,
ie to maintain a hybrid system for a while. It will probably need to
happen all in one go (though again, I can minimize changes in the
beginning).

Anyway, all this is still quite a ways down the road. Thanks for looking
at this.

Eric




  reply	other threads:[~2019-07-19 18:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 19:29 Turning Gnus groups into real objects Eric Abrahamsen
2019-07-17 21:33 ` Andy Moreton
2019-07-17 22:04   ` Eric Abrahamsen
2019-07-17 21:59 ` Stefan Monnier
2019-07-17 22:08   ` Eric Abrahamsen
2019-07-18 11:59 ` Lars Ingebrigtsen
2019-07-18 18:01   ` Eric Abrahamsen
2019-07-19 12:56     ` Lars Ingebrigtsen
2019-07-19 18:47       ` Eric Abrahamsen [this message]
2019-07-19 22:10         ` Stefan Monnier
2019-07-19 23:56           ` Eric Abrahamsen
2019-07-20 12:52         ` Lars Ingebrigtsen
2019-07-21  1:41           ` Eric Abrahamsen
2019-07-21 12:34             ` Barry Fishman
2019-07-22 17:14               ` Eric Abrahamsen
2019-07-21 13:40             ` Stefan Monnier
2019-07-22 16:38               ` Eric Abrahamsen
2019-07-21 14:02             ` Lars Ingebrigtsen
2019-07-22 16:26               ` 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

  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=87ftn17tey.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.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).