From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oM1jBjVdHmJ4SQAAgWs5BA (envelope-from ) for ; Tue, 01 Mar 2022 18:51:49 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id gPajOjRdHmK0VgEAG6o9tA (envelope-from ) for ; Tue, 01 Mar 2022 18:51:48 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7B35E11113 for ; Tue, 1 Mar 2022 18:51:48 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 884F75F700; Tue, 1 Mar 2022 17:51:45 +0000 (UTC) Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by mail.notmuchmail.org (Postfix) with ESMTPS id 31EE35E027 for ; Tue, 1 Mar 2022 17:51:43 +0000 (UTC) Received: from [46.244.206.149] (helo=condition-alpha.com) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nP6ez-0006D6-UB; Tue, 01 Mar 2022 18:51:42 +0100 Message-Id: From: Alexander Adolf To: Tomi Ollila , Utkarsh Singh , Notmuch mailing list Subject: Re: emacs: notmuch-address-command 'as-is throws error (was: [PATCH] emacs: Add more front ends for address completion) In-Reply-To: References: <87bkzhbez9.fsf@gmail.com> <115f4649ac25dff4073a32dba70e6db7@condition-alpha.com> Date: Tue, 01 Mar 2022 18:51:41 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Df-Sender: YWxleGFuZGVyLmFkb2xmQGNvbmRpdGlvbi1hbHBoYS5jb20= Message-ID-Hash: MCRALB7GQD2N2PF422AQKWZL2LA4AEGZ X-Message-ID-Hash: MCRALB7GQD2N2PF422AQKWZL2LA4AEGZ X-MailFrom: alexander.adolf@condition-alpha.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1646157108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=IWYjEzEtnundk5NdiwzONCYUbsveWjrYGxbykVYvzls=; b=HheuF2qQOhqfjdZ5qNJsMhABSexsCBSQ71857w3md6z4VpQxf28d7AUt+3b6EgcvLv/EXd T0Jlon+zTUTI622RJIRJZd4slHl1NhtBKbmdAyw7PrVxXpHr0fXO1TSYUYh4lHQJb7Ua01 /6fVLcim6CNBhijOtd6AYUbhQv4huCiRc9iQWbY9p4rrcNG258HaD7yTloJJ59vkWgyu99 0RQAsRsJzXV8XzMsTHzClE9vzqRdmlLZCpR5i22J2NqLbQsfp1Bp9HedGJZBxO77U0ybIg uSz54GmGPc9cRuDiFODIWH+L7iuuhID1HU0Wv+ZA99evxcYYhfTvWj6qx4IvSA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646157108; a=rsa-sha256; cv=none; b=qri1f+NOYmk8YVFdL4MPLqfDpU1/HRajMtzXnTlqHZeu5+eXY/tIxX92p3/Co2cc9GyiTV jHoIhym095LYdsLtfivjBLp7pmAuqTHKrLdsDzW139cMz4iCfckNcjAZB9lq5WKNK5rh+s Orpi9S487ubnPXP8QWywOGRv+ZM9AmwMIMoVHRHBUUVph1x5CdAR8ygyFaTIN/XCNV6b4M YF7FRpXfCy3E9cjcVYXtyx0PmKDCJeziym6MIQY3hgjvRgTPygnNYT8eY7JQlPE+iULQCO uNP+dLUPq9Wxt2JevKRzc5LgMc0dpfVTrARw3gnKvEMQyHMwsDtNyS0mT9QOJQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.17 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 7B35E11113 X-Spam-Score: -2.17 X-Migadu-Scanner: scn1.migadu.com X-TUID: 1Tane+owX95q --=-=-= Content-Type: text/plain Alexander Adolf writes: > [...] > Variant 2 "core Emacs": > [...] It was not as much work as I had anticipated, and hence here is a first sketch of the idea: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=patch-notmuch-address.el Content-Transfer-Encoding: quoted-printable (defcustom notmuch-address-completion-style 'completion-at-point "Select the framework to use for email address completion. This variable determines which of the completion frameworks to use in the header area in `notmuch-message-mode' for completing email addresses. When set to `completion-at-point' (the default), in-buffer completion (i.e. where the point is) is used. This will trigger any third party package(s) providing a user interface on top of `completion-at-point'. When set to `completing-read', completion candidates will be offered in the minibuffer using `completing-read'. This will trigger any third party package(s) providing a user interface on top of `completing-read'." :type '(choice (const :tag "in-buffer (completion-at-point)" completion-a= t-point) (const :tag "minibuffer (completing-read)" completing-r= ead)) :group 'notmuch-send :group 'notmuch-address :group 'notmuch-external) (make-obsolete-variable notmuch-address-use-company "`company' support has been removed from notumuch-address. To continue using `company', set `notmuch-address-completion-style' to 'completion-at-point, and configure `company' to use the `company-capf' backend in `message-mode'." "0.35") (defun notmuch-address-complete-at-point (beg end orig) "Provide a completion table for email address completion candidates. This function is intended to be hooked into `message-completion-alist' with an appropriate regular expression matching message headers consisting of email recipients. It returns a completion table as is expected for functions listed in `completion-at-point-functions'." (setq-local completion-styles '(substring flex)) (list beg end (completion-table-dynamic (lambda (orig) (notmuch-address-options orig))))) (defun notmuch-address-completing-read (beg end orig) "Choose email address completion candidates using `completing-read'." (let* ((options (with-temp-message "Looking for completion candidates..." (notmuch-address-options orig))) (num-options (length options)) (chosen (cond ((eq num-options 0) nil) ((eq num-options 1) (car options)) (t (funcall notmuch-address-selection-function (format "Address (%s matches): " num-options) options orig))))) (if chosen (progn (push chosen notmuch-address-history) (delete-region beg end) (insert chosen) (run-hook-with-args 'notmuch-address-post-completion-functions chosen)) (message "No matches.") (ding)))) (defun notmuch-address-expand-name () (cond (notmuch-address-command (let* ((end (point)) (beg (save-excursion (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*") (goto-char (match-end 0)) (point))) (orig (buffer-substring-no-properties beg end)) (completion-ignore-case t)) (cond ((eq notmuch-address-completion-style 'completion-at-point) (notmuch-address-complete-at-point beg end orig)) ((eq notmuch-address-completion-style 'completing-read)=20 (notmuch-address-completing-read beg end orig)) (t nil)))) (t nil))) (provide 'patch-notmuch-address) --=-=-= Content-Type: text/plain Some further cleanup to remove all company stuff from notmuch-address.el would still be needed, though. Looking forward to your thoughts, --alexander --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --=-=-=--