From: Mark Walters Date: Thu, 5 Dec 2013 20:04:29 +0000 (+0000) Subject: [PATCH WIP v3 1/3] emacs: show: mark tags changed since buffer loaded X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=aa9e9a559757751a64e96ea4ab775610c5242a8f;p=notmuch-archives.git [PATCH WIP v3 1/3] emacs: show: mark tags changed since buffer loaded --- diff --git a/1f/1de5960b9e63626cf1b6ee545a21c53b750d09 b/1f/1de5960b9e63626cf1b6ee545a21c53b750d09 new file mode 100644 index 000000000..bb97d2f9f --- /dev/null +++ b/1f/1de5960b9e63626cf1b6ee545a21c53b750d09 @@ -0,0 +1,178 @@ +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 309A4431E84 + for ; Thu, 5 Dec 2013 12:04:56 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 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, + 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 P5ck4EiXXhOn for ; + Thu, 5 Dec 2013 12:04:49 -0800 (PST) +Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com + [209.85.212.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 6FD12431FD8 + for ; Thu, 5 Dec 2013 12:04:49 -0800 (PST) +Received: by mail-wi0-f178.google.com with SMTP id ca18so216068wib.17 + for ; Thu, 05 Dec 2013 12:04:48 -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:in-reply-to:references; + bh=+1n+4a7WWXFLfMTwF3MGnzUAOPyaYy0Zw6dwT4JrMnA=; + b=l2Dwpb+T9k4z9e7Bl+fZYMrhhkYDJOJkWMsZjszOEPRp6P6g4DK8JGQkG9xA9aW8GF + rXpw3MCagUNvrzzLek5l2Ca1+H+O5wwEZi8+wZvNIh21wGXKwLiuHL3KeJRUfcaaZEyV + 0ZIPE1Z7u6ua7+8ggmN8kRRyiUVGhlyndS85/VGdSR/ZjWm0Mvp2qHdVRp3YEaqWMO+W + 1YcBl/9BHz5gNzIn6Mumn7dJFu/dZnMSsPvN/htQX5AQD0IXdpsT+yLGuY+V9E5NB2lj + v9e8N31DGolnjj9d7U3ek9P+xOJOz9sQ3IaJhsIdfP/SJun9He9+KX9PhYzJjOUHhEX0 + m3Nw== +X-Received: by 10.194.60.73 with SMTP id f9mr19097793wjr.65.1386273888231; + Thu, 05 Dec 2013 12:04:48 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id nb16sm9433226wic.0.2013.12.05.12.04.46 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Thu, 05 Dec 2013 12:04:47 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH WIP v3 1/3] emacs: show: mark tags changed since buffer loaded +Date: Thu, 5 Dec 2013 20:04:29 +0000 +Message-Id: <1386273871-24214-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1386273871-24214-1-git-send-email-markwalters1009@gmail.com> +References: <1386273871-24214-1-git-send-email-markwalters1009@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: Thu, 05 Dec 2013 20:04:56 -0000 + +This shows any tags changed in the show buffer since it was loaded or +refreshed. By default a removed tag is displayed with strike-through +in red and an added tag is displayed underlined in green. + +One nice feature is that this makes it clear when a message was unread +when you first loaded the buffer (previously the unread tag could be +removed before a user realised that it had been unread). +--- + emacs/notmuch-show.el | 34 +++++++++++++++++++++++++++++----- + emacs/notmuch-tag.el | 30 ++++++++++++++++++++---------- + 2 files changed, 49 insertions(+), 15 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 784644c..d64d407 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -211,6 +211,18 @@ For example, if you wanted to remove an \"unread\" tag and add a + :type '(repeat string) + :group 'notmuch-show) + ++(defface notmuch-show-deleted-tag-face ++ '((t :strike-through "red" :inherit 'notmuch-tag-face)) ++ "Face for tags that have been removed" ++ :group 'notmuch-show ++ :group 'notmuch-faces) ++ ++(defface notmuch-show-added-tag-face ++ '((t :underline "green")) ++ "Face for tags that have been added" ++ :group 'notmuch-show ++ :group 'notmuch-faces) ++ + + (defmacro with-current-notmuch-show-message (&rest body) + "Evaluate body with current buffer set to the text of current message" +@@ -341,11 +353,21 @@ operation on the contents of the current buffer." + "Update the displayed tags of the current message." + (save-excursion + (goto-char (notmuch-show-message-top)) +- (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) +- (let ((inhibit-read-only t)) +- (replace-match (concat "(" +- (notmuch-tag-format-tags tags) +- ")")))))) ++ (let* ((orig-tags (notmuch-show-get-prop :orig-tags)) ++ (all-tags (sort (delete-dups (append tags orig-tags)) #'string<)) ++ (display-tags (mapcar (lambda (tag) (cond ((and (member tag tags) (member tag orig-tags)) ++ tag) ++ ((not (member tag tags)) ++ (cons tag 'deleted)) ++ ((not (member tag orig-tags)) ++ (cons tag 'added)))) ++ all-tags))) ++ ++ (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) ++ (let ((inhibit-read-only t)) ++ (replace-match (concat "(" ++ (notmuch-tag-format-tags display-tags) ++ ")"))))))) + + (defun notmuch-clean-address (address) + "Try to clean a single email ADDRESS for display. Return a cons +@@ -1167,6 +1189,8 @@ function is used." + + (jit-lock-register #'notmuch-show-buttonise-links) + ++ (notmuch-show-mapc (lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags)))) ++ + ;; Set the header line to the subject of the first message. + (setq header-line-format (notmuch-sanitize (notmuch-show-strip-re (notmuch-show-get-subject)))) + +diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el +index b60f46c..fac2c3b 100644 +--- a/emacs/notmuch-tag.el ++++ b/emacs/notmuch-tag.el +@@ -137,16 +137,26 @@ This can be used with `notmuch-tag-format-image-data'." + + (defun notmuch-tag-format-tag (tag) + "Format TAG by looking into `notmuch-tag-formats'." +- (let ((formats (assoc tag notmuch-tag-formats))) +- (cond +- ((null formats) ;; - Tag not in `notmuch-tag-formats', +- tag) ;; the format is the tag itself. +- ((null (cdr formats)) ;; - Tag was deliberately hidden, +- nil) ;; no format must be returned +- (t ;; - Tag was found and has formats, +- (let ((tag tag)) ;; we must apply all the formats. +- (dolist (format (cdr formats) tag) +- (setq tag (eval format)))))))) ++ (let* ((status (if (consp tag) (cdr tag))) ++ (tag (if (consp tag) (car tag) tag)) ++ (formats (append (assoc tag notmuch-tag-formats))) ++ (tag ++ (cond ++ ((null formats) ;; - Tag not in `notmuch-tag-formats', ++ tag) ;; the format is the tag itself. ++ ((null (cdr formats)) ;; - Tag was deliberately hidden, ++ nil) ;; no format must be returned ++ (t ;; - Tag was found and has formats, ++ (let ((tag tag)) ;; we must apply all the formats. ++ (dolist (format (cdr formats) tag) ++ (setq tag (eval format)))))))) ++ (when tag ++ (cond ++ ((eq status 'deleted) ++ (notmuch-combine-face-text-property-string tag 'notmuch-show-deleted-tag-face)) ++ ((eq status 'added) ++ (notmuch-combine-face-text-property-string tag 'notmuch-show-added-tag-face)) ++ (t tag))))) + + (defun notmuch-tag-format-tags (tags) + "Return a string representing formatted TAGS." +-- +1.7.9.1 +