From: Juri Linkov Date: Thu, 17 Apr 2025 17:21:16 +0000 (+0300) Subject: * lisp/treesit.el (treesit-parsers-at): Fix for 'with-host' arg. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d0bd880af7ba0b4ff6743ceca2536841aa39142a;p=emacs.git * lisp/treesit.el (treesit-parsers-at): Fix for 'with-host' arg. Don't add the primary parser or the first of treesit-parser-list when non-nil 'with-host' is provided since there is no host for the primary parser (bug#76788). (cherry picked from commit 2808bef2522481b3b3e6a7f2739ae8dbd02c13f5) --- diff --git a/lisp/treesit.el b/lisp/treesit.el index 009c219dd9f..ec4ddce5ae9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -872,10 +872,10 @@ If ONLY contains the symbol `primary', include the primary parser." (and (memq 'global only) (not (overlay-get ov 'treesit-parser-local-p)))))) (push (if with-host (cons parser host-parser) parser) res))) - (when (and treesit-primary-parser (or (null only) (memq 'primary only))) - (push treesit-primary-parser res)) - (unless res - (push (car (treesit-parser-list)) res)) + (when (and (not with-host) (or (null only) (memq 'primary only))) + (push (or treesit-primary-parser + (car (treesit-parser-list))) + res)) (seq-sort-by (lambda (p) (treesit-parser-embed-level (or (car-safe p) p)))