aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2020-07-18 23:50:00 +0100
committerJoão Távora2020-07-19 00:59:14 +0100
commit4a7ecaaee06579e582b8560fc495eafd375b1f3b (patch)
tree22a336ac4cab8bde8929426d3a21533ad0686400
parent8d05f21946fa846edf8d9c2c77e9e6cc066bbae5 (diff)
downloademacs-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.el132
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
666That function's job is to run the `eldoc-documentation-functions' 666That function's job is to run the `eldoc-documentation-functions'
667special hook, using the `run-hook' family of functions. The way 667special hook, using the `run-hook' family of functions. ElDoc's
668we invoke it here happens in a way strategy function can itself 668built-in strategy functions play along with the
669call `eldoc--make-callback' to produce values to give to the 669`eldoc--make-callback' protocol, using it to produce callback to
670elements of the special hook `eldoc-documentation-functions'. 670feed to the functgions of `eldoc-documentation-functions'.
671 671
672For each element of `eldoc-documentation-functions' invoked a 672Other third-party strategy functions do not use
673corresponding call to `eldoc--make-callback' must be made. See 673`eldoc--make-callback'. They must find some alternate way to
674docstring of `eldoc--make-callback' for the types of callback 674produce callbacks to feed to `eldoc-documentation-function' and
675that can be produced. 675should endeavour to display the docstrings eventually produced."
676 676 (let* (;; How many callbacks have been created by the strategy
677If the strategy function does not use `eldoc--make-callback', it 677 ;; fucntion and passed to elements of
678must find some alternate way to produce callbacks to feed to 678 ;; `eldoc-documentation-functions'.
679`eldoc-documentation-function', and those callbacks should
680endeavour 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."