From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] new EUDC backends for ecomplete, and mailabbrev (with ERT tests) Date: Tue, 16 Aug 2022 21:47:19 -0400 Message-ID: References: <8e9c60585677321e437a29215963a908@condition-alpha.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11475"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, Thomas Fitzsimmons To: Alexander Adolf Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 17 03:49:13 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO8BE-0002mz-IC for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Aug 2022 03:49:12 +0200 Original-Received: from localhost ([::1]:57394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO8BD-0003f4-Ab for ged-emacs-devel@m.gmane-mx.org; Tue, 16 Aug 2022 21:49:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO89X-0002cP-T9 for emacs-devel@gnu.org; Tue, 16 Aug 2022 21:47:32 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:62869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO89V-00053P-1X for emacs-devel@gnu.org; Tue, 16 Aug 2022 21:47:26 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 97718100138; Tue, 16 Aug 2022 21:47:22 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E7BF81000ED; Tue, 16 Aug 2022 21:47:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1660700840; bh=9wqaddMBAa7rACNnbCltYjEs33U1w9s7VDbYF8AfB4o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Z3Bzdhyv5GaLFTezTK7NKCzvAgrYHBqm2tBkWBLOoUHTJ/ewiDdoHX6l8Bqosesjm /kqixhqX4uyt8tk2visgcB5zibC/JFQwTQBN76S5o7tbArvBBVOGTA1DEYGMkij8TT TjSiN8KEdNesotKH8jqvs8NCQff6IuJDzrt3ftBOfq35yF+OAdLXPw8ThcCtsn3PT9 e7/XYo07vPOprKcVA1lK06IK5qSwBtYhYQtWZIaAeP2SIeXAO27oSP6dfWmogTt6bM 8gH31VOodQEXj3RbL11S1A7gHztyDNQQhr8Oo3GhwP74oyZnADdDBY7hYDnAg9L1Pa lJZUUq9mRImTQ== Original-Received: from pastel (unknown [45.72.195.111]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BABA712025D; Tue, 16 Aug 2022 21:47:20 -0400 (EDT) In-Reply-To: <8e9c60585677321e437a29215963a908@condition-alpha.com> (Alexander Adolf's message of "Wed, 17 Aug 2022 02:11:21 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:293526 Archived-At: Alexander Adolf [2022-08-17 02:11:21] wrote: > +To enable the ecomplete backend, first `require' the respective > +library to load it, and then set the `eudc-server' to localhost in > +your init file: [ I think those `...' should be replace with @code{...} or something like that. ] I think we should be able to make the setup more intuitive. The most immediate problem I see is that there's nothing in "set the `eudc-server' to localhost" which refers to ecomplete, so as a reader I'm left wondering why that would help. > +@lisp > +(require 'eudcb-ecomplete) > +(eudc-ecomplete-set-server "localhost") > +@end lisp It's better to avoid using `require` inside the init file: - As a general rule, loading an ELisp file should not significantly affect Emacs's behavior. - `require` has to load the file right away, slowing down startup. The second point is moot here, admittedly, since calling `eudc-ecomplete-set-server` will need eudc-ecomplete anyway (either via `require` or via autoloading), but still it's better to autoload that function so the users don't need to `require` the library explicitly. Even better would be to replace the above with something like: (setq eudb-foo-bar 'ecomplete) so the EUDB files don't need to be loaded at startup. [ FWIW, I also happen to believe that Ecomplete should generally be enabled by default, so there should be *no* configuration needed at all for it to work. ] > +;;; Commentary: > +;; This library provides an interface to the ecomplete package as > +;; an EUDC data source. > + > +;;; Usage: > +;; To load the library, first `require' it: > +;; > +;; (require 'eudcb-ecomplete) See above. > +;; In the simplest case then just use: > +;; > +;; (eudc-ecomplete-set-server "localhost") Why have a dummy argument? > +(defvar eudc-ecomplete-attributes-translation-alist > + '((email . mail)) > + "See `eudc-protocol-attributes-translation-alist'. > +The back-end-specific attribute names are used as the \"type\" of > +entry when searching, and they must hence match the types you use > +in your ecmompleterc database file.") ^^^^^^^^^^^^ typo > +;; hook ourselves into the EUDC framework > +(eudc-protocol-set 'eudc-query-function > + 'eudc-ecomplete-query-internal > + 'ecomplete) > +(eudc-protocol-set 'eudc-list-attributes-function > + nil > + 'ecomplete) [ Sounds like EUDC could make use of `cl-generic` :-) ] > +(defun eudc-ecomplete-query-internal (query &optional _return-attrs) > + "Query `ecomplete' with QUERY. > +QUERY is a list of cons cells (ATTR . VALUE). Since `ecomplete' > +does not provide attributes in the usual sense, the > +back-end-specific attribute names in > +`eudc-ecomplete-attributes-translation-alist' are used as the > +KEY (that is, the \"type\" of match) when looking for matches in > +`ecomplete-database'. > + > +RETURN-ATTRS is a list of attributes to return, defaulting to > +`eudc-default-return-attributes'." > + (ecomplete-setup) > + (let ((email-attr (car (eudc-translate-attribute-list '(email)))) Why do we ignore `return-attrs` and hardcode `email` instead (and make the docstring lie in the process)? > + ;; special case email: try to decompose As a convention we like treat our comments with respect; granting them the same capitalization and punctuation we'd use in normal text. > +(eudc-register-protocol 'ecomplete) I think it would be good to have `ecomplete` registered as a supported protocol before this file is loaded. Oh, and thanks for the tests. I haven't looked at the mailabbrev patch, sorry. Stefan