[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 07 / a589aff47952fc6971b51f4a41392db68c3bec
1 Return-Path: <sojkam1@fel.cvut.cz>\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 196096DE0244\r
6  for <notmuch@notmuchmail.org>; Mon, 21 Dec 2015 01:50:19 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.209\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.209 tagged_above=-999 required=5 tests=[AWL=1.641,\r
12   RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-0.55] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id W55gUB2-nRaA for <notmuch@notmuchmail.org>;\r
16  Mon, 21 Dec 2015 01:50:16 -0800 (PST)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 4F74B6DE0BF6\r
19  for <notmuch@notmuchmail.org>; Mon, 21 Dec 2015 01:50:16 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21  by max.feld.cvut.cz (Postfix) with ESMTP id 9E3D019F41EC\r
22  for <notmuch@notmuchmail.org>; Mon, 21 Dec 2015 10:41:34 +0100 (CET)\r
23 X-Virus-Scanned: IMAP STYX AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25  by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, port 10044)\r
26  with ESMTP id 77BayyHw4VNk for <notmuch@notmuchmail.org>;\r
27  Mon, 21 Dec 2015 10:41:32 +0100 (CET)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29  by max.feld.cvut.cz (Postfix) with ESMTP id B8DD819F43F9\r
30  for <notmuch@notmuchmail.org>; Mon, 21 Dec 2015 10:41:32 +0100 (CET)\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.86)\r
32  (envelope-from <sojkam1@fel.cvut.cz>)\r
33  id 1aAwyB-0000Yo-5i; Mon, 21 Dec 2015 10:41:31 +0100\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v2] emacs: Improve notmuch-message-mode initialization\r
37 Date: Mon, 21 Dec 2015 10:41:15 +0100\r
38 Message-Id: <1450690875-2111-2-git-send-email-sojkam1@fel.cvut.cz>\r
39 X-Mailer: git-send-email 2.6.4\r
40 In-Reply-To: <1450690875-2111-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 References: <1450690875-2111-1-git-send-email-sojkam1@fel.cvut.cz>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.20\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46  <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
48  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
53  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Mon, 21 Dec 2015 09:50:19 -0000\r
55 \r
56 Recent addition of notmuch-message-mode introduced several problems:\r
57 \r
58 1. When message-setup-hook is used to set buffer local variables,\r
59    these settings are not effective, because all buffer local\r
60    variables are immediately erased by notmuch-message-mode\r
61    initialization.\r
62 \r
63 2. message-mode-hook gets invoked twice - first when message-mail\r
64    invokes message-mode and second when notmuch-mua-mail invokes\r
65    notmuch-message-mode.\r
66 \r
67 This commit fixes these problems by replacing a call to message-mail\r
68 with notmuch-specific code that is (hopefully) equivalent to\r
69 message-mail functionality before introduction of\r
70 notmuch-message-mode.\r
71 \r
72 We first initialize notmuch-message-mode with\r
73 notmuch-mua-pop-to-buffer, which is a modified version of\r
74 message-pop-to-buffer and then call message-setup-1, which is the only\r
75 functionality of message-mail that is needed for notmuch.\r
76 ---\r
77  emacs/notmuch-mua.el | 49 +++++++++++++++++++++++++++++++++++++++++++------\r
78  1 file changed, 43 insertions(+), 6 deletions(-)\r
79 \r
80 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
81 index 466edd7..a66a306 100644\r
82 --- a/emacs/notmuch-mua.el\r
83 +++ b/emacs/notmuch-mua.el\r
84 @@ -278,10 +278,36 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
85  (define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)\r
86  (define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)\r
87  \r
88 -(defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)\r
89 -  "Invoke the notmuch mail composition window.\r
90 -\r
91 -OTHER-ARGS are passed through to `message-mail'."\r
92 +(defun notmuch-mua-pop-to-buffer (name)\r
93 +  "Pop to buffer NAME, and warn if it already exists and is\r
94 +modified. This function is notmuch addaptation of\r
95 +`message-pop-to-buffer'."\r
96 +  (let ((buffer (get-buffer name)))\r
97 +    (if (and buffer\r
98 +            (buffer-name buffer))\r
99 +       (let ((window (get-buffer-window buffer 0)))\r
100 +         (if window\r
101 +             ;; Raise the frame already displaying the message buffer.\r
102 +             (progn\r
103 +               (gnus-select-frame-set-input-focus (window-frame window))\r
104 +               (select-window window))\r
105 +           (funcall (notmuch-mua-get-switch-function) buffer)\r
106 +           (set-buffer buffer))\r
107 +         (when (and (buffer-modified-p)\r
108 +                    (not (prog1\r
109 +                             (y-or-n-p\r
110 +                              "Message already being composed; erase? ")\r
111 +                           (message nil))))\r
112 +           (error "Message being composed")))\r
113 +      (funcall (notmuch-mua-get-switch-function) name)\r
114 +      (set-buffer name))\r
115 +    (erase-buffer)\r
116 +    (notmuch-message-mode)))\r
117 +\r
118 +(defun notmuch-mua-mail (&optional to subject other-headers continue\r
119 +                                  switch-function yank-action send-actions\r
120 +                                  return-action &rest ignored)\r
121 +  "Invoke the notmuch mail composition window."\r
122    (interactive)\r
123  \r
124    (when notmuch-mua-user-agent-function\r
125 @@ -293,8 +319,19 @@ OTHER-ARGS are passed through to `message-mail'."\r
126      (push (cons 'From (concat\r
127                        (notmuch-user-name) " <" (notmuch-user-primary-email) ">")) other-headers))\r
128  \r
129 -  (apply #'message-mail to subject other-headers other-args)\r
130 -  (notmuch-message-mode)\r
131 +  (notmuch-mua-pop-to-buffer (message-buffer-name "mail" to))\r
132 +  (message-setup-1\r
133 +   ;; The following sexp is copied from `message-mail'\r
134 +   (nconc\r
135 +    `((To . ,(or to "")) (Subject . ,(or subject "")))\r
136 +    ;; C-h f compose-mail says that headers should be specified as\r
137 +    ;; (string . value); however all the rest of message expects\r
138 +    ;; headers to be symbols, not strings (eg message-header-format-alist).\r
139 +    ;; http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00337.html\r
140 +    ;; We need to convert any string input, eg from rmail-start-mail.\r
141 +    (dolist (h other-headers other-headers)\r
142 +      (if (stringp (car h)) (setcar h (intern (capitalize (car h)))))))\r
143 +   yank-action send-actions return-action)\r
144    (notmuch-fcc-header-setup)\r
145    (message-sort-headers)\r
146    (message-hide-headers)\r
147 -- \r
148 2.6.4\r
149 \r