branch: elpa/eldoc-mouse
commit 44956175c0a303baf89b665e9869a7d252c0d810
Merge: e26c908511f a96d35de86e
Author: huangfeiyu <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #14 from ideasman42/pr-reformat
Cleanup: reformat with 80 column width
---
eldoc-mouse.el | 95 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 68 insertions(+), 27 deletions(-)
diff --git a/eldoc-mouse.el b/eldoc-mouse.el
index 660b03b3d3a..d92d2abe5bd 100644
--- a/eldoc-mouse.el
+++ b/eldoc-mouse.el
@@ -111,7 +111,9 @@ By default, posframe will not used by eldoc.")
(when-let* ((symbol-bounds (bounds-of-thing-at-point 'symbol)))
(cond
(eldoc-mouse-mode
- (add-hook 'eldoc-documentation-functions
#'eldoc-mouse-hover-eldoc-function nil t)
+ (add-hook
+ 'eldoc-documentation-functions #'eldoc-mouse-hover-eldoc-function
+ nil t)
(setq-local eldoc-mouse-last-symbol-bounds symbol-bounds)
(setq-local eldoc-mouse-unsupress-posframe t)
@@ -119,21 +121,29 @@ By default, posframe will not used by eldoc.")
(setq eldoc--last-request-state nil)
(eldoc-print-current-symbol-info)
- (remove-hook 'eldoc-documentation-functions
#'eldoc-mouse-hover-eldoc-function t))
+ (remove-hook
+ 'eldoc-documentation-functions #'eldoc-mouse-hover-eldoc-function
+ t))
(t
- (remove-hook 'eldoc-documentation-functions
#'eglot-signature-eldoc-function t)
+ (remove-hook
+ 'eldoc-documentation-functions #'eglot-signature-eldoc-function
+ t)
(setq-local eldoc-mouse-last-symbol-bounds symbol-bounds)
(unless eldoc-mouse--original-display-functions
- (setq-local eldoc-mouse--original-display-functions
eldoc-display-functions))
+ (setq-local eldoc-mouse--original-display-functions
+ eldoc-display-functions))
(setq-local eldoc-display-functions
- (append eldoc-display-functions
'(eldoc-mouse-display-in-posframe)))
+ (append
+ eldoc-display-functions '(eldoc-mouse-display-in-posframe)))
(setq-local eldoc-mouse-unsupress-posframe t)
;; Make sure eldoc always send the request to get doc.
(setq eldoc--last-request-state nil)
(eldoc-print-current-symbol-info)
- (add-hook 'eldoc-documentation-functions
#'eglot-signature-eldoc-function nil t)))))
+ (add-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function
+ nil
+ t)))))
(defun eldoc-mouse-enable ()
"Enable eldoc-mouse in all `eglot-managed-p' buffers."
(when (eglot-managed-p)
@@ -141,32 +151,43 @@ By default, posframe will not used by eldoc.")
(setq track-mouse t)
(setq-local eldoc-mouse--original-display-functions
eldoc-display-functions)
(setq-local eldoc-display-functions
- (append eldoc-display-functions
'(eldoc-mouse-display-in-posframe)))
+ (append
+ eldoc-display-functions '(eldoc-mouse-display-in-posframe)))
;; Avoid unnecessary document of signatures that clutters the document.
- (remove-hook 'eldoc-documentation-functions
#'eglot-signature-eldoc-function t)
+ (remove-hook 'eldoc-documentation-functions
#'eglot-signature-eldoc-function
+ t)
;; Avoid show document for the cursor.
(remove-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function t)
;; Enable highlight symbol under the cursor.
;; In the future the following line is no longer necessary,
- ;; as emacs use a specific function `eglot-highlight-eldoc-function' for
highlighting.
+ ;; as emacs use a specific function `eglot-highlight-eldoc-function'
+ ;; for highlighting.
;; And here, we want to keep the highlight at cursor.
- ;; see details:
https://cgit.git.savannah.gnu.org/cgit/emacs.git/commit/?id=60166a419f601b413db86ddce186cc387e8ec269
+ ;; See details:
+ ;;
https://cgit.git.savannah.gnu.org/cgit/emacs.git/commit/?id=60166a419f601b413db86ddce186cc387e8ec269
(when (fboundp 'eglot--highlight-piggyback)
- (add-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
nil t))
+ (add-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
+ nil
+ t))
(local-set-key [mouse-movement] #'eldoc-mouse-doc-on-mouse)))
(defun eldoc-mouse-disable ()
"Disable eldoc-mouse in all `eglot-managed-p' buffers."
(setq track-mouse nil)
(when eldoc-mouse--original-display-functions
- (setq-local eldoc-display-functions
eldoc-mouse--original-display-functions))
+ (setq-local eldoc-display-functions
+ eldoc-mouse--original-display-functions))
(when (fboundp 'eglot--highlight-piggyback)
(remove-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
t))
(unless (memq #'eglot-signature-eldoc-function eldoc-documentation-functions)
- (add-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function
nil t))
+ (add-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function
+ nil
+ t))
(unless (memq #'eglot-hover-eldoc-function eldoc-documentation-functions)
- (add-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function nil
t))
+ (add-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function
+ nil
+ t))
(when eldoc-mouse-mouse-timer
(cancel-timer eldoc-mouse-mouse-timer)
@@ -193,32 +214,45 @@ Support close the popup when user switch buffer."
POS is the buffer position under the mouse cursor."
(when (and pos
(number-or-marker-p pos)
- (not (eldoc-mouse-is-mouse-hovering-posframe?
eldoc-mouse-posframe-buffer-name))
+ (not
+ (eldoc-mouse-is-mouse-hovering-posframe?
+ eldoc-mouse-posframe-buffer-name))
(or (null eldoc-mouse-last-symbol-bounds)
(< pos (car eldoc-mouse-last-symbol-bounds))
(> pos (cdr eldoc-mouse-last-symbol-bounds))))
(eldoc-mouse--hide-posframe)
(when (fboundp 'eglot--highlight-piggyback)
- (remove-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
t))
+ (remove-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
+ t))
(when eldoc-mouse-mouse-overlay
(delete-overlay eldoc-mouse-mouse-overlay))
(save-excursion
- (add-hook 'eldoc-documentation-functions
#'eldoc-mouse-hover-eldoc-function nil t)
+ (add-hook
+ 'eldoc-documentation-functions #'eldoc-mouse-hover-eldoc-function
+ nil t)
(goto-char pos)
- (setq-local eldoc-mouse-last-symbol-bounds (bounds-of-thing-at-point
'symbol))
+ (setq-local eldoc-mouse-last-symbol-bounds
+ (bounds-of-thing-at-point 'symbol))
;; Use (nth 4 (syntax-ppss)) to check if the mouse is over a code
comment.
;; based on the answer from
;; https://emacs.stackexchange.com/questions/14269/14270#14270
- (when (and eldoc-mouse-last-symbol-bounds (not (eolp)) (not (nth 4
(syntax-ppss))))
+ (when (and eldoc-mouse-last-symbol-bounds
+ (not (eolp))
+ (not (nth 4 (syntax-ppss))))
(setq-local eldoc-mouse-unsupress-posframe t)
(eldoc-print-current-symbol-info)
(setq-local eldoc-mouse-mouse-overlay
(make-overlay
- (car eldoc-mouse-last-symbol-bounds) (cdr
eldoc-mouse-last-symbol-bounds)))
+ (car eldoc-mouse-last-symbol-bounds)
+ (cdr eldoc-mouse-last-symbol-bounds)))
(overlay-put eldoc-mouse-mouse-overlay 'face 'highlight))
- (remove-hook 'eldoc-documentation-functions
#'eldoc-mouse-hover-eldoc-function t)
+ (remove-hook
+ 'eldoc-documentation-functions #'eldoc-mouse-hover-eldoc-function
+ t)
(when (fboundp 'eglot--highlight-piggyback)
- (add-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
nil t)))))
+ (add-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
+ nil
+ t)))))
(defun eldoc-mouse--hide-posframe ()
"Hide the posframe."
@@ -236,7 +270,9 @@ POS is the buffer position under the mouse cursor."
(when eldoc-mouse-mouse-timer
(cancel-timer eldoc-mouse-mouse-timer))
(setq eldoc-mouse-mouse-timer
- (run-with-idle-timer eldoc-mouse-idle-time nil
#'eldoc-mouse-show-doc-at pos)))))
+ (run-with-idle-timer
+ eldoc-mouse-idle-time nil #'eldoc-mouse-show-doc-at
+ pos)))))
(defun eldoc-mouse-hover-eldoc-function (cb)
"Modify the `eglot-hover-eldoc-function'.
@@ -252,9 +288,11 @@ So it won't call `eglot--highlight-piggyback` with `CB`."
Remove all eglot hooks and keep highlighting on cursor,
add eldoc-mouse's `eldoc-display-functions'."
(setq-local eldoc-display-functions
- (append eldoc-display-functions
'(eldoc-mouse-display-in-posframe)))
+ (append
+ eldoc-display-functions '(eldoc-mouse-display-in-posframe)))
;; Avoid unnecessary document of signatures that clutters the document.
- (remove-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function
t)
+ (remove-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function
+ t)
;; Avoid show document for the cursor.
(remove-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function t)
;; Enable highlight symbol under the cursor.
@@ -262,9 +300,12 @@ add eldoc-mouse's `eldoc-display-functions'."
;; as emacs use a specific function eglot-highlight-eldoc-function
;; for highlighting.
;; And here, we want to keep the highlight at cursor.
- ;; see details:
https://cgit.git.savannah.gnu.org/cgit/emacs.git/commit/?id=60166a419f601b413db86ddce186cc387e8ec269
+ ;; See details:
+ ;;
https://cgit.git.savannah.gnu.org/cgit/emacs.git/commit/?id=60166a419f601b413db86ddce186cc387e8ec269
(when (fboundp 'eglot--highlight-piggyback)
- (add-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback nil
t)))
+ (add-hook 'eldoc-documentation-functions #'eglot--highlight-piggyback
+ nil
+ t)))
(defun eldoc-mouse-is-mouse-hovering-posframe? (posframe-name)
"Check if the mouse is hovering over the given posframe `POSFRAME-NAME'."