all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71354: Replace anonymous lambda timers with named functions for better tracing
@ 2024-06-04  3:34 Matthew Bauer
  2024-06-04  8:22 ` Andrea Corallo
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Bauer @ 2024-06-04  3:34 UTC (permalink / raw)
  To: 71354

[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]

Tags: patch


I noticed a few timers found in ‘M-x list-timers’ were anonymous lambdas
that show up like this:

   *           0.5s            t #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_9>

That’s not particularly helpful when trying to figure out what timers
are being run. I tracked down the two that I have configured to eldoc
and jit-lock. This gives them names that can be traced.


In GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin23.5.0, NS
appkit-2487.60 Version 14.5 (Build 23F79))
Repository revision: 0cb511b33bc96fc30d8e5286a474b4eea54817e3
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.5

Configured using:
 'configure
 --prefix=/nix/store/bj6mdh15nkgh2xbdzzsly43m9q7mi0zp-emacs-git-20240531.0
 --disable-build-details --with-modules --disable-ns-self-contained
 --with-ns --with-compress-install --with-toolkit-scroll-bars
 --with-native-compilation --without-imagemagick --with-mailutils
 --without-small-ja-dic --with-tree-sitter --without-xinput2
 --without-xwidgets --without-dbus --without-selinux'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: remove-anonymous-timer-lambdas.patch --]
[-- Type: text/patch, Size: 3710 bytes --]

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 24afd03fbe6..68483ab9333 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -269,6 +269,14 @@ See `eldoc-documentation-strategy' for more detail."
     (eldoc-mode 1)))
 
 \f
+(defun eldoc--update ()
+  (when (or eldoc-mode
+            (and global-eldoc-mode
+                 (eldoc--supported-p)))
+    ;; Don't ignore, but also don't full-on signal errors
+    (with-demoted-errors "eldoc error: %s"
+      (eldoc-print-current-symbol-info)) ))
+
 (defun eldoc-schedule-timer ()
   "Ensure `eldoc-timer' is running.
 
@@ -279,13 +287,7 @@ reflect the change."
       (setq eldoc-timer
             (run-with-idle-timer
 	     eldoc-idle-delay nil
-	     (lambda ()
-               (when (or eldoc-mode
-                         (and global-eldoc-mode
-                              (eldoc--supported-p)))
-                 ;; Don't ignore, but also don't full-on signal errors
-                 (with-demoted-errors "eldoc error: %s"
-                   (eldoc-print-current-symbol-info)) )))))
+	     'eldoc--update)))
 
   ;; If user has changed the idle delay, update the timer.
   (cond ((not (= eldoc-idle-delay eldoc-current-idle-delay))
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index 05c0bd847b3..c0fc41b5afe 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -179,6 +179,10 @@ If nil, contextual fontification is disabled.")
 \f
 ;;; JIT lock mode
 
+(defun jit-lock-context--update ()
+  (unless jit-lock--antiblink-grace-timer
+    (jit-lock-context-fontify)))
+
 (defun jit-lock-mode (arg)
   "Toggle Just-in-time Lock mode.
 Turn Just-in-time Lock mode on if and only if ARG is non-nil.
@@ -255,10 +259,7 @@ If you need to debug code run from jit-lock, see `jit-lock-debug-mode'."
     (when (eq jit-lock-contextually t)
       (unless jit-lock-context-timer
         (setq jit-lock-context-timer
-              (run-with-idle-timer jit-lock-context-time t
-                                   (lambda ()
-                                     (unless jit-lock--antiblink-grace-timer
-                                       (jit-lock-context-fontify))))))
+              (run-with-idle-timer jit-lock-context-time t 'jit-lock-context--update)))
       (add-hook 'post-command-hook #'jit-lock--antiblink-post-command nil t)
       (setq jit-lock-context-unfontify-pos
             (or jit-lock-context-unfontify-pos (point-max))))
@@ -706,6 +707,10 @@ will take place when text is fontified stealthily."
               ;; buffer, only jit-lock-context-* will re-fontify it.
               (min jit-lock-context-unfontify-pos jit-lock-start))))))
 
+(defun jit-lock--antiblink-update ()
+  (jit-lock-context-fontify)
+  (setq jit-lock--antiblink-grace-timer nil))
+
 (defun jit-lock--antiblink-post-command ()
   (let* ((new-l-b-p (copy-marker (syntax--lbp)))
          (l-b-p-2 (syntax--lbp 2))
@@ -722,11 +727,7 @@ will take place when text is fontified stealthily."
            (and same-line
                 (null jit-lock--antiblink-string-or-comment) new-s-o-c)
            (setq jit-lock--antiblink-grace-timer
-                 (run-with-idle-timer jit-lock-antiblink-grace nil
-                                      (lambda ()
-                                        (jit-lock-context-fontify)
-                                        (setq jit-lock--antiblink-grace-timer
-                                              nil)))))
+                 (run-with-idle-timer jit-lock-antiblink-grace nil 'jit-lock--antiblink-update)))
           (;; Closed an unterminated multiline string.
            (and same-line
                 (null new-s-o-c) jit-lock--antiblink-string-or-comment)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#71354: Replace anonymous lambda timers with named functions for better tracing
  2024-06-04  3:34 bug#71354: Replace anonymous lambda timers with named functions for better tracing Matthew Bauer
@ 2024-06-04  8:22 ` Andrea Corallo
  0 siblings, 0 replies; 2+ messages in thread
From: Andrea Corallo @ 2024-06-04  8:22 UTC (permalink / raw)
  To: Matthew Bauer; +Cc: 71354

Matthew Bauer <mjbauer95@gmail.com> writes:

> Tags: patch
>
>
> I noticed a few timers found in ‘M-x list-timers’ were anonymous lambdas
> that show up like this:
>
>    *           0.5s            t #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_9>
>
> That’s not particularly helpful when trying to figure out what timers
> are being run. I tracked down the two that I have configured to eldoc
> and jit-lock. This gives them names that can be traced.

I'm okay with the change.  Another fix maybe more general would have
having more information in the subr name.  I think Alan is working on
this in bug#66750 but I suspect it will not go in for emacs 30.

  Andrea





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-04  8:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04  3:34 bug#71354: Replace anonymous lambda timers with named functions for better tracing Matthew Bauer
2024-06-04  8:22 ` Andrea Corallo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.