diff options
| author | João Távora | 2020-07-18 23:50:00 +0100 |
|---|---|---|
| committer | João Távora | 2020-07-19 00:59:14 +0100 |
| commit | 4a7ecaaee06579e582b8560fc495eafd375b1f3b (patch) | |
| tree | 22a336ac4cab8bde8929426d3a21533ad0686400 | |
| parent | 8d05f21946fa846edf8d9c2c77e9e6cc066bbae5 (diff) | |
| download | emacs-4a7ecaaee06579e582b8560fc495eafd375b1f3b.tar.gz emacs-4a7ecaaee06579e582b8560fc495eafd375b1f3b.zip | |
; Reword bits of ElDoc internal documentation
* lisp/emacs-lisp/eldoc.el (eldoc--invoke-strategy): Rewrite docstring.
(eldoc--invoke-strategy): Fix formatting and rewrite comments
| -rw-r--r-- | lisp/emacs-lisp/eldoc.el | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 510dff9ed0b..5741c524d64 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el | |||
| @@ -664,75 +664,75 @@ have the following values: | |||
| 664 | "Invoke `eldoc-documentation-strategy' function. | 664 | "Invoke `eldoc-documentation-strategy' function. |
| 665 | 665 | ||
| 666 | That function's job is to run the `eldoc-documentation-functions' | 666 | That function's job is to run the `eldoc-documentation-functions' |
| 667 | special hook, using the `run-hook' family of functions. The way | 667 | special hook, using the `run-hook' family of functions. ElDoc's |
| 668 | we invoke it here happens in a way strategy function can itself | 668 | built-in strategy functions play along with the |
| 669 | call `eldoc--make-callback' to produce values to give to the | 669 | `eldoc--make-callback' protocol, using it to produce callback to |
| 670 | elements of the special hook `eldoc-documentation-functions'. | 670 | feed to the functgions of `eldoc-documentation-functions'. |
| 671 | 671 | ||
| 672 | For each element of `eldoc-documentation-functions' invoked a | 672 | Other third-party strategy functions do not use |
| 673 | corresponding call to `eldoc--make-callback' must be made. See | 673 | `eldoc--make-callback'. They must find some alternate way to |
| 674 | docstring of `eldoc--make-callback' for the types of callback | 674 | produce callbacks to feed to `eldoc-documentation-function' and |
| 675 | that can be produced. | 675 | should endeavour to display the docstrings eventually produced." |
| 676 | 676 | (let* (;; How many callbacks have been created by the strategy | |
| 677 | If the strategy function does not use `eldoc--make-callback', it | 677 | ;; fucntion and passed to elements of |
| 678 | must find some alternate way to produce callbacks to feed to | 678 | ;; `eldoc-documentation-functions'. |
| 679 | `eldoc-documentation-function', and those callbacks should | ||
| 680 | endeavour to display the docstrings given to them." | ||
| 681 | (let* (;; how many docstrings callbaks have been | ||
| 682 | (howmany 0) | 679 | (howmany 0) |
| 683 | ;; how many calls to callbacks we're waiting on. Used by | 680 | ;; How many calls to callbacks we're still waiting on. Used |
| 684 | ;; `:patient'. | 681 | ;; by `:patient'. |
| 685 | (want 0) | 682 | (want 0) |
| 686 | ;; how many doc strings and corresponding options have been | 683 | ;; The doc strings and corresponding options registered so |
| 687 | ;; registered it. | 684 | ;; far. |
| 688 | (docs-registered '())) | 685 | (docs-registered '())) |
| 689 | (cl-labels | 686 | (cl-labels |
| 690 | ((register-doc (pos string plist) | 687 | ((register-doc |
| 691 | (when (and string (> (length string) 0)) | 688 | (pos string plist) |
| 692 | (push (cons pos (cons string plist)) docs-registered))) | 689 | (when (and string (> (length string) 0)) |
| 693 | (display-doc () | 690 | (push (cons pos (cons string plist)) docs-registered))) |
| 694 | (eldoc--handle-docs | 691 | (display-doc |
| 695 | (mapcar #'cdr | 692 | () |
| 696 | (setq docs-registered | 693 | (eldoc--handle-docs |
| 697 | (sort docs-registered | 694 | (mapcar #'cdr |
| 698 | (lambda (a b) (< (car a) (car b)))))))) | 695 | (setq docs-registered |
| 699 | (make-callback (method) | 696 | (sort docs-registered |
| 700 | (let ((pos (prog1 howmany (cl-incf howmany)))) | 697 | (lambda (a b) (< (car a) (car b)))))))) |
| 701 | (cl-ecase method | 698 | (make-callback |
| 702 | (:enthusiast | 699 | (method) |
| 703 | (lambda (string &rest plist) | 700 | (let ((pos (prog1 howmany (cl-incf howmany)))) |
| 704 | (when (and string (cl-loop for (p) in docs-registered | 701 | (cl-ecase method |
| 705 | never (< p pos))) | 702 | (:enthusiast |
| 706 | (setq docs-registered '()) | 703 | (lambda (string &rest plist) |
| 707 | (register-doc pos string plist) | 704 | (when (and string (cl-loop for (p) in docs-registered |
| 708 | (when (and (timerp eldoc--enthusiasm-curbing-timer) | 705 | never (< p pos))) |
| 709 | (memq eldoc--enthusiasm-curbing-timer | 706 | (setq docs-registered '()) |
| 710 | timer-list)) | 707 | (register-doc pos string plist) |
| 711 | (cancel-timer eldoc--enthusiasm-curbing-timer)) | 708 | (when (and (timerp eldoc--enthusiasm-curbing-timer) |
| 712 | (setq eldoc--enthusiasm-curbing-timer | 709 | (memq eldoc--enthusiasm-curbing-timer |
| 713 | (run-at-time (unless (zerop pos) 0.3) | 710 | timer-list)) |
| 714 | nil #'display-doc))) | 711 | (cancel-timer eldoc--enthusiasm-curbing-timer)) |
| 715 | t)) | 712 | (setq eldoc--enthusiasm-curbing-timer |
| 716 | (:patient | 713 | (run-at-time (unless (zerop pos) 0.3) |
| 717 | (cl-incf want) | 714 | nil #'display-doc))) |
| 718 | (lambda (string &rest plist) | 715 | t)) |
| 719 | (register-doc pos string plist) | 716 | (:patient |
| 720 | (when (zerop (cl-decf want)) (display-doc)) | 717 | (cl-incf want) |
| 721 | t)) | 718 | (lambda (string &rest plist) |
| 722 | (:eager | 719 | (register-doc pos string plist) |
| 723 | (lambda (string &rest plist) | 720 | (when (zerop (cl-decf want)) (display-doc)) |
| 724 | (register-doc pos string plist) | 721 | t)) |
| 725 | (display-doc) | 722 | (:eager |
| 726 | t)))))) | 723 | (lambda (string &rest plist) |
| 727 | (let* ((eldoc--make-callback #'make-callback) | 724 | (register-doc pos string plist) |
| 728 | (res (funcall eldoc-documentation-strategy))) | 725 | (display-doc) |
| 729 | ;; Observe the old and the new protocol: | 726 | t)))))) |
| 730 | (cond (;; Old protocol: got string, output immediately; | 727 | (let* ((eldoc--make-callback #'make-callback) |
| 731 | (stringp res) (register-doc 0 res nil) (display-doc)) | 728 | (res (funcall eldoc-documentation-strategy))) |
| 732 | (;; Old protocol: got nil, clear the echo area; | 729 | ;; Observe the old and the new protocol: |
| 733 | (null res) (eldoc--message nil)) | 730 | (cond (;; Old protocol: got string, output immediately; |
| 734 | (;; New protocol: trust callback will be called; | 731 | (stringp res) (register-doc 0 res nil) (display-doc)) |
| 735 | t)))))) | 732 | (;; Old protocol: got nil, clear the echo area; |
| 733 | (null res) (eldoc--message nil)) | ||
| 734 | (;; New protocol: trust callback will be called; | ||
| 735 | t)))))) | ||
| 736 | 736 | ||
| 737 | (defun eldoc-print-current-symbol-info (&optional interactive) | 737 | (defun eldoc-print-current-symbol-info (&optional interactive) |
| 738 | "Document thing at point." | 738 | "Document thing at point." |