From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chow Loong Jin Newsgroups: gmane.emacs.bugs Subject: bug#16545: 24.3.50; Patch to coalesce calls to linum-update-current Date: Sat, 25 Jan 2014 15:57:40 +0800 Message-ID: <20140125075737.GA1843@thinkpwn> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eJnRUKwClWJh1Khz" X-Trace: ger.gmane.org 1390636760 16439 80.91.229.3 (25 Jan 2014 07:59:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Jan 2014 07:59:20 +0000 (UTC) To: 16545@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 25 08:59:26 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W6y9G-0001Hw-3P for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Jan 2014 08:59:26 +0100 Original-Received: from localhost ([::1]:50239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6y9F-0002aa-RH for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Jan 2014 02:59:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6y94-0002aK-Kl for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:59:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6y8t-00056J-95 for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:59:14 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6y8t-00056F-5q for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:59:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W6y8s-0007VO-Bm for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:59:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Chow Loong Jin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Jan 2014 07:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16545 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139063669928778 (code B ref -1); Sat, 25 Jan 2014 07:59:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Jan 2014 07:58:19 +0000 Original-Received: from localhost ([127.0.0.1]:35042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6y8A-0007U5-82 for submit@debbugs.gnu.org; Sat, 25 Jan 2014 02:58:18 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55891) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6y85-0007Tu-9R for submit@debbugs.gnu.org; Sat, 25 Jan 2014 02:58:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6y7w-00050D-II for submit@debbugs.gnu.org; Sat, 25 Jan 2014 02:58:12 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:42014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6y7w-000509-Ep for submit@debbugs.gnu.org; Sat, 25 Jan 2014 02:58:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6y7n-0002Sr-VD for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:58:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6y7f-0004yO-Hn for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:57:55 -0500 Original-Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:47231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6y7f-0004yE-6s for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 02:57:47 -0500 Original-Received: by mail-pa0-f46.google.com with SMTP id rd3so4103935pab.19 for ; Fri, 24 Jan 2014 23:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=sP5KVcYmRUh7FuZ9gKar19xW3AIFb2Ctg5+GEnxkI7c=; b=ZT2C0DLwn8lZsgRAvJRsxfgEnuqpYU/kcn+Ds8bkaP3XbYl6y+u+14krxWMz6YZDE2 sLcawgw2UzO72HemU3ajS085mZFmFNVIXo8FsqzcRTAZR3XiCTpFzB57pZHtpj7Yv7qG q4vOVNUcPsbY3Y2joqhZI+34GTg+BJMDiCV2HCuM8fQiOVRxVBo0EHJ5Ttuef8ODJ5Bq FUEQ6WjMIiXgQNrXEgvYMh58yO7Kwn/gdHLzW20WzrnHgBZ8FmYIRWo5+iJMJjIcm9ap bWQn7lSYYkgfdC5JJFbgJpQBKJjJPvv+t8uRClWWISAxtyBnhU12Bl7xwg7uH1dgaLHk p+nQ== X-Received: by 10.69.20.11 with SMTP id gy11mr18855758pbd.64.1390636665108; Fri, 24 Jan 2014 23:57:45 -0800 (PST) Original-Received: from thinkpwn ([175.156.234.201]) by mx.google.com with ESMTPSA id jn12sm10273719pbd.37.2014.01.24.23.57.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 24 Jan 2014 23:57:43 -0800 (PST) Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:83969 Archived-At: --eJnRUKwClWJh1Khz Content-Type: multipart/mixed; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --opJtzjQTFsWo+cga Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-customization-option-to-delay-linum-updates.patch" Content-Transfer-Encoding: quoted-printable =46rom 13a9fde7a9b0a4f7a40e6d5e9ce3447bbfed777b Mon Sep 17 00:00:00 2001 =46rom: Chow Loong Jin 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 --- 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") =20 (mapc #'make-variable-buffer-local '(linum-overlays linum-available)) =20 @@ -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) =20 ;;;###autoload (define-minor-mode linum-mode @@ -195,7 +200,12 @@ Linum mode is a buffer-local minor mode." =20 (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))) =20 ;; (defun linum-after-config () ;; (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visi= ble)) --=20 1.8.3.2 --opJtzjQTFsWo+cga-- --eJnRUKwClWJh1Khz Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAEBAgAGBQJS425xAAoJEPvVIltYh1KhNOgP/3ws1NC8hjrZ+CphD8aQ+gOM sCwvmAWLH0o4YBC7QqQUfBgbNo3HKlf5z2UeCJdI0ffog0J4XzlcWsJNGKthWgDF BAHmNnryiULES+XcaQa7zKCag3xAP5TVoCY3iVUUUahx1ivgQTC5y1QaxsjAN6o3 c+mOUHdGVnki6IYG0YUbyl3U0B/0T7Bc5r0Jqtv8Tcsd+YemvuPA1D8b6gtVvYwR QuseDpH7PHoH/Aa1jVfbAYllMGkzf8lDEmbz8hAMdrbWLErS/NMXbBu5aNzRa9pw ugddVBvxJ03Cc+bTrkUoKDxmgApfoFnEJuipdzk9lHaPzTsBTYyuRbClQHtmLAHr toDHuCZvWgWVOM1x+Ga1fwJ+8YVLsXjLG25xwHX2A/7k0yl5aSUxVxiVXj5m/wkY vo9u6PC0ob0DRTwaGwMopQxNr6FOMMk5kdFQNOvsHKKgpjERu/t5pODd03CgFYHp 5PfXf8LmZDq/TotMaNqTIRXnUq1hU8EOMKUvsGD9ij3lBRctpTI2QepJ/2m1Bg5f QGNH4vmykqJ4L6XYGBg1vmQ5BHOgR+ha1aEsL0dhx5qy2Ah/e91FCEg8+zT2KBiW 3lj5xIQ6zbsyw1IgUs86ZO5MpG8HjEweqko99P/SHVujU+Mr+cvU/7AOFNWqaNsq 7WwKgBk9MYMrkiK+T8Nr =wCWE -----END PGP SIGNATURE----- --eJnRUKwClWJh1Khz--