unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Chow Loong Jin <hyperair@debian.org>
To: 16545@debbugs.gnu.org
Subject: bug#16545: 24.3.50; Patch to coalesce calls to linum-update-current
Date: Sat, 25 Jan 2014 15:57:40 +0800	[thread overview]
Message-ID: <20140125075737.GA1843@thinkpwn> (raw)


[-- 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 --]

             reply	other threads:[~2014-01-25  7:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-25  7:57 Chow Loong Jin [this message]
2014-01-26  1:18 ` bug#16545: 24.3.50; Patch to coalesce calls to linum-update-current 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140125075737.GA1843@thinkpwn \
    --to=hyperair@debian.org \
    --cc=16545@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).