fix(emacs): syd-insert-file-name accurately label colliding paths

This commit is contained in:
2026-04-23 07:37:49 -06:00
parent 312fa1e42c
commit 05fd169c91

View File

@@ -193,11 +193,13 @@ form."
(cons mode (intern (concat (match-string 1 s) "-ts-mode"))))
(error "Symbol `%c' is not a mode." mode))))
(defun syd--insert-file-name-annotation (x)
(concat
" "
(propertize " " 'display `(space :align-to (- right ,(+ 1 (length x)))))
x))
(defun syd--insert-file-name-annotation (descs)
(when descs
(let ((s (string-join descs ", ")))
(concat
" "
(propertize " " 'display `(space :align-to (- right ,(+ 1 (length s)))))
s))))
(defun syd-project-relative-file-name (file-name)
(file-relative-name file-name (project-root (project-current))))
@@ -231,9 +233,12 @@ form."
`(metadata
(annotation-function
. ,(lambda (s)
(when-let* ((desc (cdr (assoc s alts))))
(let ((descs
(cl-loop for (p . lbl) in alts
when (equal p s)
collect lbl)))
(syd--insert-file-name-annotation
desc))))))
descs))))))
(_ (all-completions s (mapcar #'car alts) p)))))))
(if (equal choice choose-a-dir)
(insert (file-relative-name