about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs-pkgs/niri/niri.el15
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)))