[PATCH v2 04/14] cli/reply: unify reply format functions
[notmuch-archives.git] / bb / 4248b07685d04f87def3c370764fba8806c2ec
1 Return-Path: <too@guru-group.fi>\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 72D336DE026C\r
6  for <notmuch@notmuchmail.org>; Sat,  7 May 2016 12:03:28 -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.268\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.268 tagged_above=-999 required=5 tests=[AWL=0.277, \r
12  HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id 7ZdqQH-zzxpg for <notmuch@notmuchmail.org>;\r
17  Sat,  7 May 2016 12:03:18 -0700 (PDT)\r
18 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
19  by arlo.cworth.org (Postfix) with ESMTP id 212856DE00EB\r
20  for <notmuch@notmuchmail.org>; Sat,  7 May 2016 12:03:17 -0700 (PDT)\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
22  id 78216100227; Sat,  7 May 2016 22:03:14 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: notmuch@notmuchmail.org\r
25 Cc: tomi.ollila@iki.fi\r
26 Subject: notmuch-show-message-resend v3\r
27 Date: Sat,  7 May 2016 22:03:10 +0300\r
28 Message-Id: <1462647792-25427-1-git-send-email-tomi.ollila@iki.fi>\r
29 X-Mailer: git-send-email 2.6.4\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.20\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34  <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
36  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Sat, 07 May 2016 19:03:28 -0000\r
43 \r
44 V3 of notmuch-show-message-resend feature\r
45 \r
46 v2: id:1441204482-26509-3-git-send-email-tomi.ollila@iki.fi\r
47 \r
48 id:87pozza0dw.fsf@qmul.ac.uk has been consulted while doing\r
49 these changes (iirc ;)\r
50 \r
51 I tried to get company mode also work while reading email\r
52 addresses from minibuffer -- and got something to function,\r
53 but not anything really working. Therefore this currently\r
54 uses minibuffer (with tab completion) working.\r
55 \r
56 The following diff shows what I tried to do to get it working.\r
57 In addition to work poorly it breaks "normal" address tab\r
58 completion (as it was crafted to work with minibuffer completion\r
59 tests only)\r
60 \r
61 \r
62 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
63 index 7defed3..7a8424e 100644\r
64 --- a/emacs/notmuch-address.el\r
65 +++ b/emacs/notmuch-address.el\r
66 @@ -256,12 +256,11 @@ (defun notmuch-address-from-minibuffer (prompt)\r
67        ;; "Original" minibuffer keymap is restored just before calling\r
68        ;; notmuch-address-expand-name as it may also use minibuffer-local-map\r
69        ;; (completing-read probably does not but if something else is used there).\r
70 -      (define-key rmap (kbd "TAB") (lambda ()\r
71 -                                    (interactive)\r
72 -                                    (let ((enable-recursive-minibuffers t)\r
73 -                                          (minibuffer-local-map omap))\r
74 -                                      (notmuch-address-expand-name))))\r
75 -      (let ((minibuffer-local-map rmap))\r
76 +      (define-key rmap (kbd "TAB") #'company-manual-begin)\r
77 +\r
78 +      (let ((minibuffer-local-map rmap)\r
79 +           (minibuffer-setup-hook minibuffer-setup-hook))\r
80 +       (add-hook 'minibuffer-setup-hook #'notmuch-company-setup)\r
81         (read-string prompt)))))\r
82  \r
83  ;;\r
84 diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el\r
85 index add3161..210175a 100644\r
86 --- a/emacs/notmuch-company.el\r
87 +++ b/emacs/notmuch-company.el\r
88 @@ -45,7 +45,7 @@ (defvar notmuch-address-completion-headers-regexp)\r
89  \r
90  ;;;###autoload\r
91  (defun notmuch-company-setup ()\r
92 -  (company-mode)\r
93 +  (company-mode 1)\r
94    (make-local-variable 'company-backends)\r
95    (setq company-backends '(notmuch-company)))\r
96  \r
97 @@ -58,10 +58,7 @@ (defun notmuch-company (command &optional arg &rest _ignore)\r
98         (completion-ignore-case t))\r
99      (case command\r
100        (interactive (company-begin-backend 'notmuch-company))\r
101 -      (prefix (and (derived-mode-p 'message-mode)\r
102 -                  (looking-back (concat notmuch-address-completion-headers-regexp ".*")\r
103 -                                (line-beginning-position))\r
104 -                  (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1 (point-at-bol)))))\r
105 +      (prefix (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1)))\r
106        (candidates (cond\r
107                    (notmuch-address-full-harvest-finished\r
108                     ;; Update harvested addressed from time to time\r
109 @@ -82,5 +79,15 @@ (defun notmuch-company (command &optional arg &rest _ignore)\r
110                0))\r
111        (no-cache t))))\r
112  \r
113 +;; (partial) code snipped someone(tm) doing some company-minubuffer stuff\r
114 +;; (defun company--posn-col-row (posn)\r
115 +;;     (let ((col (car (posn-col-row posn)))\r
116 +;;           ;; `posn-col-row' doesn't work well with lines of different height.\r
117 +;;           ;; `posn-actual-col-row' doesn't handle multiple-width characters.\r
118 +;;           (row (cdr (posn-actual-col-row posn))))\r
119 +;;       (when (and header-line-format (version< emacs-version "24.3.93.3"))\r
120 +;;         ;; http://debbugs.gnu.org/18384\r
121 +;;         (cl-decf row))\r
122 +;;       (cons (+ col (window-hscroll) company-col-offset) (+ row company-row-offset))))\r
123  \r
124  (provide 'notmuch-company)\r
125 -- \r
126 1.9.3\r
127 \r
128 \r