diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2020-09-23 00:05:14 -0700 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2020-09-23 00:05:14 -0700 |
| commit | e98b4b8517b786ee3e5d4086d6b3017a23d7d2cc (patch) | |
| tree | 07a0b633ebd2e9f4fde66abbe10491df9b61e73d | |
| parent | 27373703625fdf86fe0f71500767802a28350b9f (diff) | |
WIP: more specific symbol extractionsmarter-syms
Based on #235 and #163.
| -rw-r--r-- | helpful.el | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -2688,11 +2688,36 @@ See also `helpful-callable' and `helpful-variable'." (funcall helpful-switch-buffer-function (helpful--buffer symbol nil)) (helpful-update)) +(defun helpful--variable-at-point () + (let ((var (variable-at-point))) + (when (helpful--variable-p var) + var))) + +(defun helpful--function-at-point () + (let ((sym (symbol-at-point)) + (enclosing-sym (function-called-at-point))) + (if (fboundp sym) + sym + enclosing-sym))) + +(defun helpful--symbol-at-point () + "Find the most relevant symbol at or around point. +Returns nil if nothing found." + (let ((var (variable-at-point)) + (sym (symbol-at-point)) + (fun-sym (function-called-at-point))) + (when (zerop var) + (setq var nil)) + (cond + ((helpful--bound-p var) var) + ((helpful--bound-p sym) sym) + ((helpful--bound-p fun-sym) fun-sym)))) + ;;;###autoload (defun helpful-at-point () "Show help for the symbol at point." (interactive) - (-if-let (symbol (symbol-at-point)) + (-if-let (symbol (helpful--symbol-at-point)) (helpful-symbol symbol) (user-error "There is no symbol at point."))) |
