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 4736D431FAF for ; Sat, 10 Nov 2012 20:46:28 -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 rTlO0hGBdfEr for ; Sat, 10 Nov 2012 20:46:27 -0800 (PST) Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id 095B0431FBD for ; Sat, 10 Nov 2012 20:46:26 -0800 (PST) X-AuditID: 1209190e-b7f756d000000904-88-509f2da23010 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 9D.98.02308.2AD2F905; Sat, 10 Nov 2012 23:46:26 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qAB4kOLG025911; Sat, 10 Nov 2012 23:46:24 -0500 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAB4kJc5001919 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 10 Nov 2012 23:46:21 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1TXPR5-0003a7-Or; Sat, 10 Nov 2012 23:46:19 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 3/3] emacs: Buttonize mid: links Date: Sat, 10 Nov 2012 23:46:15 -0500 Message-Id: <1352609175-12790-4-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1352609175-12790-1-git-send-email-amdragon@mit.edu> References: <1352609175-12790-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixG6nrrtId36AweUJUhZN050trt+cyWzR 2veUxYHZ49b91+wez1bdYvbY+PcHSwBzFJdNSmpOZllqkb5dAlfGprntbAX7pCqW757M1sC4 WrSLkZNDQsBE4vHKxewQtpjEhXvr2boYuTiEBPYxSjw4eZMFwtnAKLF1zl9mCOcRk8TmO8+g yuYySmw/sJEZpJ9NQENi2/7ljCC2iIC0xM67s1lBbGaBVInVOzvAaoQFjCW27gCp5+BgEVCV 6N6iAxLmFXCQuNl0mhniDEWJ7mcT2EBsTgFHif4Zf8BGCgHVnPnxnnkCI/8CRoZVjLIpuVW6 uYmZOcWpybrFyYl5ealFusZ6uZkleqkppZsYQcHFKcm3g/HrQaVDjAIcjEo8vDfezAsQYk0s K67MPcQoycGkJMqbrDM/QIgvKT+lMiOxOCO+qDQntfgQowQHs5IIb+0OoHLelMTKqtSifJiU NAeLkjjvlZSb/kIC6YklqdmpqQWpRTBZGQ4OJQne6SBDBYtS01Mr0jJzShDSTBycIMN5gIY/ 0gKq4S0uSMwtzkyHyJ9iVJQS5+XQBkoIgCQySvPgemHR/4pRHOgVYd6TICt4gIkDrvsV0GAm oMGNR+aADC5JREhJNTC6tFUym64/+MjYqC+lP/ryL7+FKvP+mF/9+7rgaZyG+C7mbe0nPspH JB0+4cpskKrVOO87v5HcFivBf57qLnpfL1f9MZ/n63Et+TNH556nb5/HXzWJV9M2UD8h/VTm ptvB1RVHjSYceTb53+6Px9TKJd9n1tm4Fm7Y7/Vfe0q6Widr1mShIwFKLMUZiYZazEXFiQCY z6sX2QIAAA== Cc: sascha-ml-reply-to-2012-4@silbe.org 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: Sun, 11 Nov 2012 04:46:28 -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 8944e73..91706ea 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 EXPECTED OUTPUT -- 1.7.10.4