From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D8A28429E21 for ; Fri, 28 Oct 2011 07:49:59 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.8 X-Spam-Level: X-Spam-Status: No, score=-0.8 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, 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 cU++a6a1bOQG for ; Fri, 28 Oct 2011 07:49:59 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 253D0431FB6 for ; Fri, 28 Oct 2011 07:49:59 -0700 (PDT) Received: by faai28 with SMTP id i28so4080599faa.26 for ; Fri, 28 Oct 2011 07:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schoepe.org; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=3lWA5wATsBizSqOVY6Z5+b3hXjVUIZhtgzGuWjF1pnw=; b=NdmZ+gfLOmp7y5CDFoxsjAl3v4d6N/nqryGIC5WMH5R1qwaags39mHcVvQ6Fa0j4kQ DdYwZS/dmUSgVFEVLnsQDz8QetA/ShRwsOLxDtnQvFyRP3+5Ew6GeMCUMTA1Wgcc/Yjq Qo6lpc5XbD6DuLx2YjKJq0rx8M7uhVfpf6SPk= Received: by 10.223.17.23 with SMTP id q23mr6616687faa.11.1319813398003; Fri, 28 Oct 2011 07:49:58 -0700 (PDT) Received: from localhost (dslb-178-004-064-120.pools.arcor-ip.net. [178.4.64.120]) by mx.google.com with ESMTPS id a21sm17727336fao.18.2011.10.28.07.49.55 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Oct 2011 07:49:56 -0700 (PDT) From: Daniel Schoepe To: notmuch@notmuchmail.org Subject: [PATCH v3] emacs: Turn id:"" elements into buttons for notmuch searches Date: Fri, 28 Oct 2011 16:48:58 +0200 Message-Id: <1319813338-26790-2-git-send-email-daniel@schoepe.org> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1319813338-26790-1-git-send-email-daniel@schoepe.org> References: <1309896760-378-1-git-send-email-daniel.schoepe@googlemail.com> <1319813338-26790-1-git-send-email-daniel@schoepe.org> Cc: Daniel Schoepe 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, 28 Oct 2011 14:50:00 -0000 From: Daniel Schoepe This fixes the minor annoyance that message ids were parsed as mail addresses by goto-address-mode in notmuch-show buffers. --- emacs/notmuch-show.el | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 8db5435..440e089 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -27,6 +27,7 @@ (require 'mm-decode) (require 'mailcap) (require 'icalendar) +(require 'goto-addr) (require 'notmuch-lib) (require 'notmuch-query) @@ -789,6 +790,24 @@ current buffer, if possible." (defvar notmuch-show-buffer-name nil) (make-variable-buffer-local 'notmuch-show-buffer-name) +(defun notmuch-show-buttonise-links (start end) + "Buttonise URLs and mail addresses between START and END. + +This also turns id:\"\"-parts into buttons for +a corresponding notmuch search." + (goto-address-fontify-region start end) + (save-excursion + (goto-char start) + (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" 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-search ,(match-string-no-properties 0))) + '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 crypto-switch) "Run \"notmuch show\" with the given thread ID and display results. @@ -839,9 +858,8 @@ function is used. " (notmuch-show-insert-forest (notmuch-query-get-threads basic-args)))) - ;; Enable buttonisation of URLs and email addresses in the - ;; buffer. - (goto-address-mode t) + (jit-lock-register #'notmuch-show-buttonise-links) + ;; Act on visual lines rather than logical lines. (visual-line-mode t) -- 1.7.7