From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] feat: add markdown-ts-mode Date: Sat, 20 Apr 2024 09:44:07 +0300 Message-ID: <86frvga5zc.fsf@gnu.org> References: <877cgs7m4e.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30894"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Rahul Martim Juliato , Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 20 08:44:50 2024 Return-path: Envelope-to: ged-emacs-devel@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 1ry4Sv-0007qm-3s for ged-emacs-devel@m.gmane-mx.org; Sat, 20 Apr 2024 08:44:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ry4SM-0003qj-3p; Sat, 20 Apr 2024 02:44:14 -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 1ry4SJ-0003qY-1Z for emacs-devel@gnu.org; Sat, 20 Apr 2024 02:44:11 -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 1ry4SI-0001iG-On; Sat, 20 Apr 2024 02:44:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=JolaVpnuzi0s+/rjDeY0wFeYeCawXfDF9iCmng74Nuc=; b=XWLj85B3MwoR Z2cnBEjn1P4L6/i1Bk+LUz5A/jzKRqUqx1/L4OjK4ancZe2eiid7Ls1MtfE5dmTF6NsXaGBixU+Lv MTxLskPuQ0CGGjDm9wALsLVOYaVpKCE+2go+/Dw5c8lZ0hJht4E01HUB1nra5XE/E08LQbhLYeiul Zv7Tu0MjrqWTWIWKC+iAKvtUCxCJZS2Nmzy6sVhL1D8B10MgQWTgr6DR/e1q1llPkIiDyF55WiBwp m2I/Y1i2ZbXV8VoRqUhLWo0CASei/q0Tewk64ZBJ2yyUNCP4feCW61PK9TQn6mnagC0mOrJpjOweg 0MwpjMRR/1nmmWZK/HVM4w==; In-Reply-To: <877cgs7m4e.fsf@gmail.com> (message from Rahul Martim Juliato on Sat, 20 Apr 2024 00:23:45 -0300) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317869 Archived-At: > From: Rahul Martim Juliato > Date: Sat, 20 Apr 2024 00:23:45 -0300 > > I've been using Emacs without any extra packages as an educational > experiment after years of package hording. > > > One of the few things I've been missing is a way of displaying some sort > of syntax highlight for markdown documents. > > > It feels a bit frustrating opening a README.md file with a single face > color, since Emacs from the box can handle so much. I am sure others > might have shared this feeling before. > > > This patch is a modified version of a package I've recently published on > MELPA, screenshots are available here: > https://github.com/LionyxML/markdown-ts-mode > > > It is a very basic mode that provides syntax highlight and imenu support > using treesitter grammar from > https://github.com/tree-sitter-grammars/tree-sitter-markdown > > > The idea here is to provide minimal support to Emacs and continue > building up features in the future. > > > It is the first time I contribute to Emacs devel, so please let me know > if I did something wrong or anything is not at the expected standards. Thanks, please see a couple of comments below. I've CC'ed Yuan as well, in case he has comments. > >From 364f61b03d601d2cb3aeb1687da2d1b2a232474c Mon Sep 17 00:00:00 2001 > From: Rahul Martim Juliato > Date: Fri, 19 Apr 2024 23:21:20 -0300 > > --- > etc/NEWS | 5 ++ > lisp/progmodes/markdown-ts-mode.el | 106 +++++++++++++++++++++++++++++ > 2 files changed, 111 insertions(+) > create mode 100644 lisp/progmodes/markdown-ts-mode.el Please accompany the patches with a ChangeLog-style commit log message; see CONTRIBUTE for the details. In this case, you'd need a very minimal one, something like: * lisp/progmodes/markdown-ts-mode.el: New file. * etc/NEWS: Announce the new mode. > +--- > +*** New major mode 'markdown-ts-mode'. > +A major mode based on the tree-sitter library for editing Markdown files. How about mentioning this in the user manual as well? It doesn't have to be anything more than just the name of the mode. > diff --git a/lisp/progmodes/markdown-ts-mode.el b/lisp/progmodes/markdown-ts-mode.el Should this mode live in lisp/textmodes/ instead? Markdown is AFAIU a mode for text with markup, it isn't a programming language. > +(defun markdown-ts-setup () > + "Setup treesit for `markdown-ts-mode'." > + (setq-local treesit-font-lock-settings markdown-ts--treesit-settings) > + (treesit-major-mode-setup)) > + > +;;;###autoload > +(define-derived-mode markdown-ts-mode fundamental-mode "markdown[ts]" > + "Major mode for editing Markdown using tree-sitter grammar." > + (setq-local font-lock-defaults nil > + treesit-font-lock-feature-list '((delimiter) > + (paragraph))) I wonder whether this mode should inherit from Text mode instead, and consequently have some text-related commands, perhaps aided by the tree-sitter grammar? WDYT? We could, of course, add commands later, but the decision to have Text mode as the parent of this one should be made now.