From 0ad9edccf08b1acdc5895216b454431a733dc50a Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Fri, 12 Dec 2014 12:14:37 +0000 Subject: [PATCH] Re: Address completion in Emacs --- cc/dfb63a9c0853c1422160b3ed8ae63d14c81253 | 139 ++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 cc/dfb63a9c0853c1422160b3ed8ae63d14c81253 diff --git a/cc/dfb63a9c0853c1422160b3ed8ae63d14c81253 b/cc/dfb63a9c0853c1422160b3ed8ae63d14c81253 new file mode 100644 index 000000000..6b65813aa --- /dev/null +++ b/cc/dfb63a9c0853c1422160b3ed8ae63d14c81253 @@ -0,0 +1,139 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 172E5431FBF + for ; Fri, 12 Dec 2014 04:15:09 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.699 +X-Spam-Level: +X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id hdCSfxjzEakX for ; + Fri, 12 Dec 2014 04:14:41 -0800 (PST) +Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com + [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 92B3E431FBC + for ; Fri, 12 Dec 2014 04:14:41 -0800 (PST) +Received: by mail-wi0-f174.google.com with SMTP id h11so2278313wiw.13 + for ; Fri, 12 Dec 2014 04:14:40 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:user-agent:to:subject:in-reply-to:references + :from:date:message-id:mime-version:content-type + :content-transfer-encoding; + bh=JOGb0u413mLYj9cnvbUtG3S8Aa9y1N3MK9JOXgF9QdY=; + b=ZyHrqtH0HysXE+J5g/TpR5BXWuWhKIpxar5WTz3fY2LWCB+ZV4Qis9L94piV+C3Vn8 + UYfXeOaqYq2zitO7wv9cP03QFa4RSAEXgxR6VSnxmRed2msqA+SJO/xUsHbwBx1FbvzQ + 6bDboguM0+IBWsttN70c5hIVwSEBWDTqNzOn32J6nyuKvN594B/FCpEYWu+u7CWnFsfK + NMZY0HYPPIz7+R/MxYZFgLsYrjiEjA2DKIccszO+OvoLNHZwiuUcGqpwmEtgB1sAvRui + wLY3Mk7JaKMFhCDtGbWUvI9LiLKfBXyIp/OURouuE62D4l+0t0M40FLS1SgDk4FauTtO + DICQ== +X-Gm-Message-State: + ALoCoQkAiXrmgFTM8znagNDIk3lRgjnA36KGjTEfu28ldWhmjFh0olHuBX4TSYp/gvDP2yltNNC0 +X-Received: by 10.180.104.197 with SMTP id gg5mr7176768wib.7.1418386479203; + Fri, 12 Dec 2014 04:14:39 -0800 (PST) +Received: from disaster-area.hh.sledj.net + ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) + by mx.google.com with ESMTPSA id ef1sm1748684wic.0.2014.12.12.04.14.38 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 12 Dec 2014 04:14:38 -0800 (PST) +Received: from localhost (30000@localhost [local]); + by localhost (OpenSMTPD) with ESMTPA id e15c7be9; + Fri, 12 Dec 2014 12:14:37 +0000 (UTC) +User-Agent: OpenSMTPD enqueuer (Demoostik) +To: Lele Gaifax , notmuch@notmuchmail.org +Subject: Re: Address completion in Emacs +In-Reply-To: <87d27p9t0f.fsf@nautilus.nautilus> +References: <87d27p9t0f.fsf@nautilus.nautilus> +From: David Edmondson +Date: Fri, 12 Dec 2014 12:14:37 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 12 Dec 2014 12:15:09 -0000 + +On Fri, Dec 12 2014, Lele Gaifax wrote: +> Hi all, +> +> Yesterday I tweaked my Emacs configuration to use "ido-completing-read" +> to select the right address in the minibuffer, and noticed what seems a +> glitch in the related code. +> +> To accomplish the goal, I implemented my own selection function +> +> (defun esk-notmuch-address-selection-function (prompt addresses first) +> "Use `ido-completing-read' to select one of the addresses." +> (ido-completing-read prompt (cons first addresses) +> nil nil nil 'notmuch-address-history)) +> +> and then assigned it to `notmuch-address-selection-function': +> +> (setq notmuch-address-selection-function 'esk-notmuch-address-selection= +-function) +> +> As you can see, I had to `cons' the two arguments, because the caller of +> that function does something similar to the following (where `orig' is +> the text entered before TAB-completion): +> +> (options (notmuch-address-options orig)) +> (num-options (length options)) +> (chosen (funcall notmuch-address-selection-function +> (format "Address (%s matches): " num-options) +> (cdr options) (car options))) +> +> and the standard `notmuch-address-selection-function' is defined like: +> +> (defun notmuch-address-selection-function (prompt collection initial-in= +put) +> "Call (`completing-read' +> PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)" +> (completing-read +> prompt collection nil nil initial-input 'notmuch-address-history)) +> +> where that `initial-input' is not what I initially thought, the text +> entered by the user, but rather the first completion candidate. +> +> Wouldn't it be more "correct" to pass the unchanged `options' list and +> the "real" `orig' text as `initial-input' to the customizable function +> instead? + +Would I then have to press TAB twice to get the first result? + +> I understand that it may be undesiderable to break existing +> configurations by rectifying the arguments in that way, and in such case +> could we change the `initial-input' argument name to better reflect the +> fact that it actually contains one possible candidate instead? + +>From the perspective of `notmuch-address-selection-function', it _is_ +the `initial-input', as that is what is presented to the user. + +> Thanks in advance for any clarification, +> ciao, lele. +> --=20 +> nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri +> real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. +> lele@metapensiero.it | -- Fortunato Depero, 1929. +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2