feat(emacs): 파일 이름을 넣음
All checks were successful
build / build (push) Successful in 2m53s

This commit is contained in:
2026-04-02 08:58:41 -06:00
parent ecfb399127
commit a9f95a1675
2 changed files with 36 additions and 1 deletions

View File

@@ -69,7 +69,8 @@
(general-def (general-def
:prefix-map 'syd-leader-insert-map :prefix-map 'syd-leader-insert-map
"u" #'insert-char "u" #'insert-char
"e" #'emoji-insert) "e" #'emoji-insert
"p" #'syd-insert-file-name)
;; This is necessary to properly rebind `universal-argument'. ;; This is necessary to properly rebind `universal-argument'.
;; `universal-argument-more' is a command that provides additional prefixes ;; `universal-argument-more' is a command that provides additional prefixes

View File

@@ -193,4 +193,38 @@ form."
(cons mode (intern (concat (match-string 1 s) "-ts-mode")))) (cons mode (intern (concat (match-string 1 s) "-ts-mode"))))
(error "Symbol `%c' is not a mode." 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 ()
(interactive)
(let* ((path (read-file-name "Path: " nil nil 'confirm))
(proj-root (project-root (project-current)))
(alts
`((,(file-relative-name path proj-root) . "Project-relative")
(,(file-relative-name path default-directory) . "File-relative")
(,path . "Absolute")
("... (choose a dir)")))
(choice
(completing-read
"Variant: "
(lambda (s p flag)
(pcase flag
('metadata
`(metadata
(annotation-function
. ,(lambda (s)
(when-let* ((desc (cdr (assoc s alts))))
(syd--insert-file-name-annotation
desc))))))
(_ (all-completions s (mapcar #'car alts) p)))))))
(if (equal choice "... (choose a root)")
(insert (file-relative-name
path (read-file-name "Relative to: " nil nil
'confirm)))
(insert choice))))
(provide 'syd/prelude) (provide 'syd/prelude)