From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#70789: treesit navigate for outlines at bobp Date: Wed, 8 May 2024 17:16:22 -0700 Message-ID: <61713C0C-62CA-4FA1-87CA-2E5A4D38AFA1@gmail.com> References: <86seywi4kk.fsf@mail.linkov.net> <37B3FE57-8ABA-4C10-8F75-EC7FF1A64B74@gmail.com> <86jzk7a1pp.fsf@mail.linkov.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34614"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70789@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 09 02:17:51 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 1s4rTq-0008xG-OP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 May 2024 02:17:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4rTh-0007Cn-EC; Wed, 08 May 2024 20:17:41 -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 1s4rTd-000776-Fv for bug-gnu-emacs@gnu.org; Wed, 08 May 2024 20:17:38 -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 1s4rTd-0001JM-4V for bug-gnu-emacs@gnu.org; Wed, 08 May 2024 20:17:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s4rU2-0005Jn-G3 for bug-gnu-emacs@gnu.org; Wed, 08 May 2024 20:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 May 2024 00:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70789 X-GNU-PR-Package: emacs Original-Received: via spool by 70789-submit@debbugs.gnu.org id=B70789.171521382720432 (code B ref 70789); Thu, 09 May 2024 00:18:02 +0000 Original-Received: (at 70789) by debbugs.gnu.org; 9 May 2024 00:17:07 +0000 Original-Received: from localhost ([127.0.0.1]:51709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4rT9-0005JU-3l for submit@debbugs.gnu.org; Wed, 08 May 2024 20:17:07 -0400 Original-Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:54502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4rT6-0005J4-T9 for 70789@debbugs.gnu.org; Wed, 08 May 2024 20:17:05 -0400 Original-Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1ec4dc64c6cso1836625ad.0 for <70789@debbugs.gnu.org>; Wed, 08 May 2024 17:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715213793; x=1715818593; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=I18hWEBZjVSV+jGP4cfZ/tDEPN8kdHuFtgm/nhKoMMM=; b=Hk9ZAuv0K2l2Y47puUkjgK8Vngal6crhi4YfR2TUzcPxeCP7mMKn1oe+Xv5bQms6zz ytaURdvgJVIiXn+XyoQUDd85KXJAYXaQGfuJ80LQgbreJYRcZ5ULJ7om41defQxVApNb 7bmOZwtdR78p8rlxdTlPbD1EAE5DaErQCFH7bdeX/R/lUFrtGkMXJQa+MMrAGWrq3Mu/ qY5614oMtMAxuk1yipsAGIGRqLKwa/RdVT0uLznCGg+zLOUQybLfQ76mKJVb4uOlcfGy yLrHpUQKcrxlYZOVg657fzO7lAbtC5YjUQq6U89TMox3NLMbWc67uS+exE1r/KbjXrJX no3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715213793; x=1715818593; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I18hWEBZjVSV+jGP4cfZ/tDEPN8kdHuFtgm/nhKoMMM=; b=fYZNAZiTMkS9KvZXneIOJBX3N8/bd6Leb9epHdLFxnVwVAOanFBgMfcYRA5/F/JzYw 15kE1w0ftVgGqP/RfomJiHGMYmkipTGqwAWA0AguvHhLeSckyAu4gkKKgJSopEoHaR5k jFvxxuu/rzysVVu/FDtFnkmsduxj8joB5zGutebGaiDKKo6HPw2HQEJZUykKXzSVcX0F Q8Ivma9Z0dKgkoGFefcq9y6AjFYOtPtYmXCuzz6p4PIvbJZyYohHNIUJ73+8qyooahWa 3cB8uZqHv6rcDEJfYS6cU/XJ0nKqVx6DVWc8QYFUmRkGEcAf7pYKgTSPchi138rdjByq gEuw== X-Gm-Message-State: AOJu0YwKOjOPRkvzEknXoiuERmVf9FVXY55GUxa2zO+bIyLUhFFve0yB U/n3xO60eNWqB1q/TGsOo9LJQ8GrTYYwQCNeE7SiaYawQARcSFh2 X-Google-Smtp-Source: AGHT+IFtV1p/3MkbzDUJpZi2MP6zVNqzaDqb7oN45fzp55mnl/AysMZHxSslHMtuB9REggDAEglMlw== X-Received: by 2002:a17:903:41cc:b0:1e3:e093:b5f0 with SMTP id d9443c01a7336-1eeb018707dmr50041505ad.8.1715213793246; Wed, 08 May 2024 17:16:33 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:641:300:4910:38af:f15:5ce3:fab2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0b9d4278sm1371095ad.12.2024.05.08.17.16.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2024 17:16:32 -0700 (PDT) In-Reply-To: <86jzk7a1pp.fsf@mail.linkov.net> X-Mailer: Apple Mail (2.3731.700.6.1.1) 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:284701 Archived-At: > On May 5, 2024, at 11:43 PM, Juri Linkov wrote: >=20 >>> '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. >>>=20 >>> So there is a need to handle this difference specially. Therefore = this >>> patch adds such special-handling of bobp to = 'treesit-outline-search=E2=80=99: >>=20 >> Thanks. Just for me to understand it better, could you show an >> example where treesit-navigate-thing misses text at point? >=20 > Here is an example: >=20 > 0. emacs -Q > 1. C-x C-f = test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb > 2. M-x ruby-ts-mode > 3. M-: (setq outline-minor-mode-use-buttons t) > 4. M-x outline-minor-mode >=20 > There are no outline buttons because the top thing "class" > is at the beginning of the buffer. Then you can insert > an empty line before "class", and disable/enable > outline-minor-mode again, and outline buttons appear > on "class" and "def" lines. >=20 > Basically this is because >=20 > (treesit-navigate-thing (point-min) 1 'beg = "\\`\\(?:class\\|method\\)\\'") >=20 > can't find "class" at the beginning of the buffer, > but after inserting an empty line before "class" it can find it. I see, from treesit-navigate-thing=E2=80=99s point of view, point is = already at the beginning of a class, therefore the correct behavior is = to go to the beg of the next class. Using =E2=80=98end is probably more = appropriate here, but I know you must have good reasons to use =E2=80=98be= g. How about using treesit-search-forward? Wait, am I the one that = suggested treesit-navigate-thing to you, because it returns = higher-leveled nodes first? In that case, maybe you can use treesit-thing-next to test if point is = at the beginning of an outline header? That feels a bit easier to write = and understand to me. If you prefer the current patch I don=E2=80=99t = have problem with it either. Yuan