From: Mark Walters Date: Sun, 18 Jan 2015 18:10:51 +0000 (+0000) Subject: Re: [PATCH v2 2/3] emacs: Improved display of matching/non-matching authors. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0eee648d7a29f3807eb3118d4c34cf8682007508;p=notmuch-archives.git Re: [PATCH v2 2/3] emacs: Improved display of matching/non-matching authors. --- diff --git a/16/469694f7035aecc05a4d3be3641f920c5ed941 b/16/469694f7035aecc05a4d3be3641f920c5ed941 new file mode 100644 index 000000000..0c4a8f167 --- /dev/null +++ b/16/469694f7035aecc05a4d3be3641f920c5ed941 @@ -0,0 +1,210 @@ +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 D6B38431FB6 + for ; Sun, 18 Jan 2015 10:10:39 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 1.34 +X-Spam-Level: * +X-Spam-Status: No, score=1.34 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, DNS_FROM_AHBL_RHSBL=2.438, + FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] + 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 lxpiBCLpoj+I for ; + Sun, 18 Jan 2015 10:10:36 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 4918E431FAF + for ; Sun, 18 Jan 2015 10:10:36 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1YCuIy-0006Mw-Cw; Sun, 18 Jan 2015 18:10:32 +0000 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1YCuIx-00078I-Tv; Sun, 18 Jan 2015 18:10:32 +0000 +From: Mark Walters +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 2/3] emacs: Improved display of + matching/non-matching authors. +In-Reply-To: <1414172643-28270-3-git-send-email-dme@dme.org> +References: <1414172643-28270-1-git-send-email-dme@dme.org> + <1414172643-28270-3-git-send-email-dme@dme.org> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Sun, 18 Jan 2015 18:10:51 +0000 +Message-ID: <87oapwj6xg.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 5f0bc6cd3ac055a77f4f406af71c2084 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * -0.1 AWL AWL: Adjusted score from AWL reputation of From: address +X-QM-Scan-Virus: ClamAV says the message is clean +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: Sun, 18 Jan 2015 18:10:40 -0000 + +On Fri, 24 Oct 2014, David Edmondson wrote: +> Rather than splitting the :authors attribute, which is error prone, +> use the separate :authors_matched and :authors_non_matched attributes. +> +> This improves the display of authors should one of them include a pipe +> symbol (|) in their 'from' address. + +Hi + +I haven't fully understood this code yet: do you need to join the +matching and non-matching authors and then split again for propertizing? +It feels like it would be nicer to keep them separate and only combine +at the very end. + +Does this all get nicer with your formatting search results series? + +Best wishes + +Mark + + +> --- +> emacs/notmuch.el | 64 +++++++++++++++++++++++++++++++------------------------- +> 1 file changed, 35 insertions(+), 29 deletions(-) +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index b44a907..688b37c 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -672,22 +672,24 @@ foreground and blue background." +> ;; Reverse the list so earlier entries take precedence +> (reverse notmuch-search-line-faces))) +> +> -(defun notmuch-search-author-propertize (authors) +> +(defun notmuch-search-author-propertize (authors matching-length) +> "Split `authors' into matching and non-matching authors and +> propertize appropriately. If no boundary between authors and +> non-authors is found, assume that all of the authors match." +> - (if (string-match "\\(.*\\)|\\(.*\\)" authors) +> - (concat (propertize (concat (match-string 1 authors) ",") +> - 'face 'notmuch-search-matching-authors) +> - (propertize (match-string 2 authors) +> - 'face 'notmuch-search-non-matching-authors)) +> - (propertize authors 'face 'notmuch-search-matching-authors))) +> - +> -(defun notmuch-search-insert-authors (format-string authors) +> + (let ((match-part (substring authors 0 matching-length)) +> + (non-match-part (substring authors matching-length))) +> + +> + (concat (propertize match-part 'face 'notmuch-search-matching-authors) +> + (propertize non-match-part 'face 'notmuch-search-non-matching-authors)))) +> + +> +(defun notmuch-search-insert-authors (format-string matching-authors non-matching-authors) +> ;; Save the match data to avoid interfering with +> ;; `notmuch-search-process-filter'. +> (save-match-data +> - (let* ((formatted-authors (format format-string authors)) +> + (let* ((authors (if (string= "" non-matching-authors) +> + matching-authors +> + (concat matching-authors ", " non-matching-authors))) +> + (formatted-authors (format format-string authors)) +> (formatted-sample (format format-string "")) +> (visible-string formatted-authors) +> (invisible-string "") +> @@ -703,9 +705,9 @@ non-authors is found, assume that all of the authors match." +> (setq visible-string (substring formatted-authors 0 visible-length) +> invisible-string (substring formatted-authors visible-length)) +> ;; If possible, truncate the visible string at a natural +> - ;; break (comma or pipe), as incremental search doesn't +> - ;; match across the visible/invisible border. +> - (when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string) +> + ;; break (comma), as incremental search doesn't match +> + ;; across the visible/invisible border. +> + (when (string-match "\\(.*\\)\\(, \\)\\([^,]*\\)" visible-string) +> ;; Second clause is destructive on `visible-string', so +> ;; order is important. +> (setq invisible-string (concat (match-string 3 visible-string) +> @@ -721,20 +723,23 @@ non-authors is found, assume that all of the authors match." +> ? )))) +> +> ;; Use different faces to show matching and non-matching authors. +> - (if (string-match "\\(.*\\)|\\(.*\\)" visible-string) +> - ;; The visible string contains both matching and +> - ;; non-matching authors. +> - (setq visible-string (notmuch-search-author-propertize visible-string) +> - ;; The invisible string must contain only non-matching +> - ;; authors, as the visible-string contains both. +> - invisible-string (propertize invisible-string +> - 'face 'notmuch-search-non-matching-authors)) +> - ;; The visible string contains only matching authors. +> - (setq visible-string (propertize visible-string +> - 'face 'notmuch-search-matching-authors) +> - ;; The invisible string may contain both matching and +> - ;; non-matching authors. +> - invisible-string (notmuch-search-author-propertize invisible-string))) +> + (let ((visible-length (length visible-string)) +> + (matching-length (length matching-authors))) +> + +> + (if (> visible-length matching-length) +> + ;; The visible string contains both matching and +> + ;; non-matching authors. +> + (setq visible-string (notmuch-search-author-propertize visible-string matching-length) +> + ;; The invisible string must contain only non-matching +> + ;; authors, as the visible-string contains both. +> + invisible-string (propertize invisible-string +> + 'face 'notmuch-search-non-matching-authors)) +> + ;; The visible string contains only matching authors. +> + (setq visible-string (propertize visible-string +> + 'face 'notmuch-search-matching-authors) +> + ;; The invisible string may contain both matching and +> + ;; non-matching authors. +> + invisible-string (notmuch-search-author-propertize invisible-string (- visible-length matching-length))))) +> +> ;; If there is any invisible text, add it as a tooltip to the +> ;; visible text. +> @@ -768,8 +773,9 @@ non-authors is found, assume that all of the authors match." +> 'face 'notmuch-search-subject))) +> +> ((string-equal field "authors") +> - (notmuch-search-insert-authors +> - format-string (notmuch-sanitize (plist-get result :authors)))) +> + (notmuch-search-insert-authors format-string +> + (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_matched) ", ")) +> + (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_non_matched) ", ")))) +> +> ((string-equal field "tags") +> (let ((tags (plist-get result :tags)) +> -- +> 2.1.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch