From: Philip Kaludercic <philipk@posteo.net>
To: Aleksandr Vityazev <avityazew@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [ELPA] New package devicetree-ts-mode
Date: Fri, 22 Dec 2023 07:36:51 +0000 [thread overview]
Message-ID: <87bkaiadt8.fsf@posteo.net> (raw)
In-Reply-To: <874jgb5tx8.fsf@gmail.com> (Aleksandr Vityazev's message of "Thu, 21 Dec 2023 20:47:47 +0300")
[-- Attachment #1: Type: text/plain, Size: 291 bytes --]
Aleksandr Vityazev <avityazew@gmail.com> writes:
> Hello,
>
> I'd like to submit devicetree-ts-mode [1] to GNU ELPA.
> This is tree-sitter major mode for Devicetree [2] files.
>
> [1] https://git.sr.ht/~akagi/devicetree-ts-mode/
> [2] https://www.devicetree.org/
Here are a few comments:
[-- Attachment #2: Type: text/plain, Size: 3397 bytes --]
diff --git a/devicetree-ts-mode.el b/devicetree-ts-mode.el
index 1d9f72c..d26937c 100644
--- a/devicetree-ts-mode.el
+++ b/devicetree-ts-mode.el
@@ -33,6 +33,7 @@
;; * IMenu
;; * Font Lock
+;; The commentary section could elaborate on what "Devicetree" are.
;;; Code:
@@ -44,15 +45,21 @@
(declare-function treesit-parser-create "treesit.c")
(declare-function treesit-node-child-by-field-name "treesit.c")
+(defgroup devicetree ()
+ "Tree-sitter support for DTS."
+ :prefix "devicetree-ts-"
+ :group 'languages)
+
(defcustom devicetree-ts-mode-indent-offset 4
"Number of spaces for each indentation step in `devicetree-ts-mode'."
:version "29.1"
+ ;; This is not a core package, the version of your package is 0.2,
+ ;; so this doesn't match up
:type 'natnum
- :safe 'natnump
- :group 'devicetree)
+ :safe 'natnump)
;; Taken from the dts-mode
-(defvar devicetree-ts-mode--syntax-table
+(defvar devicetree-ts-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?< "(>" table)
@@ -81,6 +88,10 @@
(defvar devicetree-ts-mode--indent-rules
(let ((offset devicetree-ts-mode-indent-offset))
+ ;; If this is a variable, that is set when the package is loaded,
+ ;; customising the user option `devicetree-ts-mode-indent-offset'
+ ;; will have no effect. You could turn this into a function
+ ;; instead.
`((devicetree
((node-is ">") parent-bol 0)
((node-is "]") parent-bol 0)
@@ -93,13 +104,14 @@
(no-node parent-bol 0))))
"Tree-sitter indent rules for `devicetree-ts-mode'.")
+;; Could these be defconst?
(defvar devicetree-ts-mode--treesit-keywords
'("/delete-node/" "/delete-property/" "#define" "#include"
"/omit-if-no-ref/" "/dts-v1/"))
(defvar devicetree-ts-mode--treesit-operators
- '( "!" "~" "-" "+" "*" "/" "%" "||" "&&" "|"
- "^" "&" "==" "!=" ">" ">=" "<=" ">" "<<" ">>"))
+ '("!" "~" "-" "+" "*" "/" "%" "||" "&&" "|"
+ "^" "&" "==" "!=" ">" ">=" "<=" ">" "<<" ">>"))
(defvar devicetree-ts-mode--font-lock-settings
(treesit-font-lock-rules
@@ -154,8 +166,8 @@
(defun devicetree-ts-mode--node-addresses (node)
"List of addresses for NODE."
- (reverse
- (seq-reduce
+ (reverse ;Why `reverse'? (or `nreverse'?)
+ (seq-reduce ;Isn't this a `seq-filter'?
(lambda (acc children)
(if (string-equal (treesit-node-field-name children)
"address")
@@ -175,8 +187,6 @@
;;;###autoload
(define-derived-mode devicetree-ts-mode prog-mode "DTS"
"Major mode for editing devicetree, powered by tree-sitter."
- :group 'devicetree
- :syntax-table devicetree-ts-mode--syntax-table
(when (treesit-ready-p 'devicetree)
(treesit-parser-create 'devicetree)
@@ -187,7 +197,7 @@
;; Imenu.
(setq-local treesit-simple-imenu-settings
- `((nil "\\`node\\'"
+ `((nil ,(rx bos "node" eos)
nil devicetree-ts--mode--name-function)))
(setq-local which-func-functions nil)
@@ -216,9 +226,8 @@
(treesit-major-mode-setup)))
-(if (treesit-ready-p 'devicetree)
- (add-to-list 'auto-mode-alist
- '("\\.dtsi?\\'" . devicetree-ts-mode)))
+(when (treesit-ready-p 'devicetree)
+ (add-to-list 'auto-mode-alist '("\\.dtsi?\\'" . devicetree-ts-mode)))
(provide 'devicetree-ts-mode)
;;; devicetree-ts-mode.el ends here
[-- Attachment #3: Type: text/plain, Size: 1151 bytes --]
>
> From b69687be8232cfd305893b7c0b6999e6667d6dd8 Mon Sep 17 00:00:00 2001
> Message-ID: <b69687be8232cfd305893b7c0b6999e6667d6dd8.1703075351.git.avityazew@gmail.com>
> From: Aleksandr Vityazev <avityazew@gmail.com>
> Date: Wed, 20 Dec 2023 15:28:35 +0300
> Subject: [PATCH] * elpa-packages (devicetree-ts-mode): New package
>
> ---
> elpa-packages | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/elpa-packages b/elpa-packages
> index 612bc676cd..6f86a59cfd 100644
> --- a/elpa-packages
> +++ b/elpa-packages
> @@ -207,6 +207,8 @@
> :news "CHANGELOG.org"
> :readme "README.md")
> (devdocs :url "https://github.com/astoff/devdocs.el")
> + (devicetree-ts-mode :url "https://sr.ht/~akagi/devicetree-ts-mode"
> + :ignored-files ("LICENSE"))
You can track this file in an .elpaignore file, within your repository
(which you appear to have anyway).
> (dict-tree :url nil) ;"http://www.dr-qubit.org/git/predictive.git"
> (diff-hl :url "https://github.com/dgutov/diff-hl.git")
> (diffview :url "https://github.com/mgalgs/diffview-mode.git")
>
> base-commit: b7bbd439862f2a58151eacacebc1815b7ddf3322
> --
> 2.41.0
next prev parent reply other threads:[~2023-12-22 7:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 17:47 [ELPA] New package devicetree-ts-mode Aleksandr Vityazev
2023-12-22 7:36 ` Philip Kaludercic [this message]
2023-12-22 20:08 ` Aleksandr Vityazev
2024-01-07 13:27 ` Aleksandr Vityazev
2023-12-22 16:02 ` Stefan Kangas
2023-12-22 20:36 ` Aleksandr Vityazev
2024-02-20 3:04 ` Björn Bidar
-- strict thread matches above, loose matches on Subject: below --
2024-01-16 0:38 Aleksandr Vityazev
2024-01-16 6:18 ` Philip Kaludercic
2024-01-16 6:42 ` Aleksandr Vityazev
2024-01-16 7:30 ` Philip Kaludercic
2024-01-16 8:08 ` Aleksandr Vityazev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkaiadt8.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=avityazew@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).