From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#70789: treesit navigate for outlines at bobp Date: Sun, 05 May 2024 19:52:43 +0300 Organization: LINKOV.NET Message-ID: <86seywi4kk.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32132"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Yuan Fu To: 70789@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 05 18:57:14 2024 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 1s3fAo-0008Ek-2w for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 May 2024 18:57:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3fAI-0004yO-25; Sun, 05 May 2024 12:56:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3fAF-0004xg-26 for bug-gnu-emacs@gnu.org; Sun, 05 May 2024 12:56:39 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3fAE-0005LG-84 for bug-gnu-emacs@gnu.org; Sun, 05 May 2024 12:56:38 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s3fAb-0001ix-S0; Sun, 05 May 2024 12:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: casouri@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 May 2024 16:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70789 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Yuan Fu Original-Received: via spool by submit@debbugs.gnu.org id=B.17149281716581 (code B ref -1); Sun, 05 May 2024 16:57:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 May 2024 16:56:11 +0000 Original-Received: from localhost ([127.0.0.1]:60681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3f9m-0001i5-Uu for submit@debbugs.gnu.org; Sun, 05 May 2024 12:56:11 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:53256) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3f9j-0001hX-VC for submit@debbugs.gnu.org; Sun, 05 May 2024 12:56:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3f98-0004VA-6n for bug-gnu-emacs@gnu.org; Sun, 05 May 2024 12:55:30 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3f95-0003WA-6T for bug-gnu-emacs@gnu.org; Sun, 05 May 2024 12:55:29 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 1BC741C0004 for ; Sun, 5 May 2024 16:55:23 +0000 (UTC) X-GND-Sasl: juri@linkov.net Received-SPF: pass client-ip=217.70.183.197; envelope-from=juri@linkov.net; helo=relay5-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284520 Archived-At: --=-=-= Content-Type: text/plain 'treesit-outline-search' didn't match outlines at the beginning of the buffer because unlike 're-search-forward' (used by outline-mode) that matches the text that immediately follows point, 'treesit-navigate-thing' misses text at point and stars the search after point. So there is a need to handle this difference specially. Therefore this patch adds such special-handling of bobp to 'treesit-outline-search': --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=treesit-outline-search-bobp.patch diff --git a/lisp/treesit.el b/lisp/treesit.el index e55e04e53b3..86ed1bbae33 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2884,15 +2884,21 @@ treesit-outline-search (start (treesit-node-start node))) (eq (pos-bol) (save-excursion (goto-char start) (pos-bol)))) - (let* ((pos + (let* ((bob-pos + ;; `treesit-navigate-thing' can't find a thing at bobp, + ;; so use `looking-at' to match at bobp. + (and (bobp) (treesit-outline-search bound move backward t) (point))) + (pos ;; When function wants to find the current outline, point ;; is at the beginning of the current line. When it wants ;; to find the next outline, point is at the second column. - (if (eq (point) (pos-bol)) - (if (bobp) (point) (1- (point))) - (pos-eol))) - (found (treesit-navigate-thing pos (if backward -1 1) 'beg - treesit-outline-predicate))) + (unless bob-pos + (if (eq (point) (pos-bol)) + (if (bobp) (point) (1- (point))) + (pos-eol)))) + (found (or bob-pos + (treesit-navigate-thing pos (if backward -1 1) 'beg + treesit-outline-predicate)))) (if found (if (or (not bound) (if backward (>= found bound) (<= found bound))) (progn --=-=-=--