From: Mark Walters Date: Wed, 12 Mar 2014 04:09:49 +0000 (+0000) Subject: [Patch v3 0/8] emacs: show tag changes in buffer X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bc2386e8b2f5da8801e99b75a1aed05efffb0907;p=notmuch-archives.git [Patch v3 0/8] emacs: show tag changes in buffer --- diff --git a/30/fb250090dcd4e1adaca2a0d02a0d48655af688 b/30/fb250090dcd4e1adaca2a0d02a0d48655af688 new file mode 100644 index 000000000..c1123e0fc --- /dev/null +++ b/30/fb250090dcd4e1adaca2a0d02a0d48655af688 @@ -0,0 +1,222 @@ +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 30118431FC9 + for ; Tue, 11 Mar 2014 21:10:11 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.7 +X-Spam-Level: ** +X-Spam-Status: No, score=2.7 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, + FREEMAIL_REPLY=2.499, 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 Ge3pxO3KeIP5 for ; + Tue, 11 Mar 2014 21:10:05 -0700 (PDT) +Received: from mail-we0-f172.google.com (mail-we0-f172.google.com + [74.125.82.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 5ABD7431FBD + for ; Tue, 11 Mar 2014 21:10:05 -0700 (PDT) +Received: by mail-we0-f172.google.com with SMTP id t61so10935384wes.31 + for ; Tue, 11 Mar 2014 21:10:02 -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=ushI8sUyDdfc3tZh/Ec3wHxTnIQti1POySXlq7loy8M=; + b=cn6p7+5AqY+v7+OUNAasM1W2dybTInO6NQZ30cEdkJzjV6HpbZZJ9Mjo4LU3vwokJM + Y48hpt2BGZeQj8OpZGJvE45fOjhB70Dvii8acQp23onSYgEHaimJDmqPtCj3HkC8nIzk + z/EmrME60hzrHGhs+962npirUrzjkw6/j+nH/G10gv6LmXBb5YVXauA4Pe0MijpzDdwc + AwGeDQjTyqoaB/qjJ+MmWK5jRm9IhdCL3FVUDwMf4HbRWoHHIxIZlu5+4SQfEsxl4f7s + /VhrMGbiwKJuGmtPFrL7qCNn22vEQIx73dQluKR+4HVPWnyJE3j3B15zi8P2j3+ftMPR + ZZXA== +X-Received: by 10.194.1.242 with SMTP id 18mr2235058wjp.22.1394597401363; + Tue, 11 Mar 2014 21:10:01 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id 12sm66447776wjm.10.2014.03.11.21.10.00 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 11 Mar 2014 21:10:00 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org, + amdragon@mit.edu +Subject: [Patch v3 0/8] emacs: show tag changes in buffer +Date: Wed, 12 Mar 2014 04:09:49 +0000 +Message-Id: <1394597397-8486-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: Wed, 12 Mar 2014 04:10:11 -0000 + +This is version 3 of this patch set. Version 2 is at +id:1392841212-8494-1-git-send-email-markwalters1009@gmail.com. + +This includes a (very) slightly tweaked version of Austin's +notmuch-apply-face patch so that face properties for deleted/added +tags get applied on top of rather than instead of the default face for +that tag. + +Otherwise I think this addesses all of Austin's review comments. + +A diff from v2 is below: I have deleted the parts related to the +notmuch-apply-face addition. + +Best wishes + +Mark + +diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el +index 869b97d..cfccb8e 100644 +--- a/emacs/notmuch-tag.el ++++ b/emacs/notmuch-tag.el +@@ -28,18 +28,6 @@ + (require 'crm) + (require 'notmuch-lib) + +-;; (notmuch-tag-clear-cache will be called by the defcustom +-;; notmuch-tag-formats, so it has to be defined first.) +- +-(defvar notmuch-tag--format-cache (make-hash-table :test 'equal) +- "Cache of tag format lookup. Internal to `notmuch-tag-format-tag'.") +- +-(defun notmuch-tag-clear-cache () +- "Clear the internal cache of tag formats. +- +-This must be called after changes to `notmuch-tag-formats'." +- (clrhash notmuch-tag--format-cache)) +- + (define-widget 'notmuch-tag-format-type 'lazy + "Customize widget for notmuch-tag-format and friends" + :type '(alist :key-type (regexp :tag "Tag") +@@ -51,7 +39,7 @@ (define-widget 'notmuch-tag-format-type 'lazy + (string :tag "Display as") + (list :tag "Face" :extra-offset -4 + (const :format "" :inline t +- (propertize tag 'face)) ++ (notmuch-apply-face tag)) + (list :format "%v" + (const :format "" quote) + custom-face-edit)) +@@ -102,7 +90,11 @@ (defcustom notmuch-tag-formats + :type 'notmuch-tag-format-type) + + (defcustom notmuch-tag-deleted-formats +- '((".*" (propertize tag 'face ++ '(("unread" (notmuch-apply-face "unread" ++ (if (display-supports-face-attributes-p '(:strike-through "red")) ++ '(:strike-through "red") ++ '(:inverse-video t)))) ++ (".*" (notmuch-apply-face tag + (if (display-supports-face-attributes-p '(:strike-through "red")) + '(:strike-through "red") + '(:inverse-video t))))) +@@ -115,14 +107,14 @@ (defcustom notmuch-tag-deleted-formats + unless strike-through is not available (e.g., emacs is running in + a terminal) in which case it uses inverse video. To hide deleted + tags completely set this to +- '((\"\" nil)) ++ '((\".*\" nil)) + + See `notmuch-tag-formats' for full documentation." + :group 'notmuch-show + :type 'notmuch-tag-format-type) + + (defcustom notmuch-tag-added-formats +- '((".*" (propertize tag 'face '(:underline "green")))) ++ '((".*" (notmuch-apply-face tag '(:underline "green")))) + "Custom formats for tags when added. + + For added tags the formats in `notmuch-tag-formats` are applied +@@ -185,8 +177,15 @@ (defun notmuch-tag-tag-icon () + + ") + ++(defvar notmuch-tag--format-cache (make-hash-table :test 'equal) ++ "Cache of tag format lookup. Internal to `notmuch-tag-format-tag'.") ++ ++(defun notmuch-tag-clear-cache () ++ "Clear the internal cache of tag formats." ++ (clrhash notmuch-tag--format-cache)) ++ + (defun notmuch-tag-format-tag-by-state (tag formatted-tag tag-state) +- "Format TAG by looking into the appropriate `notmuch-tag-formats`. ++ "Format TAG according to the appropriate `notmuch-tag-formats`. + + Applies formats for TAG from the appropriate one of + `notmuch-tag-formats`, `notmuch-tag-deleted-formats` and +@@ -194,11 +193,15 @@ (defun notmuch-tag-format-tag-by-state (tag formatted-tag tag-state) + formatted tag FORMATTED-TAG." + (let ((formatted (gethash (cons tag tag-state) notmuch-tag--format-cache 'missing))) + (when (eq formatted 'missing) +- (let* ((tag-formats (cond ((null tag-state) notmuch-tag-formats) +- ((eq 'deleted tag-state) notmuch-tag-deleted-formats) +- ((eq 'added tag-state) notmuch-tag-added-formats))) ++ (let* ((tag-formats (case tag-state ++ ((list nil) notmuch-tag-formats) ++ (deleted notmuch-tag-deleted-formats) ++ (added notmuch-tag-added-formats))) + (formats + (save-match-data ++ ;; Don't use assoc-default since there's no way to ++ ;; distinguish a missing key from a present key with a ++ ;; null cdr:. + (assoc* tag tag-formats + :test (lambda (tag key) + (and (eq (string-match key tag) 0) +@@ -224,7 +227,7 @@ (defun notmuch-tag-format-tag-by-state (tag formatted-tag tag-state) + formatted)) + + (defun notmuch-tag-format-tag (tags orig-tags tag) +- "Format TAG by looking into `notmuch-tag-formats'. ++ "Format TAG according to `notmuch-tag-formats'. + + TAGS and ORIG-TAGS are lists of the current tags and the original + tags; tags which have been deleted (i.e., are in ORIG-TAGS but +@@ -246,7 +249,7 @@ (defun notmuch-tag-format-tags (tags orig-tags &optional face) + "Return a string representing formatted TAGS." + (let ((face (or face 'notmuch-tag-face)) + (all-tags (sort (delete-dups (append tags orig-tags nil)) #'string<))) +- (notmuch-combine-face-text-property-string ++ (notmuch-apply-face + (mapconcat #'identity + ;; nil indicated that the tag was deliberately hidden + (delq nil (mapcar + + + + +Austin Clements (2): + emacs: Combine notmuch-combine-face-text-property{,-string} + Make keys of notmuch-tag-formats regexps and use caching + +Mark Walters (6): + emacs: tag split customise option for format-tags into a widget + emacs: tag: add customize for deleted/added tag formats + emacs: show: mark tags changed since buffer loaded + emacs: show: use orig-tags for tag display + emacs: search: use orig-tags in search + emacs: tree: use orig-tags in search + + emacs/notmuch-lib.el | 35 +++++---- + emacs/notmuch-show.el | 7 +- + emacs/notmuch-tag.el | 194 +++++++++++++++++++++++++++++++++++++------------ + emacs/notmuch-tree.el | 12 ++- + emacs/notmuch.el | 44 +++++++---- + test/test-lib.el | 5 + + 6 files changed, 210 insertions(+), 87 deletions(-) + +-- +1.7.9.1 +