[Patch v3 0/8] emacs: show tag changes in buffer

Subject: [Patch v3 0/8] emacs: show tag changes in buffer

Date: Wed, 12 Mar 2014 04:09:49 +0000

To: notmuch@notmuchmail.org, amdragon@mit.edu

Cc:

From: Mark Walters


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 ()
   </g>
 </svg>")
 
+(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


Thread: