Improve target handling for forge embark target finder

This commit is contained in:
Jeremy Dormitzer 2024-04-23 12:00:27 -04:00
parent d6fdb649ce
commit 43204e2ced

View File

@ -122,11 +122,17 @@ targets."
"U" #'password-store-url) "U" #'password-store-url)
(add-to-list 'embark-keymap-alist '(password-store . embark-password-store-actions))) (add-to-list 'embark-keymap-alist '(password-store . embark-password-store-actions)))
(add-to-list 'embark-target-injection-hooks '(xref-find-references embark--ignore-target)) (add-to-list 'embark-target-injection-hooks '(xref-find-references embark--ignore-target))
(with-eval-after-load 'forge (defun embark-target-finder-forge ()
(defun embark-target-finder-forge () "Identify Forge commits/issues/PRs at point."
"Identify Forge commits/issues/PRs at point." (when-let ((target (and
(when-let ((target (forge--browse-target))) (fboundp 'forge--browse-target)
`(forge . ,(format "%s" target))))) (forge--browse-target))))
`(forge ,(or
(and (stringp target) target)
(ignore-errors (forge-get-url target))
(s-chomp (thing-at-point 'line t)))
,(line-beginning-position)
. ,(line-end-position))))
(add-to-list 'embark-target-finders #'embark-target-finder-forge) (add-to-list 'embark-target-finders #'embark-target-finder-forge)
(defvar-keymap embark-forge-actions (defvar-keymap embark-forge-actions
:doc "Keymap for actions for forge." :doc "Keymap for actions for forge."