From dbda47d09961b3527b965470845034c78136bab8 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 11 Jun 2025 15:36:43 +0200 Subject: emacs: Don’t break with markdown-inline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/emacs/modules/mm-treesit.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to '.config/emacs') diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el index 68f3bb0..4e052de 100644 --- a/.config/emacs/modules/mm-treesit.el +++ b/.config/emacs/modules/mm-treesit.el @@ -122,18 +122,27 @@ the associated language’s major-mode should be enabled. This alist is used to configure `auto-mode-alist'.") +(defvar mm-treesit-dont-have-modes + '(markdown-inline) + "List of languages that don't have modes. +Some languages may come with multiple parsers, (e.g. `markdown' and +`markdown-inline') and as a result one-or-more of the parsers won't be +associated with a mode. To avoid breaking the configuration, these +languages should be listed here.") + (dolist (spec treesit-language-source-alist) (let* ((lang (car spec)) (lang (alist-get lang mm-treesit-language-remap-alist lang)) - (symbol-name (symbol-name lang)) - (name-mode (intern (concat symbol-name "-mode"))) - (name-ts-mode (intern (concat symbol-name "-ts-mode")))) + (name-mode (intern (format "%s-mode" lang))) + (name-ts-mode (intern (format "%s-ts-mode" lang)))) ;; If ‘name-ts-mode’ is already in ‘auto-mode-alist’ then we don’t ;; need to do anything, however if that’s not the case then if ;; ‘name-ts-mode’ and ‘name-mode’ are both bound we do a simple ;; remap. If the above is not true then we lookup the extensions in ;; ‘mm-treesit-language-file-name-alist’. (cond + ((memq lang mm-treesit-dont-have-modes) + nil) ((not (fboundp name-ts-mode)) (warn "`%s' is missing." name-ts-mode)) ((rassq name-ts-mode auto-mode-alist) -- cgit v1.2.3