Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / c9 / 8fd02ff4dab728b29b922bbd301587c0330d83
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id A5B3A6DE0E46\r
6  for <notmuch@notmuchmail.org>; Fri, 12 Aug 2016 13:04:18 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.349\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.349 tagged_above=-999 required=5 tests=[AWL=0.221,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id yQrIBQlDm6-k for <notmuch@notmuchmail.org>;\r
19  Fri, 12 Aug 2016 13:04:10 -0700 (PDT)\r
20 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
21  [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 78A786DE0C7E for\r
22  <notmuch@notmuchmail.org>; Fri, 12 Aug 2016 13:04:10 -0700 (PDT)\r
23 Received: by mail-wm0-f68.google.com with SMTP id i138so4798759wmf.3\r
24  for <notmuch@notmuchmail.org>; Fri, 12 Aug 2016 13:04:10 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id;\r
27  bh=GZr3F6sGwtqRFy5RPA4xul78VRDsp874PDpb7OzI1Dk=;\r
28  b=N8I9w35B//Lb38RaM16UTZf7bsBNbknXdSlLsCuxvpIo/csKk9H1HBWXFAvY4cxZ+M\r
29  wp53rYQAsE1NF7ws+9cCkmdsvm0qe971EUtHuu44GykTcgeWTvLVmTRz6J70ndkXCRcb\r
30  2ZiSDtjTmk15O9MIXxohr+wqs8cCooJH7OvI8p0QdJz5pQfKZBfmXZndvfhRmdHWmCS/\r
31  MDsJQmV7LJfaPLdhl4dqVV8ZC0QJc8y1XvMLhNCxU9GoFulyy0XZFxL4L0rMD+LnoLXf\r
32  JJlQXvmzU690o+4SGJ2x81CnX47sVHOsVF/3I/vuN//Ow9aiXLkEu1dWxdmIUAaubtoJ\r
33  NO/Q==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
37  bh=GZr3F6sGwtqRFy5RPA4xul78VRDsp874PDpb7OzI1Dk=;\r
38  b=hMqqKZb3cr6pu6GpilQw49J3t3CY2NGwBJSWxyo9K+ryukn9b0Sylt7Fb4Yoi1bwvs\r
39  ctJOIMzzUs1Ic97Ejj6KSRh36oyS8KalaBmbV7J+zXkJ2oJOLcJaNPbUIAIwRJV4uKGS\r
40  d15zzsJCTdEsSpI4K7/N9uWYSY2jX0pywxf5hGgwWdne1498ZqBkTiIfBDVjSravcQUu\r
41  2r/OUey4pVCqyPSH94glecp/wwtfI4UI/2DDpYujJP0fJB+z7VWraF3LtXRv0N39NB8w\r
42  bEUF8KCXw/ldJD6MBV0012/DF4nsrkFZVD4NR7VMiA5wYCnIF7pK9jZL+lyd/zPIhLbw\r
43  I4Qg==\r
44 X-Gm-Message-State:\r
45  AEkoouuEP5kti+ObZqbAo/nDy6ObuFdWReP5zK3JyeJwXvWZGrFNeLrEZRnsVo9uNv8rJg==\r
46 X-Received: by 10.194.127.37 with SMTP id nd5mr17236105wjb.156.1471032248456; \r
47  Fri, 12 Aug 2016 13:04:08 -0700 (PDT)\r
48 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
49  by smtp.gmail.com with ESMTPSA id pm1sm8913234wjb.40.2016.08.12.13.04.07\r
50  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
51  Fri, 12 Aug 2016 13:04:07 -0700 (PDT)\r
52 From: Mark Walters <markwalters1009@gmail.com>\r
53 To: notmuch@notmuchmail.org\r
54 Subject: [WIP PATCH] emacs: query: completion for from: in searches\r
55 Date: Fri, 12 Aug 2016 21:04:02 +0100\r
56 Message-Id: <1471032242-4701-1-git-send-email-markwalters1009@gmail.com>\r
57 X-Mailer: git-send-email 2.1.4\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.20\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62  <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
64  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
69  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Fri, 12 Aug 2016 20:04:18 -0000\r
71 \r
72 This is a first attempt at tab completion for from: searches\r
73 ---\r
74 \r
75 This sort of works (well it works but maybe in unexpected ways!)\r
76 \r
77 At the moment it completes to any word (as delimited by whitespace) in\r
78 any address stored in the address hashmap. It does not trigger the\r
79 address harvesting itself -- you either need to call\r
80 notmuch-address-harvest-trigger manually, or use address completion\r
81 when sending a mail first, and the harvest needs to finish before this\r
82 will work.\r
83 \r
84 Since the hashmap does some address deduplication this will not give\r
85 perfect completion (there may be names in your database it won't\r
86 complete to). Also completion is case-sensitive.\r
87 \r
88 Getting a perfect solution may be more effort than its worth -- this\r
89 will probably demonstrate whether something like this suffices.\r
90 \r
91 Best wishes\r
92 \r
93 Mark \r
94 \r
95 emacs/notmuch.el | 18 ++++++++++++++----\r
96  1 file changed, 14 insertions(+), 4 deletions(-)\r
97 \r
98 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
99 index 8acdef3..532f7b3 100644\r
100 --- a/emacs/notmuch.el\r
101 +++ b/emacs/notmuch.el\r
102 @@ -888,10 +888,20 @@ PROMPT is the string to prompt with."\r
103                ;; this ugly regexp is used to get the last word of the input\r
104                ;; possibly preceded by a '('\r
105                ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string)\r
106 -               (mapcar (lambda (compl)\r
107 -                         (concat (match-string-no-properties 1 string) compl))\r
108 -                       (all-completions (match-string-no-properties 2 string)\r
109 -                                        completions)))\r
110 +               (let ((last-word (match-string-no-properties 2 string))\r
111 +                     (start-string (match-string-no-properties 1 string)))\r
112 +                 (if (and notmuch-address-full-harvest-finished\r
113 +                          (string-match "^from:\\(.*\\)" last-word))\r
114 +                     (let ((from-completions (notmuch-address-matching (match-string 1 last-word))))\r
115 +                       (apply #'append\r
116 +                              (mapcar (lambda (name-addr)\r
117 +                                        (mapcar (lambda (compl)\r
118 +                                                  (concat start-string "from:" compl))\r
119 +                                                (split-string name-addr "[ <>]" t)))\r
120 +                                      from-completions)))\r
121 +                   (mapcar (lambda (compl)\r
122 +                             (concat start-string compl))\r
123 +                           (all-completions last-word completions)))))\r
124                (t (list string)))))))\r
125        ;; this was simpler than convincing completing-read to accept spaces:\r
126        (define-key keymap (kbd "TAB") 'minibuffer-complete)\r
127 -- \r
128 2.1.4\r
129 \r