From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#56682: locked narrowing Date: Wed, 17 Aug 2022 22:19:56 +0300 Message-ID: <83bksid6eb.fsf@gnu.org> References: <5e3c3081-f098-8140-c767-b895c32bf30b@yandex.ru> <835yisffil.fsf@gnu.org> <831qtgff78.fsf@gnu.org> <83zgg4dw4y.fsf@gnu.org> <83r11gdrr4.fsf@gnu.org> <83edxfds7s.fsf@gnu.org> <83r11fc80o.fsf@gnu.org> <83o7wjc6o2.fsf@gnu.org> <83lernc5gu.fsf@gnu.org> <83k076dd7d.fsf@gnu.org> <83edxed8qe.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40088"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org, gregory@heytings.org, dgutov@yandex.ru To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 17 21:21:27 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOObV-000AC0-A4 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 21:21:25 +0200 Original-Received: from localhost ([::1]:35230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOObT-0004qZ-Vg for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 17 Aug 2022 15:21:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOOb8-0004qP-M1 for bug-gnu-emacs@gnu.org; Wed, 17 Aug 2022 15:21:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOOb8-0002w7-Db for bug-gnu-emacs@gnu.org; Wed, 17 Aug 2022 15:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oOOb8-0002zl-9G for bug-gnu-emacs@gnu.org; Wed, 17 Aug 2022 15:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 Aug 2022 19:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56682 X-GNU-PR-Package: emacs Original-Received: via spool by 56682-submit@debbugs.gnu.org id=B56682.166076403011453 (code B ref 56682); Wed, 17 Aug 2022 19:21:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 17 Aug 2022 19:20:30 +0000 Original-Received: from localhost ([127.0.0.1]:53088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oOOac-0002yf-Ag for submit@debbugs.gnu.org; Wed, 17 Aug 2022 15:20:30 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36150) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oOOaZ-0002yM-42 for 56682@debbugs.gnu.org; Wed, 17 Aug 2022 15:20:28 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOOaS-0002tJ-Sj; Wed, 17 Aug 2022 15:20:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=wJzbGMuq3W0jkLhNPDYeDdbuY2K3ljLbvfZ1aP/d6Ho=; b=d7Zugjg8CTGd G6N+3fW3vlaeWyUJymjdazeBROKL5Bl/NHEEZkmK95tYVZCJZSg2dBbB1ZXpuZ5uWpo10KD5Q+geU yu4cJWdVKcoatRLwcm0cCLP+Jd+dORZFQOBCKojd1fKtxJijzysUPXVsdPtO7+7O0WBzvt8Wk2ZXT 840nMjh6YQc4gfOqeQOJwfyWUCzS7PkALCUW36A/mXUeb8P3a+kliZCeJCOt9/E70k00rnKoOKcBT 2H4S5UbfA9Vet/4SsmP93EyXDjYElvDtTYpn3grFpryhzpxI92iz7zZqZbkpmyZDkmbJK2J7MnWVp sM6pIrXpwu/VoA9TCpbH5g==; Original-Received: from [87.69.77.57] (port=4755 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOOaE-0002By-Cu; Wed, 17 Aug 2022 15:20:20 -0400 In-Reply-To: (message from Stefan Monnier on Wed, 17 Aug 2022 15:09:22 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:240107 Archived-At: > From: Stefan Monnier > Cc: dgutov@yandex.ru, 56682@debbugs.gnu.org, gregory@heytings.org > Date: Wed, 17 Aug 2022 15:09:22 -0400 > > >> Because I can't find that code. > > What do you mean? it's in maybe_produce_line_number, obviously... > > My intuition tells me it should be there, but I can't find it. Really? I meant this: if (!last_line) { /* If possible, reuse data cached by line-number-mode. */ if (it->w->base_line_number > 0 && it->w->base_line_pos > 0 && it->w->base_line_pos <= IT_CHARPOS (*it) /* line-number-mode always displays narrowed line numbers, so we cannot use its data if the user wants line numbers that disregard narrowing, or if the buffer's narrowing has just changed. */ && !(line_numbers_wide && (BEG_BYTE != BEGV_BYTE || Z_BYTE != ZV_BYTE)) && !current_buffer->clip_changed) { start_from = CHAR_TO_BYTE (it->w->base_line_pos); last_line = it->w->base_line_number - 1; } else start_from = beg_byte; if (!it->lnum_bytepos) first_time = true; } else start_from = it->lnum_bytepos; /* Paranoia: what if someone changes the narrowing since the last time display_line was called? Shouldn't really happen, but who knows what some crazy Lisp invoked by :eval could do? */ if (!(beg_byte <= start_from && start_from <= z_byte)) { last_line = 0; start_from = beg_byte; } this_line = last_line + display_count_lines_logically (start_from, IT_BYTEPOS (*it), IT_CHARPOS (*it), &bytepos); > >> Apparently `maybe_produce_line_number` > >> just uses `w->base_line_number` whenever it's not 0, so apparently it's > >> set to 0 elsewhere. > > It's set to zero in several places in xdisp.c. > > I can't seem to find even one of them related to the fact that the > buffer was modified. This: if (!just_this_one_p || current_buffer->clip_changed || BEG_UNCHANGED < CHARPOS (startp)) /* Forget any recorded base line for line number display. */ w->base_line_number = 0; And this: /* Forget any previously recorded base line for line number display. */ if (!buffer_unchanged_p) w->base_line_number = 0; > When I test the code, I can see that it works correctly, but I can't see > in the code how the cache gets flushed/ignored/refreshed when the > buffer's contents is modified (e.g. by inserting a newline at BOB). Of course, this works: it's about the oldest code in the display engine. > > But again, if you don't want to trust the cached values, just use > > display_count_lines starting from BOB. > > That's already what nlinum does (via `line-number-at-pos`). Then maybe all this discussion is just a waste of breath.