From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pranshu Sharma Newsgroups: gmane.emacs.devel Subject: Re: hideshow support for treesitter Date: Fri, 6 Sep 2024 11:18:57 +1000 Message-ID: References: <86o753iet8.fsf@mail.linkov.net> <8634mey5us.fsf@mail.linkov.net> <86v7zaukn3.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000adc8000621693141" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40529"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 06 07:30:24 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 1smRY5-000AJk-Vy for ged-emacs-devel@m.gmane-mx.org; Fri, 06 Sep 2024 07:30:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smRXd-0001YE-RI; Fri, 06 Sep 2024 01:29:54 -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 1smNd2-0008GR-4o for emacs-devel@gnu.org; Thu, 05 Sep 2024 21:19:12 -0400 Original-Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smNd0-0000UY-9s for emacs-devel@gnu.org; Thu, 05 Sep 2024 21:19:11 -0400 Original-Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e02b79c6f21so1757677276.2 for ; Thu, 05 Sep 2024 18:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725585549; x=1726190349; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=g/LbR7+GnfzpdYCnf3UvFeY/3I0MOk1Z1GCrcNEYxGI=; b=i8tRjaIPi7NWSDN/7VYC366+BuAK/JvYF63kJqqk4voLsiCrWF/CrV4rzjPh3zJvS9 kQ0FIZHjDEpoiUl6A7YXTX4AlFGHwlCC1FNGUfrpV1cjPlZO/9cq1VBORpR9alH4Qdf+ Qv9WD3ncAYAMDplYz2SBCzKPH02JYTz3w8nX+xPlvf4GvS7XcGm2g1CrH0tlQQSt4Rw6 sVvJGRYTJEj9X3dKyGBcOCRUPvadNvZ42eZVL0WvjDzNE/lW392aq2OdCS74dx8w2Xpu wzTo9Cwh13HDmmiGEt7FKETnO0nTnx+RlzD23BMC+pMFfjM4VPKE4uU0Co8KmES49Phf aPMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725585549; x=1726190349; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g/LbR7+GnfzpdYCnf3UvFeY/3I0MOk1Z1GCrcNEYxGI=; b=g7ID5Ykq75nZeVtF4islnh/YblMn7CBUkABJcd57zwf4A2ZrMweXXk541HqlSmGKlI Bit8F5yqTW/pjiA6HiqF2+txBiFUO2pGOE/fvNuDh0w+xidQKWV7ZBIXJbQZinJ0mKnv YnsZYgODMJNQMR5encLWEIlPkyagodk8R3BYu7Lphyx4c+0sMMB21l/GXT1oAzaGQQr4 8PQiUckgFb+LGpD9wrILq1/omJkqpRNU8JnT57sPpSygYfNjq0pvRHodulqTh9wNb5Bm wGfFqFZ710JJVkFy41EXZpB3Vr0XzkGdx6ZW/we9bhI9MWNZeHh3IJsbma1rb6DYkJ/M tP4Q== X-Gm-Message-State: AOJu0YyvCOYZUH1umO/xpOqCz8jc+j50VD6yL0Hy2FSqTvyfaA4L9LtD YBM1+Nezor7SXPsizI+wtuDe0xf+FSRnqMOknUYgnzdm3OT8t+sjcRlI4bObR3sIhJrycf4YL/m 1rhsHnJJtyVCQFSW0T27aBxdsaUmbaPZv X-Google-Smtp-Source: AGHT+IHer5Ua4zXnWDO+VvysyIyTgiiUsOnjW9b+4ycr0f/8Ic5aTXZGh3eBdEw0XhUy8Sq2gaYdp2G25Mp0IjaTj9U= X-Received: by 2002:a05:6902:1583:b0:e1a:9a31:fc1e with SMTP id 3f1490d57ef6-e1d3488db64mr1702266276.23.1725585549017; Thu, 05 Sep 2024 18:19:09 -0700 (PDT) In-Reply-To: <86v7zaukn3.fsf@mail.linkov.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::b29; envelope-from=pranshusharma198@gmail.com; helo=mail-yb1-xb29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 06 Sep 2024 01:29:47 -0400 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:323438 Archived-At: --000000000000adc8000621693141 Content-Type: text/plain; charset="UTF-8" I am working to try get the hide show working for tree sitter, however one thing that is missing in treesit is sexp navigation functions, hideshow requires sexp function. 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. > > I looked at hideshow.el and found such a list: > > (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 "{\\|<[^/>]*?" "}\\|]*[^/]>" "