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 20D5C431FD9 for ; Tue, 11 Dec 2012 01:00:50 -0800 (PST) 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 kf4WQ6wkqzUS for ; Tue, 11 Dec 2012 01:00:49 -0800 (PST) Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id DEFBA431FAE for ; Tue, 11 Dec 2012 01:00:48 -0800 (PST) Received: by mail-wg0-f41.google.com with SMTP id ds1so1214872wgb.2 for ; Tue, 11 Dec 2012 01:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=aW34qn1wrIONxWP6V0whAOqbeiiOjp9tmgLCntBpqBk=; b=TjOtZvlpAGU2ZEXoMjBJG3zzi0vIbqNTpgzTD0Riqshjg7xZgBMoUUd9FcDQ5ig9UU FQypbC5iVy/mH2tw6eAuzR0FO60c9dOcxVpvKuzQby+KA5jS0/q/XLnnLpBmR3ZXl3e8 xMeSoICIBac4fPNHpktMTmpcuosEVyLlRUt+CtEumUCqVE4nQZ9Cy0SimAtNwCRDAycY de0DY8gA14zahhe8LbB0qVPp2PWOZW3FSqQKDvkA58v/GUXnOU9i/wAF0ZAEqyDNvFqc SjqFlIH/rvv5PB8A9qrMX/gTmxlxYbiRGzlImNVjz+GoBBE9f/zKgAIoduiqsSgpix3K JHGw== Received: by 10.216.72.12 with SMTP id s12mr371252wed.69.1355216447682; Tue, 11 Dec 2012 01:00:47 -0800 (PST) Received: from luz3.lille.inria.fr ([193.51.236.232]) by mx.google.com with ESMTPS id b1sm15376748wix.11.2012.12.11.01.00.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Dec 2012 01:00:47 -0800 (PST) From: Damien Cassou To: notmuch@notmuchmail.org Subject: [PATCH 3/4] emacs: Make all tags in `notmuch-show' clickable Date: Tue, 11 Dec 2012 10:00:36 +0100 Message-Id: <1355216437-21109-4-git-send-email-damien.cassou@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com> References: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com> 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, 11 Dec 2012 09:00:50 -0000 Signed-off-by: Damien Cassou --- emacs/notmuch-show.el | 15 +++++++-------- emacs/notmuch-tagger.el | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index a71497a..93bce07 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -362,10 +362,8 @@ operation on the contents of the current buffer." (goto-char (notmuch-show-message-top)) (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) (let ((inhibit-read-only t)) - (replace-match (concat "(" - (propertize (mapconcat 'identity tags " ") - 'face 'notmuch-tag-face) - ")"))))) + (replace-match (propertize (notmuch-tagger-format-tags tags) + 'face 'notmuch-tag-face))))) (notmuch-show-update-header-line)) (defun notmuch-clean-address (address) @@ -442,10 +440,11 @@ message at DEPTH in the current thread." (notmuch-show-clean-address (plist-get headers :From)) " (" date - ") (" - (propertize (mapconcat 'identity tags " ") - 'face 'notmuch-tag-face) - ")\n") + ") " + (propertize + (notmuch-tagger-format-tags tags) + 'face 'notmuch-tag-face) + "\n") (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) (defun notmuch-show-insert-header (header header-value) diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el index 38b858a..35b81ca 100644 --- a/emacs/notmuch-tagger.el +++ b/emacs/notmuch-tagger.el @@ -44,12 +44,21 @@ test if the library is present before calling this function." (let ((tag (header-button-get button 'notmuch-tagger-tag))) (notmuch-tagger-goto-target tag))) +(defun notmuch-tagger-body-button-action (button) + "Open `notmuch-search' for the tag referenced by BUTTON." + (let ((tag (button-get button 'notmuch-tagger-tag))) + (notmuch-tagger-goto-target tag))) + (eval-after-load "header-button" '(define-button-type 'notmuch-tagger-header-button-type 'supertype 'header 'action #'notmuch-tagger-header-button-action 'follow-link t)) +(define-button-type 'notmuch-tagger-body-button-type + 'action #'notmuch-tagger-body-button-action + 'follow-link t) + (defun notmuch-tagger-really-make-header-link (tag) "Return a property list that presents a link to TAG. @@ -73,6 +82,20 @@ if not." (notmuch-tagger-really-make-header-link tag) tag)) +(defun notmuch-tagger-make-body-link (tag) + "Return a property list that presents a link to TAG. +The returned property list will not work in the header-line. For +a link that works on the header-line, prefer +`notmuch-tagger-make-header-link'." + (let ((button (copy-sequence tag))) + (make-text-button + button nil + 'type 'notmuch-tagger-body-button-type + 'notmuch-tagger-tag tag + 'skip t ;; don't stop when using TAB + 'help-echo (format "%s: Search other messages like this" tag)) + button)) + (defun notmuch-tagger-format-tags-header-line (tags) "Format TAGS as a `mode-line-format' template. The result is suitable for inclusion in `header-line-format'." @@ -83,5 +106,15 @@ The result is suitable for inclusion in `header-line-format'." " ") ")")) +(defun notmuch-tagger-format-tags (tags) + "Format TAGS as a string suitable for insertion in a buffer. +If the result of this function is to be used within the +header-line, prefer `notmuch-tagger-format-tags-header-line' +instead of this function." + (concat + "(" + (mapconcat #'notmuch-tagger-make-body-link tags " ") + ")")) + (provide 'notmuch-tagger) ;;; notmuch-tagger.el ends here -- 1.7.10.4