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 9FF71431FC2 for ; Thu, 22 Aug 2013 23:51:47 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, 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 zzltq7SrSRsC for ; Thu, 22 Aug 2013 23:51:42 -0700 (PDT) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E121A431FAE for ; Thu, 22 Aug 2013 23:51:41 -0700 (PDT) Received: by mail-wg0-f53.google.com with SMTP id c11so183845wgh.32 for ; Thu, 22 Aug 2013 23:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=K9ccgaHX2dCiavz60u1xMMtsNWQM2XCrheoXzBPuZvM=; b=tOp4VXKu+vmIf4H0kLrth+I4fGOgxtki905ZI7JuOuSn/hohWasvaVBRL/a06X0g4J v7I3d7q/5mTWumahnKo3qiC4Mof3fSQ3YXTyP++CPPDGViqMg+hZRR+rDOiALFT4H1o1 Bh1o431tKiYfXOPqSN/98mWSCCpRnSxO39FfdAlTaaf2ZlxF2g0sqrK0gj3/krRgLPpS ro6lP9ProCay4iVgnGeaQcJbqBhKyD/HExRvp+k03tTwdkf4wk6QW5X4hpaoJ3PxmNhR SwIQRSBboHe6f4npTSnSn8O5hG1ahqCoRHF0u0uolVrcJ1t30113HPMlOf8vVof4vlk3 5JZg== X-Received: by 10.180.13.83 with SMTP id f19mr904048wic.54.1377240699303; Thu, 22 Aug 2013 23:51:39 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id ei6sm1436523wid.11.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 22 Aug 2013 23:51:38 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH] make http links into buttons Date: Fri, 23 Aug 2013 07:51:35 +0100 Message-Id: <1377240695-825-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 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: Fri, 23 Aug 2013 06:51:48 -0000 This patch replaces the use of goto-address-fontify-region with our own code doing roughly the same thing. The advantage is that we control how the resulting buttons work. In particular RET on link activates the button (in my case opening it in an external browser) and TAB stops at these links. It finds the urls using the goto-address variable for the regexp so it should make exactly the same links. Caveats and queries: 1) the buttons used now are text buttons rather than overlay "things": this seems to mean some things like fonts get overridden by notmuch-wash (observable in cited regions for example). 2) Email links are also activatable by RET but there are quite a lot of them (eg all addresses in headers) so I make these buttons skippable. Possibly they should not be changed as pressing RET in a show body (to collapse the message) is relatively common so accidentally composing a mail may be irritating. 3) the test for id buttonization in emacs-show fails because some links become buttons. I don't think it is worth updating this until/unless we have some consensus on how this should all work. What do people think? Best wishes Mark --- emacs/notmuch-show.el | 27 ++++++++++++++++++++++++--- 1 files changed, 24 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 82b70ba..8aa56e0 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1080,8 +1080,31 @@ See RFC 2392.") This also turns id:\"\"-parts and mid: links into buttons for a corresponding notmuch search." - (goto-address-fontify-region start end) (save-excursion + ;; Do urls + (goto-char start) + (while (re-search-forward goto-address-url-regexp end t) + (make-text-button (match-beginning 0) (match-end 0) + :type 'notmuch-button-type + 'action #'goto-address-at-point + 'follow-link t + 'help-echo "Mouse-1, RET: open this link in browser" + 'face goto-address-url-face + 'priority 10 + 'mouse-face goto-address-url-mouse-face)) + ;; do email addresses + (goto-char start) + (while (re-search-forward goto-address-mail-regexp end t) + (make-text-button (match-beginning 0) (match-end 0) + :type 'notmuch-button-type + 'action #'goto-address-at-point + 'follow-link t + 'help-echo "Mouse-1, RET: mail this address" + 'face goto-address-mail-face + 'priority 10 + 'skip t ;; don't make tab stop at all email addresses in headers etc + 'mouse-face goto-address-mail-mouse-face)) + ;; Do id: and mid: links (let (links) (goto-char start) (while (re-search-forward notmuch-id-regexp end t) @@ -1096,8 +1119,6 @@ buttons for a corresponding notmuch search." (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) :type 'notmuch-button-type 'action `(lambda (arg) -- 1.7.9.1