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 6D2A8431FD0 for ; Tue, 5 Jul 2011 13:12:54 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.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 YIdMP21aVI9a for ; Tue, 5 Jul 2011 13:12:53 -0700 (PDT) Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 8E8FA431FB6 for ; Tue, 5 Jul 2011 13:12:53 -0700 (PDT) Received: by fxh19 with SMTP id 19so6441358fxh.19 for ; Tue, 05 Jul 2011 13:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=7HnxWETjFrRXs/iWtJJVHglwJGrYzkVENLjcLnCueXE=; b=xnQxEhyqLa2aS/b8Vf8MzY/3p0IiEBJYEcgiBQFlv/LlCMGJxGevsOs+FOYG1pjGwf lvJJAugscTfkLP+SeY+gQ98CJ8Lz0g9vKPDM43XfANqfP5mJJcD/93g1QIjYVyt6Wta8 Fn3c4KvkuTdNXvBS/Q3d5Grgv4xGT+GlniwTw= Received: by 10.223.93.196 with SMTP id w4mr2268956fam.44.1309896772166; Tue, 05 Jul 2011 13:12:52 -0700 (PDT) Received: from localhost (dslb-178-004-223-219.pools.arcor-ip.net [178.4.223.219]) by mx.google.com with ESMTPS id j23sm1148129fai.39.2011.07.05.13.12.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 13:12:50 -0700 (PDT) From: Daniel Schoepe To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Turn id:"" elements into buttons for notmuch searches Date: Tue, 5 Jul 2011 22:12:40 +0200 Message-Id: <1309896760-378-1-git-send-email-daniel.schoepe@googlemail.com> X-Mailer: git-send-email 1.7.5.4 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: Tue, 05 Jul 2011 20:12:54 -0000 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 | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f96743b..0f7fcfe 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -778,6 +778,24 @@ current buffer, if possible." (defvar notmuch-show-parent-buffer nil) (make-variable-buffer-local 'notmuch-show-parent-buffer) +(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:\"[^ ]+\"" 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. @@ -822,9 +840,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.5.4