From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH 07/18] lei query: Fontify results
Date: Sat, 5 Jun 2021 17:13:51 -0400 [thread overview]
Message-ID: <20210605211402.20304-8-kyle@kyleam.com> (raw)
In-Reply-To: <20210605211402.20304-1-kyle@kyleam.com>
---
piem-lei.el | 60 ++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 48 insertions(+), 12 deletions(-)
diff --git a/piem-lei.el b/piem-lei.el
index 1b744213..2bed43ef 100644
--- a/piem-lei.el
+++ b/piem-lei.el
@@ -146,6 +146,22 @@ (define-derived-mode piem-lei-show-mode special-mode "lei-show"
\f
;;;; Searching
+(defface piem-lei-query-date
+ '((t :inherit font-lock-variable-name-face))
+ "Face for date in `piem-lei-query-mode' buffers.")
+
+(defface piem-lei-query-pct
+ '((t :inherit shadow))
+ "Face for \"search relevance\" in `piem-lei-query-mode' buffers.")
+
+(defface piem-lei-query-from
+ '((t :inherit font-lock-doc-face))
+ "Face for sender name in `piem-lei-query-mode' buffers.")
+
+(defface piem-lei-query-subject
+ '((t :inherit default))
+ "Face for subject in `piem-lei-query-mode' buffers.")
+
(defun piem-lei-query--read-json-item ()
(let ((json-object-type 'alist)
(json-array-type 'list)
@@ -164,9 +180,12 @@ (defvar piem-lei-query--date-re
(defun piem-lei-query--format-date (data)
(let ((date (cdr (assq 'dt data))))
- (if (string-match piem-lei-query--date-re date)
- (concat (match-string 1 date) " " (match-string 2 date))
- (error "Date did not match expected format: %S" date))))
+ (propertize
+ (if (string-match piem-lei-query--date-re date)
+ (concat (match-string 1 date) " "
+ (match-string 2 date))
+ (error "Date did not match expected format: %S" date))
+ 'font-lock-face 'piem-lei-query-date)))
;;;###autoload
(defun piem-lei-query (query)
@@ -188,12 +207,16 @@ (defun piem-lei-query (query)
(format "%s %3s %-20.20s %s"
(piem-lei-query--format-date data)
(if-let ((pct (cdr (assq 'pct data))))
- (concat (number-to-string (cdr (assq 'pct data)))
- "%")
+ (propertize
+ (concat (number-to-string (cdr (assq 'pct data)))
+ "%")
+ 'font-lock-face 'piem-lei-query-pct)
"")
- (let ((from (car (cdr (assq 'f data)))))
- (or (car from) (cadr from)))
- (cdr (assq 's data))))
+ (propertize (let ((from (car (cdr (assq 'f data)))))
+ (or (car from) (cadr from)))
+ 'font-lock-face 'piem-lei-query-from)
+ (propertize (cdr (assq 's data))
+ 'font-lock-face 'piem-lei-query-subject)))
(add-text-properties (line-beginning-position) (line-end-position)
(list 'piem-lei-query-result data)))
(forward-line))
@@ -231,6 +254,14 @@ (define-derived-mode piem-lei-query-mode special-mode "lei-query"
\f
;;;;; Threading
+(defface piem-lei-query-thread-marker
+ '((t :inherit default))
+ "Face for thread marker in `piem-lei-query-mode' buffers.")
+
+(defface piem-lei-query-thread-ghost
+ '((t :inherit font-lock-comment-face))
+ "Face for ghost message IDs in `piem-lei-query-mode' buffers.")
+
;; The approach here tries to loosely follow what is in public-inbox's
;; SearchThread.pm, which in turn is a modified version of the
;; algorithm described at <https://www.jwz.org/doc/threading.html>.
@@ -314,7 +345,7 @@ (defun piem-lei-query--format-thread-marker (level)
(if (= level 0)
""
(concat (make-string (* 2 (1- level)) ?\s)
- "` ")))
+ (propertize "` " 'font-lock-face 'piem-lei-query-thread-marker))))
(defun piem-lei-query--slurp (args)
(with-temp-buffer
@@ -358,15 +389,20 @@ (defun piem-lei-query-thread (mid)
(piem-lei-query--format-date data) " "
(piem-lei-query--format-thread-marker depth)
(let ((from (car (cdr (assq 'f data)))))
- (or (car from) (cadr from)))
+ (propertize (or (car from) (cadr from))
+ 'font-lock-face 'piem-lei-query-from))
(concat " "
- (cdr (assq 's data))))
+ (propertize (cdr (assq 's data))
+ 'font-lock-face
+ 'piem-lei-query-subject)))
(add-text-properties (line-beginning-position)
(line-end-position)
(list 'piem-lei-query-result data)))
(insert (make-string 17 ?\s) ; Date alignment.
(piem-lei-query--format-thread-marker depth)
- (concat " <" mid-msg ">")))
+ (propertize (concat " <" mid-msg ">")
+ 'font-lock-face
+ 'piem-lei-query-thread-ghost)))
(insert ?\n)))
(insert "End of lei-q results"))
(goto-char (point-min))
--
2.31.1
next prev parent reply other threads:[~2021-06-05 21:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-05 21:13 [PATCH 00/18] Initial lei support Kyle Meyer
2021-06-05 21:13 ` [PATCH 01/18] lei: Add command and mode for displaying a message Kyle Meyer
2021-06-05 21:13 ` [PATCH 02/18] piem-lei-show: Let caller suppress displaying buffer Kyle Meyer
2021-06-05 21:13 ` [PATCH 03/18] piem-lei-show: Highlight headers and quoted text Kyle Meyer
2021-06-05 21:13 ` [PATCH 04/18] lei: Add command and mode for displaying overview of search results Kyle Meyer
2021-06-05 21:13 ` [PATCH 05/18] lei query: Add piem-lei-show wrapper for displaying line's message Kyle Meyer
2021-06-05 21:13 ` [PATCH 06/18] lei: Add command for viewing a thread Kyle Meyer
2021-06-05 21:13 ` Kyle Meyer [this message]
2021-06-05 21:13 ` [PATCH 08/18] piem-lei-query-thread: Position point on seed message Kyle Meyer
2021-06-05 21:13 ` [PATCH 09/18] piem-lei-query-thread: Drop repeated subjects Kyle Meyer
2021-06-05 21:13 ` [PATCH 10/18] piem-lei-query-thread: Deal with multiple "re:"s Kyle Meyer
2021-06-05 21:13 ` [PATCH 11/18] piem-lei-query-thread: Omit main part of subject if shared Kyle Meyer
2021-06-05 21:13 ` [PATCH 12/18] piem-lei-query-thread: Add bug#NNN special case when eliding subject Kyle Meyer
2021-06-05 21:13 ` [PATCH 13/18] lei query: Add next/previous line variants that update message buffer Kyle Meyer
2021-06-05 21:13 ` [PATCH 14/18] piem-lei-show: Record message ID Kyle Meyer
2021-06-05 21:13 ` [PATCH 15/18] lei query: Add commands for showing or scrolling message buffer Kyle Meyer
2021-06-05 21:14 ` [PATCH 16/18] lei: Configure bindings for query and show modes Kyle Meyer
2021-06-05 21:14 ` [PATCH 17/18] lei: Wire up piem.el hooks Kyle Meyer
2021-06-05 21:14 ` [PATCH 18/18] piem-lei-query-thread: Use piem-lei-get-mid to get message ID Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://git.kyleam.com/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210605211402.20304-8-kyle@kyleam.com \
--to=kyle@kyleam.com \
--cc=piem@inbox.kyleam.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.kyleam.com/piem/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).