From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id QPd0Oj3pu2DaeAAAsNZ9tg (envelope-from ); Sat, 05 Jun 2021 21:14:37 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id gEFZOjnpu2BhSQAAbx9fmQ (envelope-from ); Sat, 05 Jun 2021 21:14:33 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1622927673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dot8PK9Q6+y0WWkZZXoUJy5m27P9bn9wbZ+YyStb7xk=; b=R4jelur9jCsZ7SEquID8yJZJWbHevBjnpmjACJPqVdyHNiVr4bYGmgYH5Lpwqukqu3P/Is oFTWXLKcyCoeMFqcq18UwtrktA+JMLrDno7C9ktNgfh3uSPmhamKJl+j6KCb0d1Vl4zIF1 3oMZ19nywvbDu5FnbEjzHcmJYFureL+3DinEd/GKtiDDcmP/dSdUnL20TilNNjYtb0GAG9 kwhiSsjsDOEno1REQii2p0/7d5wR8NgOeK/2CA+i74qyjnUus+JYfwHfnQpSVmx//IOWAr qTY0ePHKRo6GhjJvclQ0YXj0VJMILwaOQFFRaEO1ATbsxPMNXkSjdZZs8U8GyA== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 07/18] lei query: Fontify results Date: Sat, 5 Jun 2021 17:13:51 -0400 Message-Id: <20210605211402.20304-8-kyle@kyleam.com> In-Reply-To: <20210605211402.20304-1-kyle@kyleam.com> References: <20210605211402.20304-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyle@kyleam.com X-TUID: tte1L27+rTPR --- 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" ;;;; 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" ;;;;; 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 . @@ -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