Skip to content

Commit

Permalink
Refine type of symbol at point to command or variable if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
oantolin committed Jan 11, 2021
1 parent cf16ab4 commit 296ad80
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion embark.el
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ a string, or nil to indicate it found no target."
(defcustom embark-transformer-alist
'((consult-buffer . embark-refine-consult-buffer-type)
(minor-mode . embark-lookup-lighter-minor-mode)
(xref-location . embark-set-xref-location-default-action))
(xref-location . embark-set-xref-location-default-action)
(symbol . embark-refine-symbol-type))
"Alist associating type to functions for transforming targets.
Each function should take a target string and return a pair of
the form a `cons' of the new type and the new target."
Expand Down Expand Up @@ -655,6 +656,15 @@ removes its prefix typing character."
;; new buffer case, don't remove first char
(cons 'buffer target))))

(defun embark-refine-symbol-type (target)
"Refine symbol TARGET to command or variable if possible."
(when-let ((symbol (intern-soft target)))
(cons (cond
((commandp symbol) 'command)
((boundp symbol) 'variable)
(t 'symbol))
target)))

(defun embark-lookup-lighter-minor-mode (target)
"If TARGET is a lighter, look up its minor mode.
Expand Down

0 comments on commit 296ad80

Please sign in to comment.