diff options
author | Vincent Ambo <mail@tazj.in> | 2024-09-27T22·38+0300 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2024-09-29T00·50+0000 |
commit | 5e4f1e7a6afa4428113e91249e07a0070e6522b4 (patch) | |
tree | e2ac61e4689c2884146cc02dd32b72e617df7c6f /tools | |
parent | 867b28bda197c27b6219bc2535aae3a2dd9a28e6 (diff) |
feat(emacs-pkgs/niri): add annotations for buffer targets r/8729
Adds a completing-read annotation function which can display the "remoteness" of Emacs buffers, as well as the app ID of Niri windows. Change-Id: I15550f7403b91aa4be7076290931da74ac539fac Reviewed-on: https://cl.tvl.fyi/c/depot/+/12536 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tools')
-rw-r--r-- | tools/emacs-pkgs/niri/niri.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/emacs-pkgs/niri/niri.el b/tools/emacs-pkgs/niri/niri.el index a677d093755d..3a4521174329 100644 --- a/tools/emacs-pkgs/niri/niri.el +++ b/tools/emacs-pkgs/niri/niri.el @@ -77,6 +77,21 @@ all Emacs buffers." Emacs buffer." (interactive) (let* ((selectables (niri--list-selectables)) + ;; Annotate buffers that display remote files. I frequently + ;; want to see it, because I might have identically named + ;; files open locally and remotely at the same time, and it + ;; helps with differentiating them. + (completion-extra-properties + '(:annotation-function + (lambda (name) + (let ((elt (map-elt selectables name))) + (pcase (car elt) + (:emacs + (if-let* ((file (buffer-file-name (cdr elt))) + (remote (file-remote-p file))) + (format " [%s]" remote))) + (:niri (format " [%s]" (map-elt (cdr elt) "app_id")))))))) + (target-key (completing-read "Switch to: " (map-keys selectables))) (target (map-elt selectables target-key))) |