Giter Club home page Giter Club logo

Comments (7)

CIAvash avatar CIAvash commented on July 23, 2024 1

As a quick test, I evaluated this code and the slowness went away:

(progn
  (setq-local eldoc-box-position-function #'eldoc-box--default-at-point-position-function)
  (setq-local eldoc-message-function #'eldoc-box--eldoc-message-function)
  (eldoc-box-hover-mode))

from eldoc-box.

CIAvash avatar CIAvash commented on July 23, 2024

Using Emacs 28.1 on Arch Linux and Sway (Wayland)

from eldoc-box.

K-gihu avatar K-gihu commented on July 23, 2024

Same on emacs 29.0.50 on arch linux and Gnome 42.0.
The above quick test also made it not slow.

from eldoc-box.

casouri avatar casouri commented on July 23, 2024

I guess the slowness comes from the "follow cursor" feature? I can make that feature optional so it isn't slow by default.

from eldoc-box.

lthms avatar lthms commented on July 23, 2024

I can confirm the issue, and my profiler reports tend to point to the follow cursor feature indeed. For some reason, disabling/enabling the mode fix my problem most of the time, but having a more future-proof approach would be neat!

from eldoc-box.

lthms avatar lthms commented on July 23, 2024

The following patch makes the feature usable again.

diff --git a/eldoc-box.el b/eldoc-box.el
index 7f7c8da..f563e57 100644
--- a/eldoc-box.el
+++ b/eldoc-box.el
@@ -317,29 +317,24 @@ FRAME is the childframe, WINDOW is the primary window."
     ;; move position
     (set-frame-position frame (car pos) (cdr pos))))
 
-(defvar eldoc-box--inhibit-childframe-timer nil
-  "When this timer is on, inhibit childframe display.
-Intended for follow-cursor to disable display when moving cursor.")
-
 (defun eldoc-box--inhibit-childframe-for (sec)
-  "Inhibit display of childframe for SEC seconds."
-  (when eldoc-box--inhibit-childframe-timer
-    (cancel-timer eldoc-box--inhibit-childframe-timer))
-  (eldoc-box-quit-frame)
-  (setq eldoc-box--inhibit-childframe t
-        eldoc-box--inhibit-childframe-timer
-        (run-with-timer sec nil
-                        (lambda ()
-                          (setq eldoc-box--inhibit-childframe nil)))))
+  "Inhibit display of childframe for SEC seconds after Emacs is idle again."
+  (unless eldoc-box--inhibit-childframe
+    (setq eldoc-box--inhibit-childframe t)
+    (eldoc-box-quit-frame)
+    (run-with-idle-timer sec nil
+                    (lambda ()
+                      (setq eldoc-box--inhibit-childframe nil)))))
 
 (defun eldoc-box--follow-cursor ()
   "Make childframe follow cursor in at-point mode."
-  (if (member this-command eldoc-box-self-insert-command-list)
-      (progn (when (frame-live-p eldoc-box--frame)
-               (eldoc-box--update-childframe-geometry
-                eldoc-box--frame (frame-selected-window eldoc-box--frame))))
-    ;; if not typing, inhibit display
-    (eldoc-box--inhibit-childframe-for 0.2)))
+  (unless eldoc-box--inhibit-childframe
+    (if (member this-command eldoc-box-self-insert-command-list)
+        (progn (when (frame-live-p eldoc-box--frame)
+                 (eldoc-box--update-childframe-geometry
+                  eldoc-box--frame (frame-selected-window eldoc-box--frame))))
+      ;; if not typing, inhibit display
+      (eldoc-box--inhibit-childframe-for 0.5))))
 
 (defun eldoc-box--get-frame (buffer)
   "Return a childframe displaying BUFFER.

Feel free to use the diff if you find it reasonable. I can also fill a PR if you prefer.

from eldoc-box.

asymmetric avatar asymmetric commented on July 23, 2024

As mentioned in the README (and from personal experience), there's still a performance penalty when enabling this mode.

Is this something that can be solved in principle, or are there some fundamental issues?

from eldoc-box.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.