Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A5B3A6DE0E46 for ; Fri, 12 Aug 2016 13:04:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.349 X-Spam-Level: X-Spam-Status: No, score=-0.349 tagged_above=-999 required=5 tests=[AWL=0.221, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yQrIBQlDm6-k for ; Fri, 12 Aug 2016 13:04:10 -0700 (PDT) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 78A786DE0C7E for ; Fri, 12 Aug 2016 13:04:10 -0700 (PDT) Received: by mail-wm0-f68.google.com with SMTP id i138so4798759wmf.3 for ; Fri, 12 Aug 2016 13:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=GZr3F6sGwtqRFy5RPA4xul78VRDsp874PDpb7OzI1Dk=; b=N8I9w35B//Lb38RaM16UTZf7bsBNbknXdSlLsCuxvpIo/csKk9H1HBWXFAvY4cxZ+M wp53rYQAsE1NF7ws+9cCkmdsvm0qe971EUtHuu44GykTcgeWTvLVmTRz6J70ndkXCRcb 2ZiSDtjTmk15O9MIXxohr+wqs8cCooJH7OvI8p0QdJz5pQfKZBfmXZndvfhRmdHWmCS/ MDsJQmV7LJfaPLdhl4dqVV8ZC0QJc8y1XvMLhNCxU9GoFulyy0XZFxL4L0rMD+LnoLXf JJlQXvmzU690o+4SGJ2x81CnX47sVHOsVF/3I/vuN//Ow9aiXLkEu1dWxdmIUAaubtoJ NO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GZr3F6sGwtqRFy5RPA4xul78VRDsp874PDpb7OzI1Dk=; b=hMqqKZb3cr6pu6GpilQw49J3t3CY2NGwBJSWxyo9K+ryukn9b0Sylt7Fb4Yoi1bwvs ctJOIMzzUs1Ic97Ejj6KSRh36oyS8KalaBmbV7J+zXkJ2oJOLcJaNPbUIAIwRJV4uKGS d15zzsJCTdEsSpI4K7/N9uWYSY2jX0pywxf5hGgwWdne1498ZqBkTiIfBDVjSravcQUu 2r/OUey4pVCqyPSH94glecp/wwtfI4UI/2DDpYujJP0fJB+z7VWraF3LtXRv0N39NB8w bEUF8KCXw/ldJD6MBV0012/DF4nsrkFZVD4NR7VMiA5wYCnIF7pK9jZL+lyd/zPIhLbw I4Qg== X-Gm-Message-State: AEkoouuEP5kti+ObZqbAo/nDy6ObuFdWReP5zK3JyeJwXvWZGrFNeLrEZRnsVo9uNv8rJg== X-Received: by 10.194.127.37 with SMTP id nd5mr17236105wjb.156.1471032248456; Fri, 12 Aug 2016 13:04:08 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by smtp.gmail.com with ESMTPSA id pm1sm8913234wjb.40.2016.08.12.13.04.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Aug 2016 13:04:07 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [WIP PATCH] emacs: query: completion for from: in searches Date: Fri, 12 Aug 2016 21:04:02 +0100 Message-Id: <1471032242-4701-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 2.1.4 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 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 Aug 2016 20:04:18 -0000 This is a first attempt at tab completion for from: searches --- This sort of works (well it works but maybe in unexpected ways!) At the moment it completes to any word (as delimited by whitespace) in any address stored in the address hashmap. It does not trigger the address harvesting itself -- you either need to call notmuch-address-harvest-trigger manually, or use address completion when sending a mail first, and the harvest needs to finish before this will work. Since the hashmap does some address deduplication this will not give perfect completion (there may be names in your database it won't complete to). Also completion is case-sensitive. Getting a perfect solution may be more effort than its worth -- this will probably demonstrate whether something like this suffices. Best wishes Mark emacs/notmuch.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 8acdef3..532f7b3 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -888,10 +888,20 @@ PROMPT is the string to prompt with." ;; this ugly regexp is used to get the last word of the input ;; possibly preceded by a '(' ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string) - (mapcar (lambda (compl) - (concat (match-string-no-properties 1 string) compl)) - (all-completions (match-string-no-properties 2 string) - completions))) + (let ((last-word (match-string-no-properties 2 string)) + (start-string (match-string-no-properties 1 string))) + (if (and notmuch-address-full-harvest-finished + (string-match "^from:\\(.*\\)" last-word)) + (let ((from-completions (notmuch-address-matching (match-string 1 last-word)))) + (apply #'append + (mapcar (lambda (name-addr) + (mapcar (lambda (compl) + (concat start-string "from:" compl)) + (split-string name-addr "[ <>]" t))) + from-completions))) + (mapcar (lambda (compl) + (concat start-string compl)) + (all-completions last-word completions))))) (t (list string))))))) ;; this was simpler than convincing completing-read to accept spaces: (define-key keymap (kbd "TAB") 'minibuffer-complete) -- 2.1.4