From: Lele Gaifax Date: Fri, 12 Dec 2014 08:22:56 +0000 (+0100) Subject: Address completion in Emacs X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=852671503812de9022bc1022c5a6b7b4de7e01ea;p=notmuch-archives.git Address completion in Emacs --- diff --git a/5b/e7f89c4188a13c9895913bb95256efbe5c2982 b/5b/e7f89c4188a13c9895913bb95256efbe5c2982 new file mode 100644 index 000000000..f1a77cf2b --- /dev/null +++ b/5b/e7f89c4188a13c9895913bb95256efbe5c2982 @@ -0,0 +1,115 @@ +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 248CB431FD5 + for ; Fri, 12 Dec 2014 00:23:22 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.165 +X-Spam-Level: +X-Spam-Status: No, score=0.165 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7, RCVD_NUMERIC_HELO=0.865] + 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 s7AHWpV59RwF for ; + Fri, 12 Dec 2014 00:23:17 -0800 (PST) +Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) + (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3AE39431FBF + for ; Fri, 12 Dec 2014 00:23:17 -0800 (PST) +Received: from list by plane.gmane.org with local (Exim 4.69) + (envelope-from ) id 1XzLVG-0006HW-1o + for notmuch@notmuchmail.org; Fri, 12 Dec 2014 09:23:10 +0100 +Received: from 151.62.31.98 ([151.62.31.98]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 12 Dec 2014 09:23:10 +0100 +Received: from lele by 151.62.31.98 with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 12 Dec 2014 09:23:10 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: notmuch@notmuchmail.org +From: Lele Gaifax +Subject: Address completion in Emacs +Date: Fri, 12 Dec 2014 09:22:56 +0100 +Organization: Nautilus Entertainments +Lines: 53 +Message-ID: <87d27p9t0f.fsf@nautilus.nautilus> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@ger.gmane.org +X-Gmane-NNTP-Posting-Host: 151.62.31.98 +User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) +Cancel-Lock: sha1:mMXYnqq7nIW1l9FgR7YMwrQTE8E= +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 08:23:22 -0000 + +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-input) + "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? + +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? + +Thanks in advance for any clarification, +ciao, lele. +-- +nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri +real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. +lele@metapensiero.it | -- Fortunato Depero, 1929. +