diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-27 13:02:48 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-27 13:02:48 -0400 |
| commit | 202059c53d69093c169b8a05f670f9b97ad007ad (patch) | |
| tree | 843967db353033eb9b9bfc46b0d20293b7c0016c /modules | |
| parent | f9d9e003a208c22cd4d390125d990b79a4c0a0e7 (diff) | |
| download | dotemacs-202059c53d69093c169b8a05f670f9b97ad007ad.tar.gz dotemacs-202059c53d69093c169b8a05f670f9b97ad007ad.zip | |
feat(completion): annotate the Signal and contact pickers via categories
Two pickers have bare-name candidates worth a category: the Signal recipient picker, where a name maps to a phone or UUID, and org-contacts find, where a name maps to an email. I tag each with a custom category and a table annotation-function that shows the looked-up value. marginalia has no annotator for these custom categories, so it leaves the table's annotation in place. The other Tier-2 candidates from the survey (ai-term projects, the mu4e contact list) already carry their info inline, so a category adds nothing and I left them bare.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/org-contacts-config.el | 22 | ||||
| -rw-r--r-- | modules/signal-config.el | 8 |
2 files changed, 25 insertions, 5 deletions
diff --git a/modules/org-contacts-config.el b/modules/org-contacts-config.el index 64abb9fb5..944d75c10 100644 --- a/modules/org-contacts-config.el +++ b/modules/org-contacts-config.el @@ -168,15 +168,29 @@ Added: %U" ;;; ------------------------- Quick Contact Functions --------------------------- +(require 'system-lib) + (defun cj/org-contacts-find () "Find and open a contact." (interactive) (find-file contacts-file) (goto-char (point-min)) - (let ((contact (completing-read "Find contact: " - (org-map-entries - (lambda () (nth 4 (org-heading-components))) - nil (list contacts-file))))) + (let* ((alist (org-map-entries + (lambda () + (cons (nth 4 (org-heading-components)) + (or (org-entry-get nil "EMAIL") + (org-entry-get nil "PHONE")))) + nil (list contacts-file))) + (contact (completing-read + "Find contact: " + (cj/completion-table-annotated + 'contact + (lambda (cand) + (let ((info (cdr (assoc cand alist)))) + (when (and info (> (length info) 0)) + (concat " " (propertize info 'face + 'completions-annotations))))) + alist)))) (goto-char (point-min)) (search-forward contact) (org-fold-show-entry) diff --git a/modules/signal-config.el b/modules/signal-config.el index 86cb523ce..edb7d0dc3 100644 --- a/modules/signal-config.el +++ b/modules/signal-config.el @@ -309,7 +309,13 @@ opens the chosen recipient in `signel-chat'." (candidates (cons note-self cj/signel--contact-cache)) (table (lambda (string pred action) (if (eq action 'metadata) - '(metadata + `(metadata + (category . signal-contact) + (annotation-function + . ,(lambda (cand) + (let ((r (cdr (assoc cand candidates)))) + (when r + (concat " " (propertize r 'face 'completions-annotations)))))) (display-sort-function . identity) (cycle-sort-function . identity)) (complete-with-action action candidates string pred)))) |
