From 43204e2ced7da9d50da5b7462ab41f50de8860d7 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 23 Apr 2024 12:00:27 -0400 Subject: [PATCH] Improve target handling for forge embark target finder --- emacs/.emacs.d/config/init-completion.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/emacs/.emacs.d/config/init-completion.el b/emacs/.emacs.d/config/init-completion.el index cc61690..51ebd8f 100644 --- a/emacs/.emacs.d/config/init-completion.el +++ b/emacs/.emacs.d/config/init-completion.el @@ -122,11 +122,17 @@ targets." "U" #'password-store-url) (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)) - (with-eval-after-load 'forge - (defun embark-target-finder-forge () - "Identify Forge commits/issues/PRs at point." - (when-let ((target (forge--browse-target))) - `(forge . ,(format "%s" target))))) + (defun embark-target-finder-forge () + "Identify Forge commits/issues/PRs at point." + (when-let ((target (and + (fboundp 'forge--browse-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) (defvar-keymap embark-forge-actions :doc "Keymap for actions for forge."