From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU ELPA] New package: blueprint-ts-mode Date: Mon, 02 Oct 2023 10:20:25 +0000 Message-ID: <87y1glfhqu.fsf@posteo.net> References: <1e45e194-a180-4d80-bd2b-2b5961d760e8@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30891"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Huan Thieu Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 02 12:21:45 2023 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 1qnG3c-0007gW-S8 for ged-emacs-devel@m.gmane-mx.org; Mon, 02 Oct 2023 12:21:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnG2a-0007G2-9D; Mon, 02 Oct 2023 06:20:40 -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 1qnG2X-0007Em-IN for emacs-devel@gnu.org; Mon, 02 Oct 2023 06:20:38 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnG2U-0000bu-3o for emacs-devel@gnu.org; Mon, 02 Oct 2023 06:20:36 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2333D240101 for ; Mon, 2 Oct 2023 12:20:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1696242026; bh=strQCIiLpQIrhn+uNz2R4FZQQ/lIl53N0yM2Rt/FrDM=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=ViMFxlUgPMpSj88nxE4SpFJLj5FuZqsE4G9XhvYkpWrcsZiU+0D2SepaWQMRD5/e1 LgdbGdMajkdHXQyRM59iKFL8ZfgxkcQ2GMFyQ0y3eWfNneEEYBIWMY82Btxo6QE0xC eUGWV9DeWhslQOAoeIB5JVXaLO40BWZZ7/QTCQANR63H45Q0Wd+6ILos+8+9cRa1Ur uuHF3fHBYZ3oyvlb6A066Y8n3EZuwJoPB0OlNpZAXmFdA9Vpk9ULRM2XZG0Rq5M1y0 Bw7us5HTZY4xpOvQGun5P5+bcPVarlb0H+zONLEBjb5HgA8Oc6qQm/oSE0uaPQwJ2g sZXrumIYuDkGA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RzcQx4K8cz9rxD; Mon, 2 Oct 2023 12:20:25 +0200 (CEST) In-Reply-To: <1e45e194-a180-4d80-bd2b-2b5961d760e8@gmail.com> (Huan Thieu Nguyen's message of "Sat, 9 Sep 2023 12:10:38 +0200") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:311236 Archived-At: --=-=-= Content-Type: text/plain Huan Thieu Nguyen writes: > Hi hi, > > I made a tree-sitter based mode for blueprint files > . I'd like to add it to > NonGNU ELPA. > > With best regards! > > Nguyen Thieu Huan A few suggestions and comments from my side: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/blueprint-ts-mode.el b/blueprint-ts-mode.el index 9a88399..d33e6d0 100644 --- a/blueprint-ts-mode.el +++ b/blueprint-ts-mode.el @@ -25,26 +25,34 @@ ;;; Commentary: ;; Treesitter based major mode for editing Blueprint files. -;; Blueprint is a new markup language for GTK4 user interfaces. For more information see . -;; This mode provides syntax highlighting, eglot integration and Treesitter based navigation. + +;; Blueprint is a new markup language for GTK4 user interfaces. For +;; more information see +;; . +;; This mode provides syntax highlighting, eglot integration and +;; Treesitter based navigation. ;;; Code: (require 'treesit) -(require 'rx) +(eval-when-compile (require 'rx)) (require 'eglot) +(defgroup blueprint () + "Tree-sitter support for Blueprint files." + :prefix "blueprint-ts-" + :group 'languages) + (defcustom blueprint-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `json-ts-mode'." - :version "29.1" :type 'integer - :safe 'integerp - :group 'blueprint) + :safe #'integerp) (defvar blueprint-ts-mode--keywords '("menu" "item" "section" "styles" "using" "bind" "template") "Blueprint keywords for tree-sitter font-locking.") +;; Why a macro? (defmacro blueprint-ts-mode--treesit-font-lock-rules (language &rest rules) "Wrapper around `treesit-font-lock-rules'. `LANGUAGE' is the treesitter language to use. @@ -62,7 +70,7 @@ ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((n-p-gp "object" "child" "object_content") - prev-sibling 0) ;; [child_type] indent + prev-sibling 0) ;; [child_type] indent (is this a meaningful comment?) ((parent-is "object_content") parent-bol blueprint-ts-mode-indent-offset) ((parent-is "template") parent-bol blueprint-ts-mode-indent-offset) ((parent-is "styles") parent-bol blueprint-ts-mode-indent-offset) @@ -101,7 +109,6 @@ ;;;###autoload (define-derived-mode blueprint-ts-mode prog-mode "Blueprint" "Blueprint major mode using treesitter." - :group 'blueprint (when (treesit-ready-p 'blueprint) (treesit-parser-create 'blueprint) ;; Comments @@ -118,7 +125,7 @@ (rx (or "template" "object" "menu"))) (setq-local treesit-sentence-type-regexp (rx (or "menu_attribute" "property"))) ;; Font-lock - (setq-local treesit-font-lock-level 4) + (setq-local treesit-font-lock-level 4) ;isn't this a user option? (setq-local treesit-font-lock-feature-list '((comment variable) (string keyword type) @@ -128,9 +135,8 @@ (treesit-major-mode-setup))) (add-to-list 'auto-mode-alist '("\\.blp\\'" . blueprint-ts-mode)) -(add-to-list 'eglot-server-programs +(add-to-list 'eglot-server-programs ;is there some way around having to load Eglot? '(blueprint-ts-mode . ("blueprint-compiler" "lsp"))) - (provide 'blueprint-ts-mode) ;;; blueprint-ts-mode.el ends here --=-=-=--