unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel@gnu.org, casouri@gmail.com
Subject: Re: Code quality of some -ts-mode major modes
Date: Fri, 17 Mar 2023 13:46:24 +0200	[thread overview]
Message-ID: <83lejveh2n.fsf@gnu.org> (raw)
In-Reply-To: <87fsa3g05n.fsf@posteo.net> (message from Philip Kaludercic on Fri, 17 Mar 2023 10:08:52 +0000)

> From: Philip Kaludercic <philipk@posteo.net>
> Cc: Yuan Fu <casouri@gmail.com>
> Date: Fri, 17 Mar 2023 10:08:52 +0000
> 
> Hi, I took a look at some of the new tree-sitter major modes and was
> surprised at what I saw.  Without meaning to belittle anyone, there were
> some basic "stylistic mistakes" that I wouldn't have expected to have
> gotten merged.  I didn't look up the exact chronology, but it seems like
> there has been a lot of uncritical copying between these files.

These remarks are not helpful and should have been omitted from the
message, IMNSHO.

> @@ -23,15 +23,18 @@
>  ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
>  
>  ;;; Commentary:
> -;;
> +
> +;; This file provides basic YAML syntax highlighting using Tree
> +;; Sitter.  To use the `yaml-ts-mode' major mode you will have to make
> +;; sure that you have installed the appropriate grammar.

Adding helpful comments is always welcome, and shouldn't be
controversial.  There's also no end to adding such helpful comments,
so just feel free to add them when you think they could help.

>  ;;; Code:
>  
>  (require 'treesit)
>  
> -(declare-function treesit-parser-create "treesit.c")
> +;; (declare-function treesit-parser-create "treesit.c") ;doesn't appear necessary

If the function is not used, removing the declare-function is OK.

> @@ -120,10 +125,9 @@ yaml-ts-mode--font-lock-settings
>  ;;;###autoload
>  (define-derived-mode yaml-ts-mode text-mode "YAML"
>    "Major mode for editing YAML, powered by tree-sitter."
> -  :group 'yaml
> -  :syntax-table yaml-ts-mode--syntax-table
> +  ;; :group 'yaml ;; no such customisation group was defined?

Should we add such a group?

> -  (when (treesit-ready-p 'yaml)
> +  (when (treesit-ready-p 'yaml)         ;why not raise an `user-error'?
>      (treesit-parser-create 'yaml)

This is intentional, and I explained it many times.

> In particular: The lack of a commentary section or any
> indication/pointer on how to install the grammar which is the necessary
> prequisite for the mode to have any effect to begin with (my
> understanding is that Emacs will not ship with these files, nor are any
> distributions working on providing them, right?).

There's a description in NEWS.  But mentioning the specific grammar
with which the mode was tested is useful anyway.

> My question: Would there be any objection from those involves with
> tree-sitter against me making changes like the ones I gave above?

Please post the patches for review, but in general they are, of
course, welcome.  These modes are very "young", so it doesn't surprise
me there are some stylistic issues with them.  That said, not
everything you see is such an issue, especially if you weren't
involved in the relevant discussions.

> Maintaining some basic style in the core seems desirable to me, as we
> have seen that these files often serve as a template for creating new
> major modes.

You are preaching to the choir here.



      parent reply	other threads:[~2023-03-17 11:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 10:08 Code quality of some -ts-mode major modes Philip Kaludercic
2023-03-17 10:29 ` Ruijie Yu via Emacs development discussions.
2023-03-17 11:52   ` Eli Zaretskii
2023-03-17 12:37   ` Philip Kaludercic
2023-03-17 13:54     ` Eli Zaretskii
2023-03-17 15:20       ` Philip Kaludercic
2023-03-17 15:31         ` Eli Zaretskii
2023-03-17 15:49           ` Philip Kaludercic
2023-03-17 16:35             ` Eli Zaretskii
2023-03-17 16:53               ` Philip Kaludercic
2023-03-17 21:45       ` Dmitry Gutov
2023-03-18  5:59         ` Eli Zaretskii
2023-03-17 11:46 ` Eli Zaretskii [this message]

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=83lejveh2n.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=philipk@posteo.net \
    /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).