From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tak Kunihiro Newsgroups: gmane.emacs.bugs Subject: bug#29737: 27.0.50; pixel-scroll-mode is laggy Date: Mon, 01 Jan 2018 09:58:38 +0900 (JST) Message-ID: <20180101.095838.502407685578664475.tkk@misasa.okayama-u.ac.jp> References: <20171224.112823.71840469338618559.tkk@misasa.okayama-u.ac.jp> <20171225.124845.1313473587937932282.tkk@misasa.okayama-u.ac.jp> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Jan__1_09_58_38_2018_938)--" Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1514768298 21868 195.159.176.226 (1 Jan 2018 00:58:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 Jan 2018 00:58:18 +0000 (UTC) Cc: tkk@misasa.okayama-u.ac.jp, 29737@debbugs.gnu.org To: valentjedi@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 01 01:58:14 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eVoQc-0005DQ-6Q for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Jan 2018 01:58:10 +0100 Original-Received: from localhost ([::1]:58668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVoSb-0006NN-9l for geb-bug-gnu-emacs@m.gmane.org; Sun, 31 Dec 2017 20:00:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVoSU-0006LB-HA for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2017 20:00:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eVoSQ-00025R-Hn for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2017 20:00:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eVoSQ-000259-An for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2017 20:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eVoSP-0001Y9-Vw for bug-gnu-emacs@gnu.org; Sun, 31 Dec 2017 20:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jan 2018 01:00:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29737 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29737-submit@debbugs.gnu.org id=B29737.15147683705891 (code B ref 29737); Mon, 01 Jan 2018 01:00:01 +0000 Original-Received: (at 29737) by debbugs.gnu.org; 1 Jan 2018 00:59:30 +0000 Original-Received: from localhost ([127.0.0.1]:59121 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eVoRu-0001Wx-8x for submit@debbugs.gnu.org; Sun, 31 Dec 2017 19:59:30 -0500 Original-Received: from [208.81.69.64] (port=29747 helo=s18p02o141.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eVoRs-0001VT-Su for 29737@debbugs.gnu.org; Sun, 31 Dec 2017 19:59:29 -0500 Original-Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o141.mxlogic.net(mxl_mta-8.5.0-1933) over TLS secured channel with ESMTP id 4c7894a5.0.222724.00-391.422955.s18p02o141.mxlogic.net (envelope-from ); Sun, 31 Dec 2017 17:58:51 -0700 (MST) X-MXL-Hash: 5a4987cb0b24a60e-5c71eae53a15ab5c84b2ca3038d1869fa54a95a7 Original-Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 706d_0421_f1a46a9c_a05f_402d_b899_d2529f541d09; Mon, 01 Jan 2018 09:58:37 +0900 Original-Received: from localhost (p221050-ipngn200207tottori.tottori.ocn.ne.jp [153.182.220.50]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id CB0A14C0B3E; Mon, 1 Jan 2018 09:58:37 +0900 (JST) In-Reply-To: <20171225.124845.1313473587937932282.tkk@misasa.okayama-u.ac.jp> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: ********** X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 10.1 X-NAI-Spam-Rules: 6 Rules triggered TS_MSG_REP_80_512=10, RCVD_BAD_SIP=0.1, EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_FAIL=0, RV6190=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6190> : inlines <6292> : streams <1774745> : uri <2560861> X-AnalysisOut: [v=2.2 cv=P+BKvmIu c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=ocR9PWop10UA:10 a=ZW2] X-AnalysisOut: [jQSb4f7COxXVFQvcA:9 a=CjuIK1q_8ugA:10 a=KyQIGehDox9TusDjnD] X-AnalysisOut: [YA:9] X-Spam: [F=0.5100000000; CM=0.500; MH=0.510(2017123109); S=0.204(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:141666 Archived-At: ----Next_Part(Mon_Jan__1_09_58_38_2018_938)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit I think that on scrolling of 1000 lines, smooth scroll is not necessary. User wants smooth scrolling only for the first spin of mouse wheel. This patch introduces a new variable `pixel-dead-time' and `pixel-last-scroll-time'. When another scroll request was delivered within `pixel-dead-time', very likely user does not want smooth scrolling. On such situation, `scroll-down' is called instead of `pixel-scroll-pixel-down'. On theory there should not be lag because of smoothing. I tested the revised pixel-scroll-mode for a week and confirmed that works good. When `pixel-dead-time' is zero, its behavior is the same as before. I think `pixel-dead-time' 0.1 works better. I'm sending ChangeLog and a patch relative to the current master. * ChangeLog Add a new algorithm to avoid lag when scrolling is in rush * lisp/pixel-scroll.el (pixel-scroll-up): Invoke 'scroll-up' when called within 'pixel-dead-time'. (pixel-scroll-down): Invoke 'scroll-down' when called within 'pixel-dead-time'. (pixel-dead-time): Interval that requires for the next smooth scrolling. (pixel-last-scroll-time): Time when the last scrolling was made. (Bug#29737) ----Next_Part(Mon_Jan__1_09_58_38_2018_938)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pixel-scroll.el.diff" diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 70244873b4..07297d61b5 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -82,6 +82,15 @@ pixel-resolution-fine-flag pixel scroll, typing \\[next-line] or \\[previous-line] scrolls the window to make it fully visible, and undoes the effect of the pixel-level scroll.") +(defvar pixel-dead-time 0.1 + "Interval that requires for the next smooth scrolling in second. +On another scrolling request within this period, the scrolling +will be carried out without pixel resolution. If zero, scrolling +is with pixel resolution always.") + +(defvar pixel-last-scroll-time 0 + "Time when the last scrolling was made in second since the epoch.") + ;;;###autoload (define-minor-mode pixel-scroll-mode "A minor mode to scroll text pixel-by-pixel. @@ -104,35 +113,51 @@ pixel-scroll-up This is an alternative of `scroll-up'. Scope moves downward." (interactive) (or arg (setq arg 1)) - (dotimes (ii arg) ; move scope downward - (let ((amt (if pixel-resolution-fine-flag - (if (integerp pixel-resolution-fine-flag) - pixel-resolution-fine-flag - (frame-char-height)) - (pixel-line-height)))) - (if (pixel-eob-at-top-p) ; when end-of-the-buffer is close - (scroll-up 1) ; relay on robust method - (while (pixel-point-at-top-p amt) ; prevent too late (multi tries) - (vertical-motion 1)) ; move point downward - (pixel-scroll-pixel-up amt))))) ; move scope downward + (if (pixel-scroll-in-rush-p) + (scroll-up arg) + (dotimes (ii arg) ; move scope downward + (let ((amt (if pixel-resolution-fine-flag + (if (integerp pixel-resolution-fine-flag) + pixel-resolution-fine-flag + (frame-char-height)) + (pixel-line-height)))) + (if (pixel-eob-at-top-p) ; when end-of-the-buffer is close + (scroll-up 1) ; relay on robust method + (while (pixel-point-at-top-p amt) ; prevent too late (multi tries) + (vertical-motion 1)) ; move point downward + (pixel-scroll-pixel-up amt)))))) ; move scope downward (defun pixel-scroll-down (&optional arg) "Scroll text of selected window down ARG lines. This is and alternative of `scroll-down'. Scope moves upward." (interactive) (or arg (setq arg 1)) - (dotimes (ii arg) - (let ((amt (if pixel-resolution-fine-flag - (if (integerp pixel-resolution-fine-flag) - pixel-resolution-fine-flag - (frame-char-height)) - (pixel-line-height -1)))) - (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries) - (vertical-motion -1)) ; move point upward - (if (or (pixel-bob-at-top-p amt) ; when beginning-of-the-buffer is seen - (pixel-eob-at-top-p)) ; for file with a long line - (scroll-down 1) ; relay on robust method - (pixel-scroll-pixel-down amt))))) + (if (pixel-scroll-in-rush-p) + (scroll-down arg) + (dotimes (ii arg) + (let ((amt (if pixel-resolution-fine-flag + (if (integerp pixel-resolution-fine-flag) + pixel-resolution-fine-flag + (frame-char-height)) + (pixel-line-height -1)))) + (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries) + (vertical-motion -1)) ; move point upward + (if (or (pixel-bob-at-top-p amt) ; when beginning-of-the-buffer is seen + (pixel-eob-at-top-p)) ; for file with a long line + (scroll-down 1) ; relay on robust method + (pixel-scroll-pixel-down amt)))))) + +(defun pixel-scroll-in-rush-p () + "Return non-nil if scroll is in rush. +When scrolling request is delivered soon after the previous one, +user is in hurry. When the interval is larger than +`pixel-dead-time', it is ready for another smooth scroll and this +returns nil." + (let* ((current-time (float-time)) + (scroll-in-rush-p (< (- current-time pixel-last-scroll-time) + pixel-dead-time))) + (setq pixel-last-scroll-time current-time) + scroll-in-rush-p)) (defun pixel-bob-at-top-p (amt) "Return non-nil if window-start is at beginning of the current buffer. ----Next_Part(Mon_Jan__1_09_58_38_2018_938)----