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#14567: Scrolling of large images Date: Sat, 15 Jun 2013 11:23:49 +0300 Message-ID: <83li6bvl2i.fsf@gnu.org> References: <83ppvzur6i.fsf@gnu.org> <83obbjuov4.fsf@gnu.org> <83vc5osn0r.fsf@gnu.org> <83obbgsg33.fsf@gnu.org> <83k3m4sar0.fsf@gnu.org> <83ehccromw.fsf@gnu.org> <87bo7cpfpk.fsf@engster.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1371284713 2515 80.91.229.3 (15 Jun 2013 08:25:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Jun 2013 08:25:13 +0000 (UTC) Cc: thomas.wiecki@gmail.com, 14567@debbugs.gnu.org To: David Engster Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 15 10:25:13 2013 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 1UnlnK-0004hG-9m for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Jun 2013 10:25:10 +0200 Original-Received: from localhost ([::1]:37373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnlnJ-0006Zz-Tk for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Jun 2013 04:25:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnlnF-0006Wk-82 for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2013 04:25:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnlnD-0003J3-Vk for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2013 04:25:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnlnD-0003Il-Sl for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2013 04:25:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UnlnC-00065C-U9 for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2013 04:25:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Jun 2013 08:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14567 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14567-submit@debbugs.gnu.org id=B14567.137128467023294 (code B ref 14567); Sat, 15 Jun 2013 08:25:02 +0000 Original-Received: (at 14567) by debbugs.gnu.org; 15 Jun 2013 08:24:30 +0000 Original-Received: from localhost ([127.0.0.1]:45569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Unlmf-00063d-Fu for submit@debbugs.gnu.org; Sat, 15 Jun 2013 04:24:30 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:48345) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Unlma-00062y-HP for 14567@debbugs.gnu.org; Sat, 15 Jun 2013 04:24:27 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MOF00L00DT60Q00@a-mtaout20.012.net.il> for 14567@debbugs.gnu.org; Sat, 15 Jun 2013 11:23:35 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MOF00K6MDZBPQ90@a-mtaout20.012.net.il>; Sat, 15 Jun 2013 11:23:35 +0300 (IDT) In-reply-to: <87bo7cpfpk.fsf@engster.org> 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:75140 Archived-At: > From: David Engster > Cc: Thomas Wiecki , 14567@debbugs.gnu.org > Date: Tue, 11 Jun 2013 22:14:47 +0200 > > Eli Zaretskii writes: > >> I can't really reproduce the line-move error either in this mode. It > >> does show up occasionally but I haven't figured out how to > >> explicitly trigger it thus far. > > > > I'll try reproducing it here. > > I also tried the patch on current trunk. I use the following snippet to > generate a buffer containing large and small images as well as text: Thanks. Unfortunately, using Emacs with Imagemagick support is a no-starter for me. However, I tried to cover every possibility of using non-numeric values in numeric context. Please try the patch below (it's relative to the current trunk, not to the previous patch), and see if it gives good results. If you still get errors, please manually load simple.el (not simple.elc) into your Emacs, run your test snippet, and see if the backtrace can pinpoint the place where I missed something. Thanks. === modified file 'lisp/simple.el' --- lisp/simple.el 2013-06-13 22:24:52 +0000 +++ lisp/simple.el 2013-06-15 07:57:08 +0000 @@ -4738,22 +4738,39 @@ lines." (vpos (nth 1 lh)) (ypos (nth 2 lh)) (rbot (nth 3 lh)) + (this-lh (window-line-height)) + (this-height (nth 0 this-lh)) + (this-ypos (nth 2 this-lh)) + (fch (frame-char-height)) py vs) (when (or (null lh) - (>= rbot (frame-char-height)) - (<= ypos (- (frame-char-height)))) + (>= rbot fch) + (<= ypos (- fch)) + (null this-lh) + (<= this-ypos (- fch))) (unless lh (let ((wend (pos-visible-in-window-p t nil t))) (setq rbot (nth 3 wend) vpos (nth 5 wend)))) + (unless this-lh + (let ((wstart (pos-visible-in-window-p nil nil t))) + (setq this-ypos (nth 2 wstart) + this-height (nth 4 wstart)))) (cond - ;; If last line of window is fully visible, move forward. - ((or (null rbot) (= rbot 0)) + ;; If last line of window is fully visible, and vscrolling + ;; more would make this line invisible, move forward. + ((and (or (< (setq vs (window-vscroll nil t)) fch) + (null this-height) + (<= this-height fch)) + (or (null rbot) (= rbot 0))) nil) - ;; If cursor is not in the bottom scroll margin, move forward. - ((and (> vpos 0) + ;; If cursor is not in the bottom scroll margin, and the + ;; current line is is not too tall, move forward. + ((and (or (null this-height) (<= this-height fch)) + vpos + (> vpos 0) (< (setq py - (or (nth 1 (window-line-height)) + (or (nth 1 this-lh) (let ((ppos (posn-at-point))) (cdr (or (posn-actual-col-row ppos) (posn-col-row ppos)))))) @@ -4761,19 +4778,21 @@ lines." nil) ;; When already vscrolled, we vscroll some more if we can, ;; or clear vscroll and move forward at end of tall image. - ((> (setq vs (window-vscroll nil t)) 0) - (when (> rbot 0) - (set-window-vscroll nil (+ vs (min rbot (frame-char-height))) t))) + ((> vs 0) + (when (or (and rbot (> rbot 0)) + (and this-height (> this-height fch))) + (set-window-vscroll nil (+ vs fch) t))) ;; If cursor just entered the bottom scroll margin, move forward, ;; but also vscroll one line so redisplay won't recenter. - ((and (> vpos 0) + ((and vpos + (> vpos 0) (= py (min (- (window-text-height) scroll-margin 1) (1- vpos)))) (set-window-vscroll nil (frame-char-height) t) (line-move-1 arg noerror to-end) t) ;; If there are lines above the last line, scroll-up one line. - ((> vpos 0) + ((and vpos (> vpos 0)) (scroll-up 1) t) ;; Finally, start vscroll. @@ -4808,7 +4827,14 @@ lines." ;; display-based motion doesn't make sense (because each ;; logical line occupies exactly one screen line). (not (> (window-hscroll) 0))) - (line-move-visual arg noerror) + (prog1 (line-move-visual arg noerror) + ;; If we moved into a tall line, set vscroll to make + ;; scrolling through tall images more smooth. + (let ((lh (line-pixel-height))) + (if (and (< arg 0) + (< (point) (window-start)) + (> lh (frame-char-height))) + (set-window-vscroll nil (- lh (frame-char-height)) t)))) (line-move-1 arg noerror to-end))))) ;; Display-based alternative to line-move-1. === modified file 'src/xdisp.c' --- src/xdisp.c 2013-06-10 04:36:06 +0000 +++ src/xdisp.c 2013-06-15 07:24:37 +0000 @@ -1217,6 +1217,24 @@ line_bottom_y (struct it *it) return line_top_y + line_height; } +DEFUN ("line-pixel-height", Fline_pixel_height, + Sline_pixel_height, 0, 0, 0, + doc: /* Return height in pixels of text line in the selected window. + +Value is the height in pixels of the line at point. */) + (void) +{ + struct it it; + struct text_pos pt; + struct window *w = XWINDOW (selected_window); + + SET_TEXT_POS (pt, PT, PT_BYTE); + start_display (&it, w, pt); + it.vpos = it.current_y = 0; + last_height = 0; + return make_number (line_bottom_y (&it)); +} + /* Subroutine of pos_visible_p below. Extracts a display string, if any, from the display spec given as its argument. */ static Lisp_Object @@ -28691,6 +28709,7 @@ syms_of_xdisp (void) defsubr (&Stool_bar_lines_needed); defsubr (&Slookup_image_map); #endif + defsubr (&Sline_pixel_height); defsubr (&Sformat_mode_line); defsubr (&Sinvisible_p); defsubr (&Scurrent_bidi_paragraph_direction);