From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Huan Nguyen Newsgroups: gmane.emacs.devel Subject: Re: outline-mode treesitter support? Date: Thu, 21 Dec 2023 05:03:03 +0100 Message-ID: <41ED492A-0520-49CE-BA9F-35085BEFEDEF@gmail.com> References: <1D18C79B-A9D5-4ECD-A95C-33159A28E2CD@gmail.com> <86r0jit8rn.fsf@mail.linkov.net> <8C0E4C36-4323-4E1B-A7A5-25A76CE5716C@gmail.com> <86sf3xjtfe.fsf@mail.linkov.net> <864jgc94yp.fsf@mail.linkov.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) 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="5694"; 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 Thu Dec 21 07:11:06 2023 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 1rGCGw-0001LT-7A for ged-emacs-devel@m.gmane-mx.org; Thu, 21 Dec 2023 07:11:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGCG7-0007Zo-2N; Thu, 21 Dec 2023 01:10:15 -0500 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 1rGAHH-0000g5-1R for emacs-devel@gnu.org; Wed, 20 Dec 2023 23:03:19 -0500 Original-Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGAHF-0008KN-HP for emacs-devel@gnu.org; Wed, 20 Dec 2023 23:03:18 -0500 Original-Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-552fba34d69so379935a12.3 for ; Wed, 20 Dec 2023 20:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703131395; x=1703736195; 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=zgkvQjd+SFnrJAGH9ub3aOqd0/ZFz6x1+HhdJLB4VWg=; b=dK+oMCsm5W/1J91OHCXGfXoR6vQObrmFWYrHgOiHx0fYq3MOjMVlneJy7rb0yPaBD5 UYnaN8zC2iGaIDi6eNQ3YhcPqWAlq6igkFP7jbnedzX0SJbSSmk3cqBfLbslXjhAn0cb cyNZqd1e1qa98AJi0cB1qg/TY89wRQrcdGFsXmiyOzwWsCl/lO9nOEmDNRi6AdqK6sh3 4DZohljV9WvfNMAZe7Veq6bfexaaLmeADHOn2UeQMsQS1wCELLFMSg+xydw9paSXzyjT o5PAWfNW0z4iW/BwLSHhhgo3tpCSkXm6wS2q0phoo8tJRDpg9TngLv26upHkCR6rikrx 5Gow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703131395; x=1703736195; 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=zgkvQjd+SFnrJAGH9ub3aOqd0/ZFz6x1+HhdJLB4VWg=; b=tCLG94NVBZAnwl1kGwo3NP3K46vxQSNNe26zy5usBqvGboTxcvjW3MUmch9sbJGUEw fiuc9T9cQSp8wgWC3WKb5g+nrrZlQSWrP5aR877sbBEMqctFsbtq7BuLzg9B5WhkYb0Q KtHTdK/j86K1uI0OIl0sT6l4guaRt8egwoZrXh4YVbGB0XZSD6NgWaHF4bkgym00Pk33 xLO3f6hcpilVO9ClOcA05rt4UAuvHqx1UiZCXx3LnWcb462hcSzTCAtuJwQTOFw4cLQI 3F+hTpDorBLU9h8ICTKdrIqIOZb/vOBMG7eGX+tD9kJ0USvBVzxIpwEPyQX8tpz1Rhrw +6bA== X-Gm-Message-State: AOJu0YyQyyH9MiP9qxl3EXsmjBQZ7F5dOdxB1CyUJcOK/OvsjKl9HTyp joQ0bp4u8ATQRKzTZGDV8/yhCidwbAc= X-Google-Smtp-Source: AGHT+IHGOL4DIzyKz7c2fX3ZvgYA5VrW5+hehtOzKSgNkHUEXgXVDVxL1LFSNxWllzBoE4jLrJpYhA== X-Received: by 2002:a17:906:20c8:b0:a19:7781:3e2a with SMTP id c8-20020a17090620c800b00a1977813e2amr10043305ejc.23.1703131395092; Wed, 20 Dec 2023 20:03:15 -0800 (PST) Original-Received: from smtpclient.apple (46.183.103.17.relaix.net. [46.183.103.17]) by smtp.gmail.com with ESMTPSA id k27-20020a17090627db00b00a268ee9017fsm488466ejc.157.2023.12.20.20.03.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2023 20:03:14 -0800 (PST) In-Reply-To: <864jgc94yp.fsf@mail.linkov.net> X-Mailer: Apple Mail (2.3774.300.61.1.2) Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=nguyenthieuhuan@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 21 Dec 2023 01:10:13 -0500 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:314031 Archived-At: > On Dec 20, 2023, at 18:08, Juri Linkov wrote: >=20 >> OK, one way to extract treesit information for outline-minor-mode is = by using >> =E2=80=98treesit-simple-imenu=E2=80=99 because outline headings = should correspond to imenu entries. >=20 > I don't know if this is a good idea, but with >=20 > (setq-local outline-search-function #'outline-search-imenu > outline-level (lambda () 1)) >=20 > this should do the trick: >=20 > #+begin_src emacs-lisp > (defun outline-search-imenu (&optional bound move backward looking-at) > (unless imenu--index-alist > (imenu--make-index-alist)) > (let* ((imenu-index (cdar imenu--index-alist)) > (imenu-positions (mapcar (lambda (i) (cdr i)) imenu-index))) > (if looking-at > (when (member (point-marker) imenu-positions) > (set-match-data (list (pos-bol) (pos-eol))) > t) > (let ((found (if backward > (seq-find (lambda (p) (< p (pos-bol))) (nreverse = imenu-positions)) > (seq-find (lambda (p) (> p (pos-eol))) = imenu-positions)))) > (if found > (if (or (not bound) (if backward (>=3D found bound) (<=3D = found bound))) > (progn > (goto-char found) > (goto-char (pos-bol)) > (set-match-data (list (point) (pos-eol))) > t) > (when move (goto-char bound)) > nil) > (when move (goto-char (or bound (if backward (point-min) = (point-max))))) > nil))))) > #+end_src Thanks for the example!=