]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/textmodes/markdown-ts-mode.el: Cleanup.
authorEshel Yaron <me@eshelyaron.com>
Thu, 20 Feb 2025 20:57:25 +0000 (21:57 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 20 Feb 2025 20:57:25 +0000 (21:57 +0100)
lisp/textmodes/markdown-ts-mode.el

index 62fa23c71055361d0b271b04ae9ffa40db030b70..78402e3c0cb0ae86b42181b62599171654038ae3 100644 (file)
@@ -1,4 +1,4 @@
-;;; markdown-ts-mode.el --- tree sitter support for Markdown  -*- lexical-binding: t; -*-
+;;; markdown-ts-mode.el --- major mode for Markdown  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2024-2025 Free Software Foundation, Inc.
 
@@ -41,7 +41,6 @@
    :feature 'delimiter
    '([ "[" "]" "(" ")" ] @shadow)
 
-
    :language 'markdown
    :feature 'paragraph
    '([((setext_heading) @font-lock-keyword-face)
 
 (defun markdown-ts-imenu-node-p (node)
   "Check if NODE is a valid entry to imenu."
-  (equal (treesit-node-type (treesit-node-parent node))
-         "atx_heading"))
+  (equal (treesit-node-type (treesit-node-parent node)) "atx_heading"))
 
 (defun markdown-ts-imenu-name-function (node)
   "Return an imenu entry if NODE is a valid header."
   (let ((name (treesit-node-text node)))
     (if (markdown-ts-imenu-node-p node)
-       (thread-first (treesit-node-parent node)(treesit-node-text))
+        (treesit-node-text (treesit-node-parent node))
       name)))
 
 (defun markdown-ts-setup ()
-  "Setup treesit for `markdown-ts-mode'."
+  "Setup tree-sitter for `markdown-ts-mode'."
   (setq-local treesit-font-lock-settings markdown-ts--treesit-settings)
   (treesit-major-mode-setup))
 
 (define-derived-mode markdown-ts-mode text-mode "Markdown"
   "Major mode for editing Markdown using tree-sitter grammar."
   (setq-local font-lock-defaults nil
-                 treesit-font-lock-feature-list '((delimiter)
-                                                  (paragraph)
-                                                  (paragraph-inline)))
+              treesit-font-lock-feature-list '((delimiter)
+                                               (paragraph)
+                                               (paragraph-inline)))
 
   (setq-local treesit-simple-imenu-settings
-              `(("Headings" markdown-ts-imenu-node-p nil markdown-ts-imenu-name-function)))
+              `(("Headings"
+                 markdown-ts-imenu-node-p nil markdown-ts-imenu-name-function)))
 
   (when (treesit-ready-p 'markdown)
     (treesit-parser-create 'markdown-inline)
 
 (derived-mode-add-parents 'markdown-ts-mode '(markdown-mode))
 
-(if (treesit-ready-p 'markdown)
-    (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-ts-mode)))
-
 (provide 'markdown-ts-mode)
 ;;; markdown-ts-mode.el ends here