branch: scratch/mheerdegen-preview commit 7de58240059831f4cebbfcb3bc1fca82e8cd963b Author: Michael Heerdegen <michael_heerde...@web.de> Commit: Michael Heerdegen <michael_heerde...@web.de>
WIP: Improvise eldoc support for search pattern prompt --- packages/el-search/el-search.el | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el index cb9bcd4..db62e84 100644 --- a/packages/el-search/el-search.el +++ b/packages/el-search/el-search.el @@ -916,6 +916,28 @@ nil." (timer-set-time el-search--mb-hints-timer (time-add (current-time) el-search-mb-hints-delay)) (timer-activate el-search--mb-hints-timer))) +(defun el-search-eldoc-documentation-function () + (when (catch 'result + (save-excursion + (while (condition-case nil + (progn (backward-up-list) + (if (el-search-looking-at '`(,(or 'pred 'guard) . ,_)) + (throw 'result nil) + t)) + (scan-error nil))) + t)) + (pcase-let (((and current-fsym `(,fnsym ,index)) + (elisp--fnsym-in-current-sexp))) + (defvar el-search--pcase-macros) ;defined later + (let (pattern-def help) + (and fnsym + (setq pattern-def (cdr (assoc fnsym el-search--pcase-macros))) + (setq help (help-split-fundoc (documentation pattern-def) fnsym)) + (elisp--highlight-function-argument + current-fsym + (format "%s" (cdar (read-from-string (car help)))) + index (concat (symbol-name fnsym) ": "))))))) + (defvar el-search--this-session-match-count-data nil) (defun el-search-read-pattern-setup-mb-hints () @@ -923,7 +945,9 @@ nil." (setq el-search--this-session-match-count-data nil) (when (timerp el-search--mb-hints-timer) (cancel-timer el-search--mb-hints-timer)) (setq el-search--mb-hints-timer nil) - (add-hook 'post-command-hook #'el-search-read-pattern-trigger-mb-hints t t))) + (add-hook 'post-command-hook #'el-search-read-pattern-trigger-mb-hints t t)) + (add-function :before-until (local 'eldoc-documentation-function) + #'el-search-eldoc-documentation-function)) (defvar el-search--search-pattern-1-do-fun nil) (defvar el-search--busy-animation