From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#71407: 30.0.50; Support arrays in json-ts-mode's imenu support Date: Fri, 07 Jun 2024 09:16:34 +0200 Message-ID: <87cyotcje5.fsf@gnu.org> Mime-Version: 1.0 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="20181"; mail-complaints-to="usenet@ciao.gmane.io" To: 71407@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 07 09:17:53 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 1sFTrF-00052G-Cr for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Jun 2024 09:17:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFTrB-0000xp-ON; Fri, 07 Jun 2024 03:17:49 -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 1sFTrA-0000xV-FQ for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 03:17:48 -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 1sFTrA-0000wH-69 for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 03:17:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sFTrP-0002gt-73 for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 03:18:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Jun 2024 07:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71407 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171774463810219 (code B ref -1); Fri, 07 Jun 2024 07:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Jun 2024 07:17:18 +0000 Original-Received: from localhost ([127.0.0.1]:57615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFTqe-0002ej-TJ for submit@debbugs.gnu.org; Fri, 07 Jun 2024 03:17:17 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFTqc-0002eY-J7 for submit@debbugs.gnu.org; Fri, 07 Jun 2024 03:17:15 -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 1sFTqN-0008L2-9B for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 03:16:59 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFTqN-0000sI-0T for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 03:16:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=ZEIfuaBBucnJ5HvsPLo64MAd9WxicnIpx2ufqgHja5Y=; b=J1TZs8GmrW725N TNRjeHHmxV3aymiZEfLT2VtAlHdCf5n5pDWmAoyJ3U4McsXQUbuWp5BYI8b15dIgyEq+RjdgMGFv3 4/Qc7UnLEeN7opEssDyyMVqp0QQ3BHmhFl3LSbJAjQFRinS4vcwmMj/D3YrBcNxw7//sEtBWxrNw0 VEkEtgd64pdoyUasWdRUDInIeyHETdWAM1ueUBj6/34QwhuHpkCY2nsvjFYb+elQRcvYt7SDNa9nD X4ojv3/DdP1ZHiMcBReODsVoj9SEzQCg7yVd/4g6N+r0FAx+VcARXMj11i9wcErQB5oqdlALCMCK1 nQqSf9XBMkQfYFak5rsA==; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelledgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgfgsehtqhertd dttdejnecuhfhrohhmpefvrghsshhilhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhr gheqnecuggftrfgrthhtvghrnhephedugfeggeetuefftdekvdevieegheehveeitdfgte evgfdtudfhfedvueegtddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepthhhohhrnhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthi dqkeeijeefkeejkeegqdeifeehvdelkedqthhsughhpeepghhnuhdrohhrghesfhgrshht mhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail 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:286745 Archived-At: json-ts-mode adds imenu support for JSON files which is quite handy. However, it doesn't support arrays (e.g., [...]) which reduces its utility quite a bit. Here is an example JSON file with an array: --8<---------------cut here---------------start------------->8--- { "root": [ { "foo": 1, "bar": "test1" }, { "foo": 2, "bar": "test2" } ] } --8<---------------cut here---------------end--------------->8--- The Imenu *Completions* buffer with imenu-flatten set to t is: --8<---------------cut here---------------start------------->8--- Click or type M-RET on a completion to select it. Type M- or M- to move point between completions. 6 possible completions: *Rescan* root:. root:bar root:foo --8<---------------cut here---------------end--------------->8--- Aha aha, 6 completions but only 4 are displayed because root:foo and root:bar are basically there twice: --8<---------------cut here---------------start------------->8--- imenu--index-alist is a variable defined in =E2=80=98imenu.el=E2=80=99. Its value is (("root" (" " . #) ("foo" . #) ("bar" . #) ("foo" . #) ("bar" . #))) Local in buffer test.json; global value is nil --8<---------------cut here---------------end--------------->8--- Well, but even if they were displayed twice, I wouldn't be able to know which leads to the first and which to the second object's foo or bar. In an ideal world, arrays would produce numerically indexed intermediate nodes, e.g., I would have root:[0]:foo root:[0]:bar root:[1]:foo root:[1]:bar Is that feasible? AFAICS, the only Imenu thing json-ts-mode does is defining ;; Imenu. (setq-local treesit-simple-imenu-settings '((nil "\\`pair\\'" nil nil))) In GNU Emacs 30.0.50 (build 17, x86_64-pc-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) of 2024-06-07 built on thinkpad-t440p Repository revision: 6906ed28f1b4ac0cf0a2a725e7402290f33c26e2 Repository branch: master System Description: Arch Linux Configured using: 'configure --with-tree-sitter --with-pgtk --with-modules' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB Important settings: value of $LC_MONETARY: de_DE.utf8 value of $LC_NUMERIC: de_DE.utf8 value of $LC_TIME: de_DE.utf8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: ELisp/l Minor modes in effect: display-fill-column-indicator-mode: t display-line-numbers-mode: t breadcrumb-mode: t breadcrumb-local-mode: t editorconfig-mode: t debbugs-browse-mode: t hl-todo-mode: t global-aggressive-indent-mode: t aggressive-indent-mode: t pdf-occur-global-minor-mode: t diredfl-global-mode: t mu4e-modeline-mode: t which-key-mode: t highlight-parentheses-mode: t outline-minor-mode: t global-git-commit-mode: t magit-auto-revert-mode: t auto-revert-mode: t server-mode: t bug-reference-prog-mode: t corfu-popupinfo-mode: t corfu-history-mode: t global-corfu-mode: t corfu-mode: t vertico-mode: t marginalia-mode: t minibuffer-depth-indicate-mode: t switchy-window-minor-mode: t electric-pair-mode: t recentf-mode: t override-global-mode: t repeat-mode: t global-so-long-mode: t save-place-mode: t savehist-mode: t puni-global-mode: t puni-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t column-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: ~/Repos/el/mu/mu4e/mu4e hides ~/Repos/el/mu/build/mu4e/mu4e ~/Repos/el/mu/mu4e/mu4e-modeline hides ~/Repos/el/mu/build/mu4e/mu4e-modeli= ne ~/Repos/el/mu/mu4e/mu4e-context hides ~/Repos/el/mu/build/mu4e/mu4e-context ~/Repos/el/mu/mu4e/mu4e-main hides ~/Repos/el/mu/build/mu4e/mu4e-main ~/Repos/el/mu/mu4e/mu4e-vars hides ~/Repos/el/mu/build/mu4e/mu4e-vars ~/Repos/el/mu/mu4e/mu4e-window hides ~/Repos/el/mu/build/mu4e/mu4e-window ~/Repos/el/mu/mu4e/mu4e-speedbar hides ~/Repos/el/mu/build/mu4e/mu4e-speedb= ar ~/Repos/el/mu/mu4e/mu4e-view hides ~/Repos/el/mu/build/mu4e/mu4e-view ~/Repos/el/mu/mu4e/mu4e-thread hides ~/Repos/el/mu/build/mu4e/mu4e-thread ~/Repos/el/mu/mu4e/mu4e-bookmarks hides ~/Repos/el/mu/build/mu4e/mu4e-bookm= arks ~/Repos/el/mu/mu4e/mu4e-org hides ~/Repos/el/mu/build/mu4e/mu4e-org ~/Repos/el/mu/mu4e/mu4e-lists hides ~/Repos/el/mu/build/mu4e/mu4e-lists ~/Repos/el/mu/mu4e/mu4e-actions hides ~/Repos/el/mu/build/mu4e/mu4e-actions ~/Repos/el/mu/mu4e/mu4e-helpers hides ~/Repos/el/mu/build/mu4e/mu4e-helpers ~/Repos/el/mu/mu4e/mu4e-search hides ~/Repos/el/mu/build/mu4e/mu4e-search ~/Repos/el/mu/mu4e/mu4e-server hides ~/Repos/el/mu/build/mu4e/mu4e-server ~/Repos/el/mu/mu4e/mu4e-obsolete hides ~/Repos/el/mu/build/mu4e/mu4e-obsole= te ~/Repos/el/mu/mu4e/mu4e-update hides ~/Repos/el/mu/build/mu4e/mu4e-update ~/Repos/el/mu/mu4e/mu4e-draft hides ~/Repos/el/mu/build/mu4e/mu4e-draft ~/Repos/el/mu/mu4e/mu4e-message hides ~/Repos/el/mu/build/mu4e/mu4e-message ~/Repos/el/mu/mu4e/mu4e-compose hides ~/Repos/el/mu/build/mu4e/mu4e-compose ~/Repos/el/mu/mu4e/mu4e-headers hides ~/Repos/el/mu/build/mu4e/mu4e-headers ~/Repos/el/mu/mu4e/mu4e-query-items hides ~/Repos/el/mu/build/mu4e/mu4e-que= ry-items ~/Repos/el/mu/mu4e/mu4e-notification hides ~/Repos/el/mu/build/mu4e/mu4e-no= tification ~/Repos/el/mu/mu4e/mu4e-contacts hides ~/Repos/el/mu/build/mu4e/mu4e-contac= ts ~/Repos/el/mu/mu4e/mu4e-icalendar hides ~/Repos/el/mu/build/mu4e/mu4e-icale= ndar ~/Repos/el/mu/mu4e/mu4e-mark hides ~/Repos/el/mu/build/mu4e/mu4e-mark ~/Repos/el/mu/mu4e/mu4e-contrib hides ~/Repos/el/mu/build/mu4e/mu4e-contrib ~/Repos/el/mu/mu4e/mu4e-folders hides ~/Repos/el/mu/build/mu4e/mu4e-folders ~/Repos/el/mu/mu4e/mu4e-mime-parts hides ~/Repos/el/mu/build/mu4e/mu4e-mime= -parts /home/horn/.emacs.d/elpa/ef-themes-1.7.0/theme-loaddefs hides /home/horn/Re= pos/el/emacs/lisp/theme-loaddefs /home/horn/.emacs.d/elpa/transient-20240603.2200/transient hides /home/horn= /Repos/el/emacs/lisp/transient Features: (shadow sort expreg cap-words superword subword face-remap mail-extr emacsbug shortdoc cl-print misearch multi-isearch cus-start view help-fns radix-tree tramp-cmds puni display-fill-column-indicator display-line-numbers ef-dream-theme generic yaml-mode fish-mode cargo xref cargo-process rust-utils rust-mode-treesitter rust-ts-mode rust-mode rust-playpen rust-compile rust-cargo rust-common rust-rustfmt web-mode disp-table auctex-autoloads tex-site breadcrumb pulse project editorconfig editorconfig-core editorconfig-core-handle editorconfig-fnmatch elfeed-show elfeed-search vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view debbugs-browse elfeed-csv elfeed elfeed-curl elfeed-log elfeed-db elfeed-lib avl-tree url-queue xml-query hl-todo aggressive-indent rainbow-mode pdf-occur tablist tablist-filter semantic/wisent/comp semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local cedet pdf-isearch pdf-misc pdf-tools pdf-view jka-compr pdf-cache pdf-info tq pdf-util pdf-macs image-mode exif vc-git vc-dir ewoc epa-file trashed diredfl dired-x eshell esh-cmd generator esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-module-loaddefs esh-util mu4e-icalendar gnus-icalendar icalendar diary-lib diary-loaddefs mu4e mu4e-org mu4e-notification notifications mu4e-main smtpmail mu4e-view mu4e-mime-parts mu4e-headers mu4e-thread mu4e-actions org-capture org-refile org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete org-list org-footnote org-faces org-entities ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs cal-menu calendar cal-loaddefs org-compat org-version org-macs mu4e-compose mu4e-draft gnus-msg mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message flow-fill mule-util mu4e-contacts mu4e-update mu4e-folders mu4e-context mu4e-query-items mu4e-server mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window magit-bookmark bookmark ido mu4e-obsolete hippie-exp auto-dictionary flyspell ispell tramp-smb which-key highlight-parentheses restclient forge-repos forge-topics forge-tablist hl-line forge-commands forge-semi forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy gsexp ghub let-alist forge-notify forge-revnote forge-pullreq forge-issue forge-topic yaml forge-post markdown-mode noutline outline forge-repo forge forge-core forge-db closql emacsql-sqlite-common emacsql emacsql-compiler eieio-base magit-submodule magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff diff-mode track-changes git-commit log-edit pcvs-util add-log magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor comp comp-cstr comp-run comp-common server magit-mode magit-git magit-base magit-section cursor-sensor crm dash visual-filename-abbrev rg vc vc-dispatcher rg-info-hack advice rg-menu transient rg-ibuffer rg-result wgrep-rg wgrep rg-history rg-header ibuf-ext ibuffer ibuffer-loaddefs grep compile debbugs soap-client url-http url-auth url-gw nsm warnings rng-xsd rng-dt rng-util xsd-regexp bug-reference thingatpt kind-icon svg-lib color corfu-popupinfo corfu-history corfu vertico marginalia icomplete mb-depth use-package-diminish switchy-window compat elec-pair recentf tree-widget edmacro kmacro use-package-bind-key bind-key diminish repeat toml-ts-mode json-ts-mode c++-ts-mode c-ts-mode java-ts-mode c-ts-common find-func treesit so-long saveplace tramp-sh tramp rx trampver tramp-integration files-x tramp-message tramp-compat xdg shell pcomplete comint ansi-osc ring format-spec ansi-color tramp-loaddefs savehist smiley gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message sendmail yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util text-property-search time-date mm-util mail-prsvr mail-utils range ef-themes cl-extra help-mode use-package-ensure use-package-core finder-inf cus-edit pp cus-load wid-edit aggressive-indent-autoloads auto-dictionary-autoloads breadcrumb-autoloads cape-autoloads cargo-autoloads clojure-mode-autoloads corfu-autoloads csv-mode-autoloads debbugs-autoloads diminish-autoloads diredfl-autoloads eat-autoloads editorconfig-autoloads ef-themes-autoloads elfeed-autoloads ement-autoloads expreg-autoloads fish-mode-autoloads forge-autoloads closql-autoloads emacsql-autoloads ghub-autoloads highlight-parentheses-autoloads hl-todo-autoloads kind-icon-autoloads magit-autoloads pcase git-commit-autoloads marginalia-autoloads markdown-mode-autoloads mastodon-autoloads pdf-tools-autoloads persist-autoloads plz-autoloads puni-autoloads easy-mmode rainbow-mode-autoloads rcirc-color-autoloads request-autoloads restclient-autoloads rg-autoloads rust-mode-autoloads svg-lib-autoloads symbol-overlay-autoloads tablist-autoloads taxy-magit-section-autoloads taxy-autoloads magit-section-autoloads dash-autoloads totp-autoloads transient-autoloads trashed-autoloads treepy-autoloads vertico-autoloads visual-filename-abbrev-autoloads web-mode-autoloads wgrep-autoloads which-key-autoloads info with-editor-autoloads yaml-autoloads yaml-mode-autoloads package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win touch-screen pgtk-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty move-toolbar make-network-process native-compile emacs) Memory information: ((conses 16 984076 183372) (symbols 48 53395 6) (strings 32 250404 9159) (string-bytes 1 7591933) (vectors 16 91715) (vector-slots 8 1078837 171011) (floats 8 796 1643) (intervals 56 28407 354) (buffers 992 24))