From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Date: Sun, 07 Feb 2021 22:36:12 +0100 Message-ID: <87zh0fwofn.fsf@gnus.org> References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <87r1lry5hl.fsf@gnus.org> <83v9b3li0a.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19072"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 07 22:37:11 2021 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 1l8rjy-0004qQ-Lp for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Feb 2021 22:37:10 +0100 Original-Received: from localhost ([::1]:47950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8rjx-0006Qp-Nw for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Feb 2021 16:37:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8rjq-0006Qe-6O for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 16:37:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8rjp-0007Aq-SL for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 16:37:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l8rjp-0000Bo-Pj for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 16:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 21:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.1612733793689 (code B ref 22763); Sun, 07 Feb 2021 21:37:01 +0000 Original-Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 21:36:33 +0000 Original-Received: from localhost ([127.0.0.1]:49089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8rjN-0000B3-0Q for submit@debbugs.gnu.org; Sun, 07 Feb 2021 16:36:33 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:40122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8rjJ-0000An-4i for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 16:36:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EZlzo4Wu4AaYJYL7ItUQsafod8QUXhesalB0qkb1juc=; b=QSchBbgmMsn8+9LAJtPaN+h3pl nCJmSpzLfxQcli3JOXX7mohDfQnAH/TY/mNakuSZm2C8y3136OdqdesdLt92WMrQf/8kNvNnTuwvP nVxQp/TCr/V9ds2srksVhAbgjQ/36gcFdXAEiCbeMcZyYlXCv14Mqrl9aNxPtWEHMyRQ=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8rj3-0005Ar-Ub; Sun, 07 Feb 2021 22:36:21 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEVRam0xOFHNxq2k iFldZmCXGgu3ZB3///+tWyq4AAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UCBxUeJnHrkPEAAAGtSURB VDjLpdRPd6IwEADw/KF7JgU9u4HeNajnSEbv+xZ6r0i+/0fozAS7uNq+7tu5BObHZCDJQwgOKZT2 gLGFKTithKyUcqKFumqJQsMgnRBOaWUKqFqwBsF6rsiKlVKqMQbqUBlTAkxgTK6d3ryOmArLX1hS McjlmFMdAyzeymtvhJIgjpjxp9jRwLLoOxpOl4zBg08VAq95oAo4jv5aIJ4i9dAx4jeE3dh9gDzh hbIYVbDW2XpqrjdK194R2JbAJsiqjSisj4Nr9rGn+J3mkuuf5rkpIwdD3yUw0uTG3INJ8b8A34bx EQz/DOfPejyGxZnW8AEs70FSvpzgdQY/DlRwYbikknRMMgZgGE8zSE1q3sHL0zRTOrsEK2cra7fH Gegr1Awdz/QlKGkEw9pNUH5UfAH5Wl3heDNVvlLWt7bezcEYfGMEPKUJuhtwNmLFcQ4yR9jFfojD dg46wTDszvt9fwcvDR+SsYe/YGVt6Afs8QfwXVPzzNsbkAS5V7XIHAEkwPVrDiJrDoH+IVv6ywRI kG8QAzS4kUUT8CbQloqDARpx3WjxgZIFPfkOxPLTQ0eiKuIAAAAldEVYdGRhdGU6Y3JlYXRlADIw MjEtMDItMDdUMjE6MzA6MzgrMDA6MDCKg84bAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA3 VDIxOjMwOjM4KzAwOjAw+952pwAAAABJRU5ErkJggg== X-Now-Playing: =?UTF-8?Q?Gar=C3=A7ons's?= _Divorce_: "French Boy" In-Reply-To: <83v9b3li0a.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 Feb 2021 22:50:29 +0200") 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:199572 Archived-At: Eli Zaretskii writes: >> From: Lars Ingebrigtsen >> Cc: Eli Zaretskii , 22763@debbugs.gnu.org, esq@lawlist.com >> Date: Sun, 07 Feb 2021 21:42:30 +0100 >> >> Why does display_count_lines (with no cache) exist, then? > > It exists to support the line-number display on the mode line. That > display has its own cache, as part of the window object, so > display_count_lines very rarely needs to count from the beginning of > the buffer, it usually counts from the last place it stopped the > previous time for the same window. This is why it has the signature > that it has. But these are the signatures: ptrdiff_t find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted, ptrdiff_t *bytepos, bool allow_quit) static ptrdiff_t display_count_lines (ptrdiff_t start_byte, ptrdiff_t limit_byte, ptrdiff_t count, ptrdiff_t *byte_pos_ptr) So they seem very similar... Anyway, here's something that just occurred to me: It's still the plan to have so-long-mode on by default, right? Which means that 'buffer-line-statistics' will be called when opening a file, which means that we know whether there are any long lines in the buffer. Could we use this info to switch between cached and non-cached action for find_newline? (I.e., just set 'cache-long-scans'.) Conversely, could we use find_newline to trigger so-long-mode? Today, so-long-mode isn't able to step into the fray when something plops a long line into the buffer (in shell-mode, for instance). If find_newline finds a long line, it could switch 'cache-long-scans' on, and also (on perhaps a different threshold) notify so-long-mode? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no