From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18923: Alternative scrolling model Date: Sun, 02 Nov 2014 17:14:26 +0200 Message-ID: <83a949y6r1.fsf@gnu.org> References: <87wq7e9zcn.fsf@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1414941330 28413 80.91.229.3 (2 Nov 2014 15:15:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Nov 2014 15:15:30 +0000 (UTC) Cc: 18923@debbugs.gnu.org To: E Sabof Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 02 16:15:23 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 1XkwsE-0007Fm-Hs for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Nov 2014 16:15:22 +0100 Original-Received: from localhost ([::1]:57555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkwsE-00081n-0O for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Nov 2014 10:15:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xkws2-0007sV-Uu for bug-gnu-emacs@gnu.org; Sun, 02 Nov 2014 10:15:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xkwrv-0005GB-CF for bug-gnu-emacs@gnu.org; Sun, 02 Nov 2014 10:15:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xkwrv-0005Fx-8k for bug-gnu-emacs@gnu.org; Sun, 02 Nov 2014 10:15:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xkwru-00063Z-RE for bug-gnu-emacs@gnu.org; Sun, 02 Nov 2014 10:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Nov 2014 15:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18923 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18923-submit@debbugs.gnu.org id=B18923.141494128823245 (code B ref 18923); Sun, 02 Nov 2014 15:15:02 +0000 Original-Received: (at 18923) by debbugs.gnu.org; 2 Nov 2014 15:14:48 +0000 Original-Received: from localhost ([127.0.0.1]:46244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xkwrg-00062q-7l for submit@debbugs.gnu.org; Sun, 02 Nov 2014 10:14:48 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:40682) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xkwrd-00062Z-5X for 18923@debbugs.gnu.org; Sun, 02 Nov 2014 10:14:45 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0NEF00C003IH2700@a-mtaout23.012.net.il> for 18923@debbugs.gnu.org; Sun, 02 Nov 2014 17:14:39 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NEF00BY83OEYX50@a-mtaout23.012.net.il>; Sun, 02 Nov 2014 17:14:39 +0200 (IST) In-reply-to: <87wq7e9zcn.fsf@gmail.com> X-012-Sender: halo1@inter.net.il 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:95378 > From: E Sabof > Date: Sun, 02 Nov 2014 01:15:52 +0000 > > I've made a prototype for an alternative way to scroll. Essentially scrolling > is done pixelwise irrespective of content. Whole lines are scrolled "normally", > and the remainder is vscrolled. If the end result is close to a line boundary > it gets "snapped" to it. > This prevents unpleasant jumping when encountering an image. It doesn't handle > the "image taller than window" case, but it would if `st-height' could measure > more accurately. Thanks. What are the advantages of this alternative way of scrolling, beyond being in Lisp and eliminating the jumps when encountering an image? (Btw, a test case for the latter would be nice, perhaps as a separate bug report.) If the only advantage is better handling of in-line images, then perhaps fixing the existing implementation is a better path forward? Allow me a few comments about the code below. > (defvar st-ov nil) Is this overlay used anywhere? I couldn't find that. > (defun st-height (&optional pos) > "Won't report accurately, if the line is higher than window." > (cl-flet (( posn-y () > (cdr (posn-x-y (or (posn-at-point) > (progn > (vertical-motion 0) > (set-window-start nil (point)) > (posn-at-point))))))) Did you try using pos-visible-in-window-p? I think it's what you want. > (when (cl-plusp ws) Why not use '(> ws 0)' instead? It's marginally faster, I think. > (cl-incf ammount vscroll) Why not use '(setq amount (+ amount vscroll))' instead? It should be marginally faster. > (when (cl-minusp direction) Same question as for cl-plusp above. > (cl-loop do (push (st-height) rows) > until (or (zerop (vertical-motion direction)) > ;; >= ? > (>= (cl-reduce '+ rows) > (abs ammount)))) I don't understand why you needed this loop. Can't you use window-body-height instead? Also, if you do need the loop, why is it a good idea to use cl-reduce here, rather than keeping track of the running sum -- isn't the latter faster? (And I don't think you need to keep the 'rows' list, see below.) > (cl-defun st-move (lines vscroll) > ;; vscroll changes aren't always displayed. Haven't found a work-around for this. A recipe to reproduce this problem, perhaps as a separate bug report, would be nice. > ( line-info (st-get-lines pixels-to-move)) > ( heights (cadr line-info)) > ( initial-vscroll (car line-info)) > excess > enough-or-too-many-heights > too-few-heights) > (cl-incf pixels-to-move initial-vscroll) > (setq enough-or-too-many-heights (cl-reduce '+ heights) It looks like you never need the info about the height of the individual lines, only their sum. So perhaps st-get-lines shouldn't return the height info as a list, but as just one number? > too-few-heights (cl-reduce '+ (butlast heights) :initial-value 0) OK, 2 numbers. > ;; (global-set-key (kbd "") (lambda () (interactive) (scroll-tick 10))) > ;; (global-set-key (kbd "") (lambda () (interactive) (scroll-tick -10))) This doesn't support the equivalent of a nil argument, which means move by "near full screen".