Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finder for symbols in the help buffer #595

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion embark.el
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ or a list of such symbols."
embark-target-sentence-at-point
embark-target-paragraph-at-point
embark-target-defun-at-point
embark-target-prog-heading-at-point)
embark-target-prog-heading-at-point
embark-target-help-symbol)
"List of functions to determine the target in current context.
Each function should take no arguments and return either:

Expand Down Expand Up @@ -951,6 +952,32 @@ their own target finder. See for example
raw)
,beg . ,end))))))

(defun embark-target-help-symbol ()
"Return the subject of the current help buffer.

Guess symbol's heuristically. If `help-mode--current-data'
has a :type property then follow that. If not return 'function if
if the symbol passes `functionp', or 'face if it passes `facep'
or 'symbol as a default."
(when help-mode--current-data
(let* ((sym (plist-get help-mode--current-data :symbol))
(type
;; This is not perfect but covers lots of cases
(cond ((alist-get
(plist-get help-mode--current-data :type)
'((defvar . variable)
(defface . face))))
((functionp sym) 'function)
((facep sym) 'face)
'symbol))
(name (symbol-name sym))
beg end)
(save-excursion
(goto-char 0)
(setq end (search-forward name))
(setq beg (search-backward name)))
`(,type ,name ,beg . ,end))))

(defun embark--cycle-key ()
"Return the key to use for `embark-cycle'."
(if embark-cycle-key
Expand Down