@@ -96,134 +96,147 @@ See `tree-sitter-langs-repos'."
9696;;;### autoload
9797(defun tree-sitter-langs--init-major-mode-alist (&rest _args )
9898 " Link known major modes to languages provided by the bundle."
99- (dolist
100- (entry (reverse
101- '((actionscript-mode . actionscript)
102- (ada-mode . ada)
103- (agda-mode . agda)
104- (agda2-mode . agda)
105- (arduino-mode . arduino)
106- (astro-mode . astro)
107- (fish-mode . fish)
108- (asm-mode . asm)
109- (fasm-mode . asm)
110- (masm-mode . asm)
111- (nasm-mode . asm)
112- (gas-mode . asm)
113- (sh-mode . bash)
114- (beancount-mode . beancount)
115- (bibtex-mode . bibtex)
116- (c-mode . c)
117- (caml-mode . ocaml)
118- (clojure-mode . clojure)
119- (lisp-mode . commonlisp)
120- (lisp-interaction-mode . commonlisp)
121- (csharp-mode . c-sharp)
122- (c++-mode . cpp)
123- (cmake-mode . cmake)
124- (d-mode . d)
125- (dart-mode . dart)
126- (dockerfile-mode . dockerfile)
127- (css-mode . css)
128- (csv-mode . csv)
129- (elm-mode . elm)
130- (elixir-mode . elixir)
131- (emacs-lisp-mode . elisp)
132- (erlang-mode . erlang)
133- (ess-r-mode . r)
134- (fennel-mode . fennel)
135- (f90-mode . fortran)
136- (fortran-mode . fortran)
137- (gdscript-mode . gdscript)
138- (git-commit-mode . gitcommit)
139- (git-rebase-mode . git-rebase)
140- (gitattributes-mode . gitattributes)
141- (gitignore-mode . gitignore)
142- (gleam-mode . gleam)
143- (glsl-mode . glsl)
144- (go-mode . go)
145- (groovy-mode . groovy)
146- (jenkinsfile-mode . groovy)
147- (haskell-mode . haskell)
148- (haxe-mode . haxe)
149- (hcl-mode . hcl)
150- (terraform-mode . hcl)
151- (heex-mode . heex)
152- (hlsl-mode . hlsl)
153- (html-mode . html)
154- (markdown-mode . markdown)
155- (mhtml-mode . html)
156- (nix-mode . nix)
157- (jai-mode . jai)
158- (java-mode . java)
159- (javascript-mode . javascript)
160- (js-mode . javascript)
161- (js2-mode . javascript)
162- (js3-mode . javascript)
163- (json-mode . json)
164- (jsonc-mode . json)
165- (jsonnet-mode . jsonnet)
166- (julia-mode . julia)
167- (kotlin-mode . kotlin)
168- (latex-mode . latex)
169- (LaTeX-mode . latex)
170- (llvm-mode . llvm)
171- (llvm-mir-mode . llvm-mir)
172- (lua-mode . lua)
173- (magik-mode . magik)
174- (makefile-mode . make)
175- (makefile-automake-mode . make)
176- (makefile-gmake-mode . make)
177- (makefile-makepp-mode . make)
178- (makefile-bsdmake-mode . make)
179- (makefile-imake-mode . make)
180- (matlab-mode . matlab)
181- (mermaid-mode . mermaid)
182- (meson-mode . meson)
183- (ninja-mode . ninja)
184- (noir-mode . noir)
185- (ocaml-mode . ocaml)
186- (org-mode . org )
187- (pascal-mode . pascal)
188- (perl-mode . perl)
189- (purescript-mode . purescript)
190- (cperl-mode . perl)
191- (php-mode . php)
192- (qss-mode . css)
193- (prisma-mode . prisma)
194- (python-mode . python)
195- (pygn-mode . pgn)
196- (racket-mode . racket)
197- (rjsx-mode . javascript)
198- (rst-mode . rst)
199- (ruby-mode . ruby)
200- (rust-mode . rust)
201- (rustic-mode . rust)
202- (scala-mode . scala)
203- (scheme-mode . scheme)
204- (solidity-mode . solidity)
205- (smithy-mode . smithy)
206- (sql-mode . sql)
207- (svelte-mode . svelte)
208- (swift-mode . swift)
209- (tablegen-mode . tablegen)
210- (toml-mode . toml)
211- (conf-toml-mode . toml)
212- (tcl-mode . tcl)
213- (tuareg-mode . ocaml)
214- (twig-mode . twig)
215- (typescript-mode . typescript)
216- (typescript-tsx-mode . tsx)
217- (typst-mode . typst)
218- (verilog-mode . verilog)
219- (vhdl-mode . vhdl)
220- (nxml-mode . xml)
221- (yaml-mode . yaml)
222- (k8s-mode . yaml)
223- (zig-mode . zig))))
224- (cl-pushnew entry tree-sitter-major-mode-language-alist
225- :key #'car ))
226- (advice-remove 'tree-sitter--setup #'tree-sitter-langs--init-major-mode-alist ))
99+ (let ((alist '((actionscript-mode . actionscript)
100+ (ada-mode . ada)
101+ (agda-mode . agda)
102+ (agda2-mode . agda)
103+ (arduino-mode . arduino)
104+ (astro-mode . astro)
105+ (fish-mode . fish)
106+ (asm-mode . asm)
107+ (fasm-mode . asm)
108+ (masm-mode . asm)
109+ (nasm-mode . asm)
110+ (gas-mode . asm)
111+ (sh-mode . bash)
112+ (beancount-mode . beancount)
113+ (bibtex-mode . bibtex)
114+ (c-mode . c)
115+ (caml-mode . ocaml)
116+ (clojure-mode . clojure)
117+ (lisp-mode . commonlisp)
118+ (lisp-interaction-mode . commonlisp)
119+ (csharp-mode . c-sharp)
120+ (c++-mode . cpp)
121+ (cmake-mode . cmake)
122+ (d-mode . d)
123+ (dart-mode . dart)
124+ (dockerfile-mode . dockerfile)
125+ (css-mode . css)
126+ (csv-mode . csv)
127+ (elm-mode . elm)
128+ (elixir-mode . elixir)
129+ (emacs-lisp-mode . elisp)
130+ (erlang-mode . erlang)
131+ (ess-r-mode . r)
132+ (fennel-mode . fennel)
133+ (f90-mode . fortran)
134+ (fortran-mode . fortran)
135+ (gdscript-mode . gdscript)
136+ (git-commit-mode . gitcommit)
137+ (git-rebase-mode . git-rebase)
138+ (gitattributes-mode . gitattributes)
139+ (gitignore-mode . gitignore)
140+ (gleam-mode . gleam)
141+ (glsl-mode . glsl)
142+ (go-mode . go)
143+ (groovy-mode . groovy)
144+ (jenkinsfile-mode . groovy)
145+ (haskell-mode . haskell)
146+ (haxe-mode . haxe)
147+ (hcl-mode . hcl)
148+ (terraform-mode . hcl)
149+ (heex-mode . heex)
150+ (hlsl-mode . hlsl)
151+ (html-mode . html)
152+ (markdown-mode . markdown)
153+ (mhtml-mode . html)
154+ (nix-mode . nix)
155+ (jai-mode . jai)
156+ (java-mode . java)
157+ (javascript-mode . javascript)
158+ (js-mode . javascript)
159+ (js2-mode . javascript)
160+ (js3-mode . javascript)
161+ (json-mode . json)
162+ (jsonc-mode . json)
163+ (jsonnet-mode . jsonnet)
164+ (julia-mode . julia)
165+ (kotlin-mode . kotlin)
166+ (latex-mode . latex)
167+ (LaTeX-mode . latex)
168+ (llvm-mode . llvm)
169+ (llvm-mir-mode . llvm-mir)
170+ (lua-mode . lua)
171+ (magik-mode . magik)
172+ (makefile-mode . make)
173+ (makefile-automake-mode . make)
174+ (makefile-gmake-mode . make)
175+ (makefile-makepp-mode . make)
176+ (makefile-bsdmake-mode . make)
177+ (makefile-imake-mode . make)
178+ (matlab-mode . matlab)
179+ (mermaid-mode . mermaid)
180+ (meson-mode . meson)
181+ (ninja-mode . ninja)
182+ (noir-mode . noir)
183+ (ocaml-mode . ocaml)
184+ (org-mode . org )
185+ (pascal-mode . pascal)
186+ (perl-mode . perl)
187+ (purescript-mode . purescript)
188+ (cperl-mode . perl)
189+ (php-mode . php)
190+ (qss-mode . css)
191+ (prisma-mode . prisma)
192+ (python-mode . python)
193+ (pygn-mode . pgn)
194+ (racket-mode . racket)
195+ (rjsx-mode . javascript)
196+ (rst-mode . rst)
197+ (ruby-mode . ruby)
198+ (rust-mode . rust)
199+ (rustic-mode . rust)
200+ (scala-mode . scala)
201+ (scheme-mode . scheme)
202+ (solidity-mode . solidity)
203+ (smithy-mode . smithy)
204+ (sql-mode . sql)
205+ (svelte-mode . svelte)
206+ (swift-mode . swift)
207+ (tablegen-mode . tablegen)
208+ (toml-mode . toml)
209+ (conf-toml-mode . toml)
210+ (tcl-mode . tcl)
211+ (tuareg-mode . ocaml)
212+ (twig-mode . twig)
213+ (typescript-mode . typescript)
214+ (typescript-tsx-mode . tsx)
215+ (typst-mode . typst)
216+ (verilog-mode . verilog)
217+ (vhdl-mode . vhdl)
218+ (nxml-mode . xml)
219+ (yaml-mode . yaml)
220+ (k8s-mode . yaml)
221+ (zig-mode . zig))))
222+ (cond
223+ ; ; If never been set; update the value directly!
224+ ((null tree-sitter-major-mode-language-alist)
225+ (setq tree-sitter-major-mode-language-alist alist))
226+ ; ; Else, we try not to change the custom value from user.
227+ (t
228+ (dolist (entry alist)
229+ ; ; TODO: The `cl-pushnew' operation is very slow; better if we can use
230+ ; ; `hash-table' instead?
231+ ; ;
232+ ; ; I've run the benchmark tests with 123 entries (alist length);
233+ ; ; compare to set value directly. Obviously, set the value directly cost
234+ ; ; constant time but how fast compare to `cl-pushnew' ?
235+ ; ;
236+ ; ; It's average 325 to 650 times faster! The average time for each
237+ ; ; `cl-pushnew' operation is 2.6 to 5.2 times slower.
238+ (cl-pushnew entry tree-sitter-major-mode-language-alist :key #'car ))))
239+ (advice-remove 'tree-sitter--setup #'tree-sitter-langs--init-major-mode-alist )))
227240
228241;;;### autoload
229242(advice-add 'tree-sitter--setup :before #'tree-sitter-langs--init-major-mode-alist )
0 commit comments