From 06748532dc5c1631fb207a208b3f5dbdbad94a97 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 9 Dec 2013 09:44:18 +0100 Subject: [PATCH] Re: [PATCH WIP v3 1/3] emacs: show: mark tags changed since buffer loaded --- 82/270780b12254eccbdcd4416a26a113f46b6aca | 206 ++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 82/270780b12254eccbdcd4416a26a113f46b6aca diff --git a/82/270780b12254eccbdcd4416a26a113f46b6aca b/82/270780b12254eccbdcd4416a26a113f46b6aca new file mode 100644 index 000000000..e3045535f --- /dev/null +++ b/82/270780b12254eccbdcd4416a26a113f46b6aca @@ -0,0 +1,206 @@ +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 6DD66431FC0 + for ; Mon, 9 Dec 2013 00:44:43 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 e-HF27KKLpPJ for ; + Mon, 9 Dec 2013 00:44:39 -0800 (PST) +Received: from mail-qc0-f172.google.com (mail-qc0-f172.google.com + [209.85.216.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1FFF7431FAE + for ; Mon, 9 Dec 2013 00:44:39 -0800 (PST) +Received: by mail-qc0-f172.google.com with SMTP id e16so2419444qcx.17 + for ; Mon, 09 Dec 2013 00:44:38 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=aWxSVwaRoc2+FG3ar3M/YakFcWxufn5QDM+tJvNKsds=; + b=d8YHQnZ89bwUk0YyrnMMQCL8qdVZXhYZtGAzF7YI2166XQASCiegtI8CcqJjrU4V2y + QlfT2Yth+kts1613gBSe/aklidsEVE/WPnGEkIqEAxDx8TI8hYCKLmLFt7hkutlLLHXW + ABHZZ0XLAGxfzBHtBnUQavFpp//WcGfJhmzQnUmeVjzsQwo5/7ncnRlB2D04C0xH4EFR + jMS0izdBRJD6kFf8/jtiSdSyaFYQJBkDho6at5HeGrh/oicDcJpp5VRHeVnKwhWJcgcj + RZqO6CCWdiWIMQRrBU2lAdahkyjnxde2fJvZ0uc8aphLrC7VTFKqPTzUXgyENKFy+yAF + 2M/g== +X-Gm-Message-State: + ALoCoQm03lkDfsBRED/CHIOtob2wLfEni4ThrVlZCAvVCcKUgGqAVmo/8LrBVkbkgHJ7h2+2/Vxf +X-Received: by 10.224.55.69 with SMTP id t5mr31946484qag.82.1386578677525; + Mon, 09 Dec 2013 00:44:37 -0800 (PST) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id x10sm30872716qas.5.2013.12.09.00.44.36 + for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Mon, 09 Dec 2013 00:44:36 -0800 (PST) +From: Jani Nikula +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH WIP v3 1/3] emacs: show: mark tags changed since buffer + loaded +In-Reply-To: <1386273871-24214-2-git-send-email-markwalters1009@gmail.com> +References: <1386273871-24214-1-git-send-email-markwalters1009@gmail.com> + <1386273871-24214-2-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.17~rc2+11~gef943e9 (http://notmuchmail.org) Emacs/23.2.1 + (x86_64-pc-linux-gnu) +Date: Mon, 09 Dec 2013 09:44:18 +0100 +Message-ID: <874n6is9b1.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +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: Mon, 09 Dec 2013 08:44:43 -0000 + +On Thu, 05 Dec 2013, Mark Walters wrote: +> 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). + +I really like how this works. Very nice! + +I did notice a small wrinkle though. On a terminal the strike-through +does not work, and the appearance is that the tag was not removed (until +you refresh with '='). I don't know if you can easily adapt the face or +disable the whole feature when on terminal. Or make this an opt-in +feature. I guess some people might not like this in general, so a way to +disable might be a good idea too. Fine tuning. + +BR, +Jani. + + + + +> --- +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2