[PATCH 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / 38 / 886282539110f55898c4f28a0fa053b9fd3329
1 Return-Path: <daniel.schoepe@googlemail.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 olra.theworths.org (Postfix) with ESMTP id 6D2A8431FD0\r
6         for <notmuch@notmuchmail.org>; Tue,  5 Jul 2011 13:12:54 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id YIdMP21aVI9a for <notmuch@notmuchmail.org>;\r
17         Tue,  5 Jul 2011 13:12:53 -0700 (PDT)\r
18 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com\r
19         [209.85.161.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 8E8FA431FB6\r
22         for <notmuch@notmuchmail.org>; Tue,  5 Jul 2011 13:12:53 -0700 (PDT)\r
23 Received: by fxh19 with SMTP id 19so6441358fxh.19\r
24         for <notmuch@notmuchmail.org>; Tue, 05 Jul 2011 13:12:52 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=googlemail.com; s=gamma;\r
27         h=from:to:cc:subject:date:message-id:x-mailer;\r
28         bh=7HnxWETjFrRXs/iWtJJVHglwJGrYzkVENLjcLnCueXE=;\r
29         b=xnQxEhyqLa2aS/b8Vf8MzY/3p0IiEBJYEcgiBQFlv/LlCMGJxGevsOs+FOYG1pjGwf\r
30         lvJJAugscTfkLP+SeY+gQ98CJ8Lz0g9vKPDM43XfANqfP5mJJcD/93g1QIjYVyt6Wta8\r
31         Fn3c4KvkuTdNXvBS/Q3d5Grgv4xGT+GlniwTw=\r
32 Received: by 10.223.93.196 with SMTP id w4mr2268956fam.44.1309896772166;\r
33         Tue, 05 Jul 2011 13:12:52 -0700 (PDT)\r
34 Received: from localhost (dslb-178-004-223-219.pools.arcor-ip.net\r
35         [178.4.223.219])\r
36         by mx.google.com with ESMTPS id j23sm1148129fai.39.2011.07.05.13.12.49\r
37         (version=TLSv1/SSLv3 cipher=OTHER);\r
38         Tue, 05 Jul 2011 13:12:50 -0700 (PDT)\r
39 From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
40 To: notmuch@notmuchmail.org\r
41 Subject: [PATCH] emacs: Turn id:"<message-id>" elements into buttons for\r
42         notmuch searches\r
43 Date: Tue,  5 Jul 2011 22:12:40 +0200\r
44 Message-Id: <1309896760-378-1-git-send-email-daniel.schoepe@googlemail.com>\r
45 X-Mailer: git-send-email 1.7.5.4\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Tue, 05 Jul 2011 20:12:54 -0000\r
59 \r
60 This fixes the minor annoyance that message ids were parsed as mail\r
61 addresses by goto-address-mode in notmuch-show buffers.\r
62 ---\r
63  emacs/notmuch-show.el |   23 ++++++++++++++++++++---\r
64  1 files changed, 20 insertions(+), 3 deletions(-)\r
65 \r
66 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
67 index f96743b..0f7fcfe 100644\r
68 --- a/emacs/notmuch-show.el\r
69 +++ b/emacs/notmuch-show.el\r
70 @@ -778,6 +778,24 @@ current buffer, if possible."\r
71  (defvar notmuch-show-parent-buffer nil)\r
72  (make-variable-buffer-local 'notmuch-show-parent-buffer)\r
73  \r
74 +(defun notmuch-show-buttonise-links (start end)\r
75 +  "Buttonise URLs and mail addresses between START and END.\r
76 +\r
77 +This also turns id:\"<message id>\"-parts into buttons for\r
78 +a corresponding notmuch search."\r
79 +  (goto-address-fontify-region start end)\r
80 +  (save-excursion\r
81 +    (goto-char start)\r
82 +    (while (re-search-forward "id:\"[^ ]+\"" end t)\r
83 +      ;; remove the overlay created by goto-address-mode\r
84 +      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)\r
85 +      (make-text-button (match-beginning 0) (match-end 0)\r
86 +                       'action `(lambda (arg)\r
87 +                                  (notmuch-search ,(match-string-no-properties 0)))\r
88 +                       'follow-link t\r
89 +                       'help-echo "Mouse-1, RET: search for this message"\r
90 +                       'face goto-address-mail-face))))\r
91 +\r
92  ;;;###autoload\r
93  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)\r
94    "Run \"notmuch show\" with the given thread ID and display results.\r
95 @@ -822,9 +840,8 @@ function is used. "\r
96           (notmuch-show-insert-forest\r
97            (notmuch-query-get-threads basic-args))))\r
98  \r
99 -      ;; Enable buttonisation of URLs and email addresses in the\r
100 -      ;; buffer.\r
101 -      (goto-address-mode t)\r
102 +      (jit-lock-register #'notmuch-show-buttonise-links)\r
103 +\r
104        ;; Act on visual lines rather than logical lines.\r
105        (visual-line-mode t)\r
106  \r
107 -- \r
108 1.7.5.4\r
109 \r