From 02e43f63d80df45d511718587add56cf2f5a5793 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 16 Nov 2012 14:49:54 +1900 Subject: [PATCH] [PATCH v3 3/3] emacs: Buttonize mid: links --- d8/39ee71476112da8c59b9ded7fac2a732c904dd | 168 ++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 d8/39ee71476112da8c59b9ded7fac2a732c904dd diff --git a/d8/39ee71476112da8c59b9ded7fac2a732c904dd b/d8/39ee71476112da8c59b9ded7fac2a732c904dd new file mode 100644 index 000000000..b5287aebd --- /dev/null +++ b/d8/39ee71476112da8c59b9ded7fac2a732c904dd @@ -0,0 +1,168 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id CEE7A431FAE + for ; Thu, 15 Nov 2012 11:50:03 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id YP-eYlCKTEjB for ; + Thu, 15 Nov 2012 11:50:03 -0800 (PST) +Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU + [18.7.68.36]) + by olra.theworths.org (Postfix) with ESMTP id F2033431FAF + for ; Thu, 15 Nov 2012 11:50:02 -0800 (PST) +X-AuditID: 12074424-b7fce6d000000925-91-50a5476a705f +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id CA.1A.02341.A6745A05; Thu, 15 Nov 2012 14:50:02 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAFJo12w000887; + Thu, 15 Nov 2012 14:50:01 -0500 +Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAFJnuZj018788 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 15 Nov 2012 14:49:59 -0500 (EST) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1TZ5Rk-0004YG-Og; Thu, 15 Nov 2012 14:49:56 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v3 3/3] emacs: Buttonize mid: links +Date: Thu, 15 Nov 2012 14:49:54 -0500 +Message-Id: <1353008994-17305-4-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1353008994-17305-1-git-send-email-amdragon@mit.edu> +References: <1353008994-17305-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsUixG6nopvlvjTA4OtZbovrN2cyW7xZOY/V + gcnj8NeFLB7PVt1iDmCK4rJJSc3JLEst0rdL4Mpo2b6esWCfVEX34mmsDYyrRbsYOTkkBEwk + Jvy+ywRhi0lcuLeerYuRi0NIYB+jxJpJC9ghnA2MEn1TLjFCOKeYJPZtvg1VNpdRYmXXQrB+ + NgENiW37lzOC2CIC0hI7785mBbGZBawkDl/dBGYLCxhLnNy9DayeRUBV4vi7V+wgNq+Ag8Sp + j51sEHcoSnQ/mwBmcwo4Shy5NBPMFgKquffxLtsERv4FjAyrGGVTcqt0cxMzc4pTk3WLkxPz + 8lKLdM31cjNL9FJTSjcxgoPJRWUHY/MhpUOMAhyMSjy8J24uDhBiTSwrrsw9xCjJwaQkypto + szRAiC8pP6UyI7E4I76oNCe1+BCjBAezkgivpxxQjjclsbIqtSgfJiXNwaIkzns95aa/kEB6 + YklqdmpqQWoRTFaGg0NJgrfWDahRsCg1PbUiLTOnBCHNxMEJMpwHaDhYDW9xQWJucWY6RP4U + o6KUOK8nSEIAJJFRmgfXC4v2V4ziQK8I88aCVPEAEwVc9yugwUxAg7fILAEZXJKIkJJqYBRc + +TB7/zU+jcuJZd6Jt+59Y97h9y5EepVf+8ILC+pyzwZOMTof3L1nofsbRZZtDx+qSrhp7m3V + W+G/Tr/qjPDnODcH8c4G18r7301Z7obZXy6p5bT7demRXd9ls5OnazY03dp5VbhteptJ+C81 + j26T9TxLfOSWrp0+aYqTgJBu8vcOx+kcF5RYijMSDbWYi4oTAcI0ABzRAgAA +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Thu, 15 Nov 2012 19:50:04 -0000 + +This adds support for RFC 2392 mid: message ID links. +--- + emacs/notmuch-show.el | 45 +++++++++++++++++++++++++++++++++------------ + test/emacs-show | 8 +++++++- + 2 files changed, 40 insertions(+), 13 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 49961fb..5b3e70e 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1014,23 +1014,44 @@ message at DEPTH in the current thread." + "\\)") + "The regexp used to match id: links in messages.") + ++(defvar notmuch-mid-regexp ++ ;; goto-address-url-regexp matched cid: links, which have the same ++ ;; grammar as the message ID part of a mid: link. Construct the ++ ;; regexp using the same technique as goto-address-url-regexp. ++ (concat "\\\"-parts into buttons for +-a corresponding notmuch search." ++This also turns id:\"\"-parts and mid: links into ++buttons for a corresponding notmuch search." + (goto-address-fontify-region start end) + (save-excursion +- (goto-char start) +- (while (re-search-forward notmuch-id-regexp end t) +- ;; remove the overlay created by goto-address-mode +- (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t) +- (make-text-button (match-beginning 0) (match-end 0) +- 'action `(lambda (arg) +- (notmuch-show ,(match-string-no-properties 0))) +- 'follow-link t +- 'help-echo "Mouse-1, RET: search for this message" +- 'face goto-address-mail-face)))) ++ (let (links) ++ (goto-char start) ++ (while (re-search-forward notmuch-id-regexp end t) ++ (push (list (match-beginning 0) (match-end 0) ++ (match-string-no-properties 0)) links)) ++ (goto-char start) ++ (while (re-search-forward notmuch-mid-regexp end t) ++ (let* ((mid-cid (match-string-no-properties 1)) ++ (mid (save-match-data ++ (string-match "^[^/]*" mid-cid) ++ (url-unhex-string (match-string 0 mid-cid))))) ++ (push (list (match-beginning 0) (match-end 0) ++ (notmuch-id-to-query mid)) links))) ++ (dolist (link links) ++ ;; Remove the overlay created by goto-address-mode ++ (remove-overlays (first link) (second link) 'goto-address t) ++ (make-text-button (first link) (second link) ++ 'action `(lambda (arg) ++ (notmuch-show ,(third link))) ++ 'follow-link t ++ 'help-echo "Mouse-1, RET: search for this message" ++ 'face goto-address-mail-face))))) + + ;;;###autoload + (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name) +diff --git a/test/emacs-show b/test/emacs-show +index e2d7c70..ec3be8b 100755 +--- a/test/emacs-show ++++ b/test/emacs-show +@@ -125,7 +125,10 @@ id:\"abc + \" + id:) + id: +-cid:xxx"' ++cid:xxx ++mid:abc mid:abc/def ++mid:abc%20def ++mid:abc. mid:abc, mid:abc;"' + test_emacs '(notmuch-show "id:'$gen_msg_id'") + (notmuch-test-mark-links) + (test-visible-output)' +@@ -153,6 +156,9 @@ id:"abc + id:) + id: + cid:xxx ++<> <> ++<> ++<>. <>, <>; + EOF + test_expect_equal_file OUTPUT EXPECTED + +-- +1.7.10.4 + -- 2.26.2