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.devel Subject: Re: hideshow support for treesitter Date: Sat, 7 Sep 2024 20:41:19 -0700 Message-ID: <05DFB538-1F1B-4675-BF78-AD3197B56CF1@gmail.com> References: <86o753iet8.fsf@mail.linkov.net> <8634mey5us.fsf@mail.linkov.net> <86v7zaukn3.fsf@mail.linkov.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) 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="9279"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Juri Linkov , emacs-devel@gnu.org To: Pranshu Sharma Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 08 05:42:26 2024 Return-path: Envelope-to: ged-emacs-devel@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 1sn8ok-0002HK-06 for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Sep 2024 05:42:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sn8o0-0005Xq-PO; Sat, 07 Sep 2024 23:41:40 -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 1sn8nz-0005XO-3h for emacs-devel@gnu.org; Sat, 07 Sep 2024 23:41:39 -0400 Original-Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sn8nx-00037f-Fv for emacs-devel@gnu.org; Sat, 07 Sep 2024 23:41:38 -0400 Original-Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2da4ea59658so2373805a91.0 for ; Sat, 07 Sep 2024 20:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725766892; x=1726371692; darn=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=w34IzYEe/rFEqHEWxJDdR/kKwnxyllVsEh7jUaOLuUo=; b=BJmYi4loWtyh9wtzxKDdyp8w0kNE+GAbiyXfTOwSbhf/NMzKVMYyFyTEcHHBGUZ/04 VuOxhUKGWqpFnxfagNR8dltnnDnUA2GytNVrrsdT/Amn1wyzfULqksKqMNUaqmqaxdot kYibX7j5pvKUFDMq4r6tM7021IO0+VCE2PimDCKJSlW2kMe1q5yA34G+Qv6pyYMDzwXp F9QiOuvOIJf2pTcvV7Il3I9vrTAAPidiiqeW4HXe1m1KNDhEfIi5aZs6gk7HIRml1ShZ PsUfT/tIjtilx4fya8uSVngKBV+SI3v1iecftO1HuXvwT8l4VuwSgQbZLW8AXFczESkB QRiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725766892; x=1726371692; 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=w34IzYEe/rFEqHEWxJDdR/kKwnxyllVsEh7jUaOLuUo=; b=KO0RuUj3EQSZbgGpcPepheHs3iW9STlJ4Cf4kTEqZ4lL9zZtRGU6uKkYWDyjOinMY2 BbyAPqK7PuS8YH/DA+9YiGFCue++gkFovTaAtpEjqD0OlGTChbaa6A0ryxxKY/zHNFwo q6cImISWqhC7i05FZIXTInO5jBjtBMBXd8SowAy4RU6PF1BtYcGRM1gxp8ADJnzPJ4HU ayIQ+dUqLszIXiAFkrWMwm4DYTsazADBtUVGtdLY79zz1+g1y9mUYKK6W0ysefh2hVhQ zDQzFzNIyqO/DJaLbP1JYZVdsadIza5zZ7+hWCOn7llg3vq7LVD+uqiVhvuNtnJnYscY txoA== X-Forwarded-Encrypted: i=1; AJvYcCWl+pBSLa83uqhVLgfndJimVgPjkeuxMMg0Vg9EG3I0olg6BSHLomPhtupWITkIuaD5B77u8KDcbNUfCg==@gnu.org X-Gm-Message-State: AOJu0YyOsC/iLgJoZ8BOqwrUOMqCjMzoPk+odPWhZi0RjG+P1XGrciWQ Efn8zx1PJAhFD3O7bGC6/Kj2s+6NFOnCiDrcsP2v5ny7V2eIBRV/ X-Google-Smtp-Source: AGHT+IEVKFbfhMiGA2gM2IP+2opWcs0ai9YAc8X/tVgYF0G54SW0TctJcdo/mOazXb8z+/VacCRpUw== X-Received: by 2002:a17:90b:3b44:b0:2c9:754d:2cba with SMTP id 98e67ed59e1d1-2dad4dde0c9mr7127823a91.3.1725766892115; Sat, 07 Sep 2024 20:41:32 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:9947:7537:5948:e5a0]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dab6e765basm2724298a91.1.2024.09.07.20.41.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Sep 2024 20:41:31 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=casouri@gmail.com; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323496 Archived-At: >=20 > On Fri, 6 Sept 2024 at 03:04, Juri Linkov wrote: > >>>>> Are there any plans to add treesitter support for hideshow, it = seems easy > >>>>> enough to do and also very helpful, especially for langs that = don't > >>>>> excessively use parens, such as python > >>>> > >>>> Indeed, it's easy to do this. You just need to override > >>>> hs-find-block-beginning-func, hs-find-next-block-func, etc. > >>>> with treesit functions like 'treesit-outline-search'. > >>> > >>> Ah I see, then I think treesit.el should contain code for this, = because > >>> this seems extremely useful task that would not make sense if each = tree > >>> sitter based major mode was to implement this separately > >> > >> Or hideshow code for treesit could be in hideshow.el as well. > >> The reason why 'treesit-outline-search' was added to treesit.el > >> was because treesit.el already contained imenu support. But > >> imenu support could be in imenu.el as well. > > > > Is there a preferred way to handle this treesit wise. I know some = packages > > (eg imenu) require major modes to define their support for it, but = others > > like ispell do it themselves. I personally thing the latter would be = better > > in this case. >=20 > I looked at hideshow.el and found such a list: >=20 > (defvar hs-special-modes-alist > (mapcar #'purecopy > '((c-mode "{" "}" "/[*/]" nil nil) > (c-ts-mode "{" "}" "/[*/]" nil nil) > (c++-mode "{" "}" "/[*/]" nil nil) > (c++-ts-mode "{" "}" "/[*/]" nil nil) > (bibtex-mode ("@\\S(*\\(\\s(\\)" 1)) > (java-mode "{" "}" "/[*/]" nil nil) > (java-ts-mode "{" "}" "/[*/]" nil nil) > (js-mode "{" "}" "/[*/]" nil) > (js-ts-mode "{" "}" "/[*/]" nil) > (lua-ts-mode "{\\|\\[\\[" "}\\|\\]\\]" "--" nil) > (mhtml-mode "{\\|<[^/>]*?" "}\\|]*[^/]>" "