|
13 | 13 | (file-header-defins jcs-insert-lisp-template "lisp" "default.txt"
|
14 | 14 | "Lisp file header format.")
|
15 | 15 |
|
| 16 | +;; |
| 17 | +;; (@* "ElDoc" ) |
| 18 | +;; |
| 19 | + |
| 20 | +(defun jcs--eldoc-remove-signature (str) |
| 21 | + "Remove function signature from STR." |
| 22 | + (with-temp-buffer |
| 23 | + (insert str) |
| 24 | + (goto-char (point-max)) |
| 25 | + (when (jcs-current-char-equal-p ")") |
| 26 | + (backward-sexp) |
| 27 | + (delete-region (point) (point-max))) |
| 28 | + (string-trim (buffer-string)))) |
| 29 | + |
| 30 | +(defun jcs--elisp-eldoc-var-docstring-with-value (callback &rest _) |
| 31 | + "Edited from the function `elisp-eldoc-var-docstring-with-value'." |
| 32 | + (when-let ((cs (elisp--current-symbol))) |
| 33 | + (when (and (boundp cs) |
| 34 | + ;; nil and t are boundp! |
| 35 | + (not (null cs)) |
| 36 | + (not (eq cs t))) |
| 37 | + (funcall callback |
| 38 | + (format "%.100S\n%s" |
| 39 | + (symbol-value cs) |
| 40 | + (let* ((doc (documentation-property |
| 41 | + cs 'variable-documentation t)) |
| 42 | + (more (- (length doc) 1000))) |
| 43 | + (concat (propertize |
| 44 | + (jcs-fill-string |
| 45 | + (if (string= doc "nil") |
| 46 | + "Undocumented." |
| 47 | + doc)) |
| 48 | + 'face 'font-lock-doc-face) |
| 49 | + (when (> more 0) |
| 50 | + (format "[%sc more]" more))))) |
| 51 | + :thing cs |
| 52 | + :face 'font-lock-variable-name-face)))) |
| 53 | + |
| 54 | +(defun jcs--elisp-eldoc-funcall (callback &rest _ignored) |
| 55 | + "Edited from the function `elisp-eldoc-funcall'." |
| 56 | + (let* ((sym-info (elisp--fnsym-in-current-sexp)) |
| 57 | + (fn-sym (car sym-info)) |
| 58 | + (doc (or (ignore-errors (documentation fn-sym t)) |
| 59 | + "")) |
| 60 | + (doc (jcs--eldoc-remove-signature doc)) |
| 61 | + (doc (jcs-fill-string doc))) |
| 62 | + (when fn-sym |
| 63 | + (funcall callback (format "%s\n\n%s" |
| 64 | + (apply #'elisp-get-fnsym-args-string sym-info) |
| 65 | + (propertize doc 'face 'font-lock-doc-face)) |
| 66 | + :thing fn-sym |
| 67 | + :face (if (functionp fn-sym) |
| 68 | + 'font-lock-function-name-face |
| 69 | + 'font-lock-keyword-face))))) |
| 70 | + |
16 | 71 | ;;
|
17 | 72 | ;; (@* "Hooks" )
|
18 | 73 | ;;
|
|
25 | 80 |
|
26 | 81 | (company-fuzzy-backend-add-before 'company-elisp-keywords 'company-dabbrev)
|
27 | 82 |
|
| 83 | + (add-hook 'eldoc-documentation-functions |
| 84 | + #'jcs--elisp-eldoc-funcall nil t) |
| 85 | + (add-hook 'eldoc-documentation-functions |
| 86 | + #'jcs--elisp-eldoc-var-docstring-with-value nil t) |
| 87 | + |
28 | 88 | (eask-api-setup))
|
29 | 89 |
|
30 | 90 | (jcs-add-hook 'emacs-lisp-compilation-mode-hook
|
|
0 commit comments