all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#16545: 24.3.50; Patch to coalesce calls to linum-update-current
@ 2014-01-25  7:57 Chow Loong Jin
  2014-01-26  1:18 ` Glenn Morris
  2019-06-26 14:49 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 6+ messages in thread
From: Chow Loong Jin @ 2014-01-25  7:57 UTC (permalink / raw)
  To: 16545


[-- Attachment #1.1: Type: text/plain, Size: 479 bytes --]

When navigating using C-n/C-p with a high key repeat rate, causing
linum-schedule to be called many times in quick succession,
linum-update-current gets called as many times in linum-schedule,
eventhough one call per round should be enough to renumber the lines.

This patch adds a linum-delay-seconds option defaulting to 10ms to delay
the call to linum-update-current, thus coalescing all calls to
linum-update-current until Emacs settles for 10ms.

--
Kind regards,
Loong Jin

[-- Attachment #1.2: 0001-Add-customization-option-to-delay-linum-updates.patch --]
[-- Type: text/x-diff, Size: 1999 bytes --]

From 13a9fde7a9b0a4f7a40e6d5e9ce3447bbfed777b Mon Sep 17 00:00:00 2001
From: Chow Loong Jin <hyperair@debian.org>
Date: Fri, 24 Jan 2014 09:47:19 +0800
Subject: [PATCH] Add customization option to delay linum updates

When linum-schedule is called many times in quick succession, delay
the update by linum-delay-seconds, and coalesce all calls to
linum-update-current to avoid useless repeated calls.

Signed-off-by: Chow Loong Jin <hyperair@debian.org>
---
 lisp/linum.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/linum.el b/lisp/linum.el
index d91ce11..50759b5 100644
--- a/lisp/linum.el
+++ b/lisp/linum.el
@@ -37,6 +37,7 @@
 (defvar linum-available nil "Overlays available for reuse.")
 (defvar linum-before-numbering-hook nil
   "Functions run in each buffer before line numbering starts.")
+(defvar linum-timer-object nil "Timer object for use with ilnum-delay")
 
 (mapc #'make-variable-buffer-local '(linum-overlays linum-available))
 
@@ -71,6 +72,10 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
   "Delay updates to give Emacs a chance for other changes."
   :group 'linum
   :type 'boolean)
+(defcustom linum-delay-seconds 0.01
+  "Number of seconds to delay before running linum-update-window"
+  :group 'linum
+  :type 'floatp)
 
 ;;;###autoload
 (define-minor-mode linum-mode
@@ -195,7 +200,12 @@ Linum mode is a buffer-local minor mode."
 
 (defun linum-schedule ()
   ;; schedule an update; the delay gives Emacs a chance for display changes
-  (run-with-idle-timer 0 nil #'linum-update-current))
+  (if linum-timer-object
+      (cancel-timer linum-timer-object))
+  (setq linum-timer-object
+        (run-with-timer linum-delay-seconds
+                        nil
+                        #'linum-update-current)))
 
 ;; (defun linum-after-config ()
 ;;   (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visible))
-- 
1.8.3.2


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2019-06-26 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-25  7:57 bug#16545: 24.3.50; Patch to coalesce calls to linum-update-current Chow Loong Jin
2014-01-26  1:18 ` Glenn Morris
2014-01-27  4:40   ` Chow Loong Jin
2014-01-27 14:29     ` Stefan Monnier
2014-01-28  3:13       ` Chow Loong Jin
2019-06-26 14:49 ` Lars Ingebrigtsen

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.