From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: [az@ftc.ru: hl-line-mode conflicts with scroll-margin] Date: 15 Jun 2004 00:40:03 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <87fz8yt4tb.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1087252828 31709 80.91.224.253 (14 Jun 2004 22:40:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 14 Jun 2004 22:40:28 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Jun 15 00:40:19 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ba07m-0001Ja-00 for ; Tue, 15 Jun 2004 00:40:18 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ba07m-0004qE-00 for ; Tue, 15 Jun 2004 00:40:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Ba08g-0001Cp-L7 for emacs-devel@quimby.gnus.org; Mon, 14 Jun 2004 18:41:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Ba08d-0001Ce-Uj for emacs-devel@gnu.org; Mon, 14 Jun 2004 18:41:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Ba08a-0001CE-DV for emacs-devel@gnu.org; Mon, 14 Jun 2004 18:41:11 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Ba08a-0001CB-9O for emacs-devel@gnu.org; Mon, 14 Jun 2004 18:41:08 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ba07G-0006uc-Cv for emacs-devel@gnu.org; Mon, 14 Jun 2004 18:39:46 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id 50D1526284B; Tue, 15 Jun 2004 00:39:45 +0200 (CEST) Original-To: Juri Linkov In-Reply-To: <87fz8yt4tb.fsf@mail.jurta.org> Original-Lines: 82 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24972 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24972 Juri Linkov writes: > storm@cua.dk (Kim F. Storm) writes: > > The following patch solves the problem. > > Here is another related bug report for you :-) > > If scroll-margin is not 0 and font-lock-mode is turned on, i.e. > > (progn > (setq scroll-margin 5) > (global-font-lock-mode)) > > then after moving the cursor down until it reaches the fifth line from > the bottom of the window the cursor is placed in the center of the window > where it starts jumping forth and back: after 1 second it moves to the > end of the line, and after another 1 second moves to the beginning > of the following line. > > This bug can be reproduced on GNU/Linux in Emacs versions starting > at least from 21.3. Ok, try this patch: *** xdisp.c 30 May 2004 23:13:12 +0200 1.892 --- xdisp.c 15 Jun 2004 00:31:01 +0200 *************** *** 12542,12550 **** position. */ if (pt_row) { ! w->cursor.vpos -= MATRIX_ROW_VPOS (first_reusable_row, ! w->current_matrix); ! w->cursor.y -= first_reusable_row->y; } /* Scroll the display. */ --- 12542,12549 ---- position. */ if (pt_row) { ! w->cursor.vpos -= nrows_scrolled; ! w->cursor.y -= first_reusable_row->y - start_row->y; } /* Scroll the display. */ *************** *** 12589,12594 **** --- 12588,12616 ---- for (row -= nrows_scrolled; row < bottom_row; ++row) row->enabled_p = 0; + /* Point may have moved to a different line, so we cannot assume that + the previous cursor position is valid; locate the correct row. */ + if (pt_row) + { + for (row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); + row < bottom_row && PT >= MATRIX_ROW_END_CHARPOS (row); + row++) + { + w->cursor.vpos++; + w->cursor.y = row->y; + } + if (row < bottom_row) + { + struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos; + while (glyph->charpos < PT) + { + w->cursor.hpos++; + w->cursor.x += glyph->pixel_width; + glyph++; + } + } + } + /* Adjust window end. A null value of last_text_row means that the window end is in reused rows which in turn means that only its vpos can have changed. */ -- Kim F. Storm http://www.cua.dk