From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pranshu Sharma Newsgroups: gmane.emacs.devel Subject: Re: New package: haskell-ts-mode Date: Thu, 29 Aug 2024 17:24:14 +1000 Message-ID: References: <874j74u15e.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000004f330a0620cd5dda" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39198"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Aug 29 09:57:31 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 1sja26-000A16-SI for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Aug 2024 09:57:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sja1S-00056e-Pe; Thu, 29 Aug 2024 03:56:50 -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 1sjZWC-0006Xx-S9 for emacs-devel@gnu.org; Thu, 29 Aug 2024 03:24:32 -0400 Original-Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjZW8-0008Bl-8E for emacs-devel@gnu.org; Thu, 29 Aug 2024 03:24:32 -0400 Original-Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2d3dc25b1b5so210965a91.2 for ; Thu, 29 Aug 2024 00:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724916266; x=1725521066; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=o/6DHQ4oD9vQqtygfAIFG6EUERGNrRxRxP8GLstCj6E=; b=dP5CRz7M0HxHOtM5ryAY3o6OOyrcs9rjZOlcERqIfAHwblLzOO2g2v2HIHQgaYwjPk P8SIfoSCJg2NREF7lxdMuMWlZtkL4Z8hCkLZMQKGFKnjaOub0Fd9T8R9ukvNwDgOP2aB UBxvKER08VWHzXd5SQtdonul5Gstm1BO4L/QzKUuG/fnsdLsBrXCRYXf42gDtARI2v7n fUHYix22NHN5OXWC/XSi+V37CVBrITSFnZramvg1GrWtce5F1REhwz6ADC1/iLWnnHhC a3a9V2yytWD5OLljJh0qMy/UUJr8xye6n19bgKokFnD5bRZh+XoHyxshiyM7nkUV4U1H WGaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724916266; x=1725521066; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=o/6DHQ4oD9vQqtygfAIFG6EUERGNrRxRxP8GLstCj6E=; b=hPYkoICTQzFHKjsVSPb+tMu0EO0oP9BneM1jIiINL7V7hu+TgOGJSKFSkCe14BOJ5M nLsQl7OdlcmbkojewVBiu6gn64M5GAniZv8U3E97aif1SaBlRXMXXPeMl7DKebfYz8os 0Q3jSKs7OUjcJtvOXbcrv392MCpT28hd9cQf2kZnDW/INB9/a9qqMyqHbWAk53qz9h/H 0ru77QkmtmhIpD6Z+PHw+JsLL5MjkqqRl/aU+ByT8NxDqIWKs3M58XTgJwBfz5VN7x6J ZIXf3H5dBrPhst0zrAjqMbuqY6SXIWDR0q/ZUylRzjDNRxBbYuZEcpQB1m+MNtBQUpYl 35tQ== X-Gm-Message-State: AOJu0YyvPWxOia0lciNnXpQ90eMl3U3NjCZ3Q0fs3AFi7TnoWZ9Z6vLF snYuARpHN+8FZtL9IShmp1CQOrrRVK0gAPH2vdbXXIg7L+E0IDOdQb/HJKwaPcUpjIifJEpE8Bq 7EX5r94wjW18n3HXT09jPOXXT51i5Qw== X-Google-Smtp-Source: AGHT+IH/hAOFK24Ok8EospGygIzR/hFo4hz9KxkfO9hh8vgXsH9po/etzSXeCkIyAzhFyGz8v7wKaVkC4/hDwmAcLCE= X-Received: by 2002:a17:90b:1b06:b0:2c8:5cb7:54e5 with SMTP id 98e67ed59e1d1-2d8564c1edbmr1875514a91.32.1724916266116; Thu, 29 Aug 2024 00:24:26 -0700 (PDT) In-Reply-To: <874j74u15e.fsf@posteo.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=sirsharmapranshu@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 29 Aug 2024 03:56:48 -0400 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:323173 Archived-At: --0000000000004f330a0620cd5dda Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Phlip, Thanks for the edits, I applied all of it apart from when when you want defun changed to macro, that does not work, as closures are not properly supported by treesit. With the spacing, I did what you suggested then used emacs to indent the whole page, and added elpaignore file Also no, I did not use Ai, what made you think so? On Thu, Aug 29, 2024 at 1:18=E2=80=AFAM Philip Kaludercic wrote: > Pranshu Sharma writes: > > > Hello all > > > > haskell-ts-mode is a major mode for haskell that uses treesitter to > provide > > features such as indentation and colouring. The mode can be found at > > pranshu/haskell-ts-mode: > > A haskelll mode that uses treesitter - Codeberg.org > > . > > First of all, the spacing and indentation is inconsistent. Please > address that, and perhaps add a directory local option to enforce > indentation with spaces to ensure a consistent look. > > I cannot comment on the tree-sitter stuff since I don't really > understand it, but otherwise I have a few comments that I would like you > to consider: > > diff --git a/haskell-ts-mode.el b/haskell-ts-mode.el > index 4ba7f42..391db66 100644 > --- a/haskell-ts-mode.el > +++ b/haskell-ts-mode.el > @@ -2,7 +2,6 @@ > > ;; Copyright (C) 2024 Pranshu Sharma > > - > ;; Author: Pranshu Sharma > ;; URL: https://codeberg.org/pranshu/haskell-ts-mode > ;; Package-Requires: ((emacs "29.3")) > @@ -23,6 +22,7 @@ > ;; along with this program. If not, see = . > > ;;; Commentary: > + > ;; This is a WIP mode that uses treesitter to provide all the basic > ;; major mode stuff, like indentation, font lock, etc... > > @@ -31,6 +31,7 @@ > (require 'comint) > (require 'treesit) > > +;; From what I understand this is necessary for tree-sitter modes, but > can you at least also add the ARGLIST argument. Also, some functions suc= h > as `treesit-induce-sparse-tree' appear not to be used? > (declare-function treesit-parser-create "treesit.c") > (declare-function treesit-induce-sparse-tree "treesit.c") > (declare-function treesit-node-child "treesit.c") > @@ -46,10 +47,11 @@ > (otherwise signature))) > > (defvar haskell-ts-use-indent t > - "Set to nil if you don't want to use Emacs indent.") > + "Set to nil if you don't want to use Emacs indent.") ;rephrase this > would the double negation > > (defvar haskell-ts-font-lock-level 4 > "Level of font lock, 1 for minimum highlghting and 4 for maximum.") > +;; both of these variables are actually user options and should be > declared using `'defcustom'! > > (defvar haskell-ts-prettify-symbols-alits > '(("\\" . "=CE=BB") > @@ -60,6 +62,7 @@ > ("<=3D" . "=E2=89=A5") > (">=3D" . "=E2=89=A4"))) > > +;; Checkdoc complains that > (defun haskell-ts-font-lock () > (treesit-font-lock-rules > :language 'haskell > @@ -157,7 +160,7 @@ > ((parent-is "apply") parent -1) > ((node-is "quasiquote") grand-parent 2) > ((parent-is "quasiquote_body") (lambda (_ _ c) c) 0) > - ;; Do Hg > + ;; Do Hg ;; what does "Hg" mean? > ((lambda (node parent bol) > (let ((n (treesit-node-prev-sibling node))) > (while (string=3D "comment" (treesit-node-type n)) > @@ -232,6 +235,7 @@ > > ;; Copied from haskell-tng-mode, changed a bit > (defvar haskell-ts-mode-syntax-table > + ;; Should this be wrapped in an `eval-when-compile'? > (let ((table (make-syntax-table))) > (map-char-table > (lambda (k v) > @@ -241,7 +245,7 @@ > (modify-syntax-entry k "_" table)))) > (char-table-parent table)) > ;; whitechar > - (seq-do > + (seq-do ;seq-do has a relatively high > overhead, try to avoid it > (lambda (it) (modify-syntax-entry it " " table)) > (string-to-list "\r\n\f\v \t")) > ;; ascSymbol > @@ -268,46 +272,40 @@ > (modify-syntax-entry ?\{ "(}1nb" table) > (modify-syntax-entry ?\} "){4nb" table) > (modify-syntax-entry ?- "_ 123" table) ;; TODO --> is not a > comment > - (seq-do > - (lambda (it) (modify-syntax-entry it ">" table)) > - (string-to-list "\r\n\f\v")) > + (dolist (c (string-to-list "\r\n\f\v")) ;though unrolling wouldn'= t > be bad either > + (modify-syntax-entry c ">" table)) > + > table)) > > +(defun haskell-ts-imenu-name-function (check-func) > + (lambda (node) > + (if (funcall check-func node) > + (haskell-ts-defun-name node) > + nil))) > > -(defmacro haskell-ts-imenu-name-function (check-func) > - `(lambda (node) > - (if (funcall ,check-func node) > - (haskell-ts-defun-name node) > - nil))) > - > -(defun haskell-ts-indent-para() > +(defun haskell-ts-indent-para () > "Indent the current paragraph." > (interactive) > - (save-excursion > - (backward-paragraph) > - (let ((p (point))) > - (forward-paragraph) > - (indent-region p (point))))) > + (when-let ((par (bounds-of-thing-at-point 'paragraph))) > + (indent-region (car par) (cdr par)))) > > (defvar haskell-ts-mode-map > (let ((km (make-sparse-keymap))) > (define-key km (kbd "C-c C-c") 'haskell-ts-compile-region-and-go) > (define-key km (kbd "C-c C-r") 'haskell-ts-run-haskell) > - (define-key km (kbd "C-M-q") 'haskell-ts-indent-para) > + (define-key km (kbd "C-M-q") 'haskell-ts-indent-para) ;is this > necessary when `prog-fill-reindent-defun' is bound to M-q? > km) > - "Map for haskell-ts-mode") > + "Map for haskell-ts-mode.") > > ;;;###autoload > (define-derived-mode haskell-ts-mode prog-mode "haskell ts mode" > "Major mode for Haskell files using tree-sitter." > - :syntax-table haskell-ts-mode-syntax-table > - :interactive t > (unless (treesit-ready-p 'haskell) > (error "Tree-sitter for Haskell is not available")) > (treesit-parser-create 'haskell) > (setq-local treesit-defun-type-regexp > "\\(?:\\(?:function\\|struct\\)_definition\\)") > ;; Indent > - (and haskell-ts-use-indent > + (and haskell-ts-use-indent ;do you mean `when'? > (setq-local treesit-simple-indent-rules haskell-ts-indent-rules) > (setq-local indent-tabs-mode nil)) > ;; Comment > @@ -316,21 +314,21 @@ > (setq-local comment-start-skip "\\(?: \\|^\\)-+") > ;; Elecric > (setq-local electric-pair-pairs > - (list (cons ?` ?`) (cons ?\( ?\)) (cons ?{ ?}) (cons ?\" > ?\") (cons ?\[ ?\]))) > + '((?` . ?`) (?\( . ?\)) (?{ . ?}) (?\" . ?\") (?\[ . ?\]))) > ;; Nav > - (setq-local treesit-defun-name-function 'haskell-ts-defun-name) > + (setq-local treesit-defun-name-function #'haskell-ts-defun-name) > (setq-local treesit-defun-type-regexp "function") > (setq-local prettify-symbols-alist haskell-ts-prettify-symbols-alits) > ;; Imenu > (setq-local treesit-simple-imenu-settings > `((nil haskell-ts-imenu-func-node-p nil > - ,(haskell-ts-imenu-name-function > 'haskell-ts-imenu-func-node-p)) > + ,(haskell-ts-imenu-name-function > #'haskell-ts-imenu-func-node-p)) > ("Signatures.." haskell-ts-imenu-sig-node-p nil > - ,(haskell-ts-imenu-name-function > 'haskell-ts-imenu-sig-node-p)) > + ,(haskell-ts-imenu-name-function > #'haskell-ts-imenu-sig-node-p)) > ("Data..." haskell-ts-imenu-data-type-p nil > (lambda (node) > (treesit-node-text (treesit-node-child node 1)))))) > - ;; font-lock. > + ;; font-lock > (setq-local treesit-font-lock-level haskell-ts-font-lock-level) > (setq-local treesit-font-lock-settings (haskell-ts-font-lock)) > (setq-local treesit-font-lock-feature-list > @@ -379,23 +377,32 @@ > > (defun haskell-ts-run-haskell() > (interactive) > - (when (not (comint-check-proc "*haskell*")) > - (set-buffer (apply (function make-comint) > - "haskell" "ghci" nil `(,buffer-file-name)))) > - (pop-to-buffer-same-window "*haskell*")) > + (pop-to-buffer-same-window ;really in the same window? > + (or > + (comint-check-proc "*haskell*") > + (make-comint "*haskell* repl" "ghci" nil buffer-file-name)))) > + > > (defun haskell-ts-haskell-session () > (get-buffer-process "*haskell*")) > > +(defvar eglot-server-programs) ;to avoid the byte-compiler error > (defun haskell-ts-setup-eglot() > (when (featurep 'eglot) > - (add-to-list 'eglot-server-programs > + ;; Eglot was added to the core along with tree-siter, so there is > + ;; no case where tree-sitter is available, but eglot is not. > + (add-to-list 'eglot-server-programs > '(haskell-ts-mode . ("haskell-language-server-wrapper" > "--lsp"))))) > > +;; Note that you write (eval-when-load 'eglot > +;; (haskell-ts-setup-eglot)) in README.org, but that doesn't do what > +;; you want it to. That will modify eglot-server-programs and > +;; evaluate the result when eglot is loaded. You presumably wanted to > +;; use `with-eval-after-load'? > + > (when (treesit-ready-p 'haskell) > (add-to-list 'auto-mode-alist '("\\.hs\\'" . haskell-ts-mode))) > > (provide 'haskell-ts-mode) > > ;;; haskell-ts-mode.el ends here > - > > (Also, a general question, do you use LLMs to generate some of the code?) > > > > > The attached patch is for the elpa repo > > Thanks, > > Pranshu > > diff --git a/elpa-packages b/elpa-packages > > index 137fef0348..451a67d395 100644 > > --- a/elpa-packages > > +++ b/elpa-packages > > @@ -368,6 +368,9 @@ > > (gtags-mode :url "https://github.com/Ergus/gtags-mode") > > (guess-language :url " > https://github.com/tmalsburg/guess-language.el" > > :merge t) > > + (haskell-ts-mode :url " > https://codeberg.org/pranshu/haskell-ts-mode" > > + :doc "README.org" > > Are you sure that you want the README to be installed as a manual? > > > + :ignored-files ("*.png" "LICENSE")) > > You can list the files you wish to ignore in an .elpaignore file in your > repository; its preferable to using :ignored-files as it is more > flexible and easier to adjust if something changes on your end. > > > (hcel :url "https://g.ypei.me/hc.el.git") > > (heap :url nil) ;" > http://www.dr-qubit.org/git/predictive.git" > > (hiddenquote :url " > https://gitlab.com/mauroaranda/hiddenquote/hiddenquote") > > > > -- > Philip Kaludercic on peregrine > --0000000000004f330a0620cd5dda Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hello Phlip,
Thanks for the edits, I applied all of it apart from when when = you want defun changed to macro, that does not work, as closures are not pr= operly supported by treesit.

With the spacing, I d= id what you suggested then used emacs to indent the whole page, and added e= lpaignore file

Also no, I did not use Ai, what mad= e you think so?


On Thu, Aug 29, 2024 at 1:18=E2=80=AFAM Phili= p Kaludercic <philipk@posteo.net> wrote:
Pr= anshu Sharma <sirsharmapranshu@gmail.com> writes:

> Hello all
>
> haskell-ts-mode is a major mode for haskell that uses treesitter to pr= ovide
> features such as indentation and colouring. The mode can be found at > pranshu/haskell-ts-mode:
> A haskelll mode that uses treesitter - Codeberg.org
> <https://codeberg.org/pranshu/haskell-ts-mode>.

First of all, the spacing and indentation is inconsistent.=C2=A0 Please
address that, and perhaps add a directory local option to enforce
indentation with spaces to ensure a consistent look.

I cannot comment on the tree-sitter stuff since I don't really
understand it, but otherwise I have a few comments that I would like you to consider:

diff --git a/haskell-ts-mode.el b/haskell-ts-mode.el
index 4ba7f42..391db66 100644
--- a/haskell-ts-mode.el
+++ b/haskell-ts-mode.el
@@ -2,7 +2,6 @@

=C2=A0;; Copyright (C) 2024=C2=A0 Pranshu Sharma

-
=C2=A0;; Author: Pranshu Sharma <pranshusharma366 at gmail>
=C2=A0;; URL:
https://codeberg.org/pranshu/haskell-ts-m= ode
=C2=A0;; Package-Requires: ((emacs "29.3"))
@@ -23,6 +22,7 @@
=C2=A0;; along with this program.=C2=A0 If not, see <https://www.gnu= .org/licenses/>.

=C2=A0;;; Commentary:
+
=C2=A0;; This is a WIP mode that uses treesitter to provide all the basic =C2=A0;; major mode stuff, like indentation, font lock, etc...

@@ -31,6 +31,7 @@
=C2=A0(require 'comint)
=C2=A0(require 'treesit)

+;; From what I understand this is necessary for tree-sitter modes, but can= you at least also add the ARGLIST argument.=C2=A0 Also, some functions suc= h as `treesit-induce-sparse-tree' appear not to be used?
=C2=A0(declare-function treesit-parser-create "treesit.c")
=C2=A0(declare-function treesit-induce-sparse-tree "treesit.c") =C2=A0(declare-function treesit-node-child "treesit.c")
@@ -46,10 +47,11 @@
=C2=A0 =C2=A0 =C2=A0(otherwise signature)))

=C2=A0(defvar haskell-ts-use-indent t
-=C2=A0 "Set to nil if you don't want to use Emacs indent.")<= br> +=C2=A0 "Set to nil if you don't want to use Emacs indent.") = ;rephrase this would the double negation

=C2=A0(defvar haskell-ts-font-lock-level 4
=C2=A0 =C2=A0"Level of font lock, 1 for minimum highlghting and 4 for = maximum.")
+;; both of these variables are actually user options and should be declare= d using `'defcustom'!

=C2=A0(defvar haskell-ts-prettify-symbols-alits
=C2=A0 =C2=A0 =C2=A0 =C2=A0'(("\\" . "=CE=BB")
@@ -60,6 +62,7 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ("<=3D" . "=E2=89=A5") =C2=A0 =C2=A0 =C2=A0 =C2=A0 (">=3D" . "=E2=89=A4")))=

+;; Checkdoc complains that
=C2=A0(defun haskell-ts-font-lock ()
=C2=A0 =C2=A0 =C2=A0(treesit-font-lock-rules
=C2=A0 =C2=A0 =C2=A0 =C2=A0 :language 'haskell
@@ -157,7 +160,7 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((parent-is "apply") par= ent -1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((node-is "quasiquote") = grand-parent 2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((parent-is "quasiquote_body&= quot;) (lambda (_ _ c) c) 0)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Do Hg
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Do Hg=C2=A0 ;; what does "Hg&qu= ot; mean?
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((lambda (node parent bol)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((n (treesit-node-pre= v-sibling node)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (string=3D &= quot;comment" (treesit-node-type n))
@@ -232,6 +235,7 @@

=C2=A0;; Copied from haskell-tng-mode, changed a bit
=C2=A0(defvar haskell-ts-mode-syntax-table
+=C2=A0 ;; Should this be wrapped in an `eval-when-compile'?
=C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((table (make-syntax-table)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (map-char-table
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (k v)
@@ -241,7 +245,7 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-syntax-entr= y k "_" table))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(char-table-parent table))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; whitechar
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(seq-do
+=C2=A0 =C2=A0 =C2=A0 =C2=A0(seq-do=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;seq-do has a relativel= y high overhead, try to avoid it
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (it) (modify-syntax-entry it &quo= t; " table))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(string-to-list "\r\n\f\v \t"))=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; ascSymbol
@@ -268,46 +272,40 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-syntax-entry ?\{=C2=A0 "(}1nb"= ; table)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-syntax-entry ?\}=C2=A0 "){4nb"= ; table)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (modify-syntax-entry ?-=C2=A0 "_ 123"= table) ;; TODO --> is not a comment
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(seq-do
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda (it) (modify-syntax-entry it ">= ;" table))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (string-to-list "\r\n\f\v"))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0(dolist (c (string-to-list "\r\n\f\v"= )) ;though unrolling wouldn't be bad either
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(modify-syntax-entry c ">" = table))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 table))

+(defun haskell-ts-imenu-name-function (check-func)
+=C2=A0 (lambda (node)
+=C2=A0 =C2=A0 (if (funcall check-func node)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0(haskell-ts-defun-name node)
+=C2=A0 =C2=A0 =C2=A0 nil)))

-(defmacro haskell-ts-imenu-name-function (check-func)
-=C2=A0 `(lambda (node)
-=C2=A0 =C2=A0 =C2=A0 (if (funcall ,check-func node)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(haskell-ts-defun-name node)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0nil)))
-
-(defun haskell-ts-indent-para()
+(defun haskell-ts-indent-para ()
=C2=A0 =C2=A0"Indent the current paragraph."
=C2=A0 =C2=A0(interactive)
-=C2=A0 (save-excursion
-=C2=A0 =C2=A0 (backward-paragraph)
-=C2=A0 =C2=A0 (let ((p (point)))
-=C2=A0 =C2=A0 =C2=A0 (forward-paragraph)
-=C2=A0 =C2=A0 =C2=A0 (indent-region p (point)))))
+=C2=A0 (when-let ((par (bounds-of-thing-at-point 'paragraph)))
+=C2=A0 =C2=A0 (indent-region (car par) (cdr par))))

=C2=A0(defvar haskell-ts-mode-map
=C2=A0 =C2=A0(let ((km (make-sparse-keymap)))
=C2=A0 =C2=A0 =C2=A0(define-key km (kbd "C-c C-c") 'haskell-t= s-compile-region-and-go)
=C2=A0 =C2=A0 =C2=A0(define-key km (kbd "C-c C-r") 'haskell-t= s-run-haskell)
-=C2=A0 =C2=A0 (define-key km (kbd "C-M-q") 'haskell-ts-inden= t-para)
+=C2=A0 =C2=A0 (define-key km (kbd "C-M-q") 'haskell-ts-inden= t-para) ;is this necessary when `prog-fill-reindent-defun' is bound to = M-q?
=C2=A0 =C2=A0 =C2=A0km)
-=C2=A0 "Map for haskell-ts-mode")
+=C2=A0 "Map for haskell-ts-mode.")

=C2=A0;;;###autoload
=C2=A0(define-derived-mode haskell-ts-mode prog-mode "haskell ts mode&= quot;
=C2=A0 =C2=A0"Major mode for Haskell files using tree-sitter." -=C2=A0 :syntax-table haskell-ts-mode-syntax-table
-=C2=A0 :interactive t
=C2=A0 =C2=A0(unless (treesit-ready-p 'haskell)
=C2=A0 =C2=A0 =C2=A0(error "Tree-sitter for Haskell is not available&q= uot;))
=C2=A0 =C2=A0(treesit-parser-create 'haskell)
=C2=A0 =C2=A0(setq-local treesit-defun-type-regexp "\\(?:\\(?:function= \\|struct\\)_definition\\)")
=C2=A0 =C2=A0;; Indent
-=C2=A0 (and haskell-ts-use-indent
+=C2=A0 (and haskell-ts-use-indent=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= ;do you mean `when'?
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq-local treesit-simple-indent-rules haskell= -ts-indent-rules)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq-local indent-tabs-mode nil))
=C2=A0 =C2=A0;; Comment
@@ -316,21 +314,21 @@
=C2=A0 =C2=A0(setq-local comment-start-skip "\\(?: \\|^\\)-+") =C2=A0 =C2=A0;; Elecric
=C2=A0 =C2=A0(setq-local electric-pair-pairs
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list (cons ?` ?`) (cons ?= \( ?\)) (cons ?{ ?}) (cons ?\" ?\") (cons ?\[ ?\])))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((?` . ?`) (?\( . ?\)= ) (?{ . ?}) (?\" . ?\") (?\[ . ?\])))
=C2=A0 =C2=A0;; Nav
-=C2=A0 (setq-local treesit-defun-name-function 'haskell-ts-defun-name)=
+=C2=A0 (setq-local treesit-defun-name-function #'haskell-ts-defun-name= )
=C2=A0 =C2=A0(setq-local treesit-defun-type-regexp "function") =C2=A0 =C2=A0(setq-local prettify-symbols-alist haskell-ts-prettify-symbols= -alits)
=C2=A0 =C2=A0;; Imenu
=C2=A0 =C2=A0(setq-local treesit-simple-imenu-settings
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 `((nil haskell-ts-imenu-fu= nc-node-p nil
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ,(ha= skell-ts-imenu-name-function 'haskell-ts-imenu-func-node-p))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ,(ha= skell-ts-imenu-name-function #'haskell-ts-imenu-func-node-p))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("Signatures..= " haskell-ts-imenu-sig-node-p nil
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ,(haskell-ts-imenu= -name-function 'haskell-ts-imenu-sig-node-p))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ,(haskell-ts-imenu= -name-function #'haskell-ts-imenu-sig-node-p))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("Data..."= ; haskell-ts-imenu-data-type-p nil
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (node= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(trees= it-node-text (treesit-node-child node 1))))))
-=C2=A0 ;; font-lock.
+=C2=A0 ;; font-lock
=C2=A0 =C2=A0(setq-local treesit-font-lock-level haskell-ts-font-lock-level= )
=C2=A0 =C2=A0(setq-local treesit-font-lock-settings (haskell-ts-font-lock))=
=C2=A0 =C2=A0(setq-local treesit-font-lock-feature-list
@@ -379,23 +377,32 @@

=C2=A0(defun haskell-ts-run-haskell()
=C2=A0 =C2=A0(interactive)
-=C2=A0 (when (not (comint-check-proc "*haskell*"))
-=C2=A0 =C2=A0 (set-buffer (apply (function make-comint)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 "haskell" "ghci" nil `(,buffer-file-name))))
-=C2=A0 (pop-to-buffer-same-window "*haskell*"))
+=C2=A0 (pop-to-buffer-same-window=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= ;really in the same window?
+=C2=A0 =C2=A0(or
+=C2=A0 =C2=A0 (comint-check-proc "*haskell*")
+=C2=A0 =C2=A0 (make-comint "*haskell* repl" "ghci" nil= buffer-file-name))))
+

=C2=A0(defun haskell-ts-haskell-session ()
=C2=A0 =C2=A0(get-buffer-process "*haskell*"))

+(defvar eglot-server-programs)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;to avoid = the byte-compiler error
=C2=A0(defun haskell-ts-setup-eglot()
=C2=A0 =C2=A0(when (featurep 'eglot)
-=C2=A0 =C2=A0(add-to-list 'eglot-server-programs
+=C2=A0 =C2=A0 ;; Eglot was added to the core along with tree-siter, so the= re is
+=C2=A0 =C2=A0 ;; no case where tree-sitter is available, but eglot is not.=
+=C2=A0 =C2=A0 (add-to-list 'eglot-server-programs
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'(haskell-ts-mod= e . ("haskell-language-server-wrapper" "--lsp")))))

+;; Note that you write (eval-when-load 'eglot
+;; (haskell-ts-setup-eglot)) in README.org, but that doesn't do what +;; you want it to.=C2=A0 That will modify eglot-server-programs and
+;; evaluate the result when eglot is loaded.=C2=A0 You presumably wanted t= o
+;; use `with-eval-after-load'?
+
=C2=A0(when (treesit-ready-p 'haskell)
=C2=A0 =C2=A0(add-to-list 'auto-mode-alist '("\\.hs\\'&quo= t; . haskell-ts-mode)))

=C2=A0(provide 'haskell-ts-mode)

=C2=A0;;; haskell-ts-mode.el ends here
-

(Also, a general question, do you use LLMs to generate some of the code?)
>
> The attached patch is for the elpa repo
> Thanks,
> Pranshu
> diff --git a/elpa-packages b/elpa-packages
> index 137fef0348..451a67d395 100644
> --- a/elpa-packages
> +++ b/elpa-packages
> @@ -368,6 +368,9 @@
>=C2=A0 =C2=A0(gtags-mode=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:url "https://github.com/Ergus/gtags-mode")
>=C2=A0 =C2=A0(guess-language=C2=A0 =C2=A0 =C2=A0:url "https://github.com/tmalsburg/guess-language.el"
>=C2=A0 =C2=A0 :merge t)
> + (haskell-ts-mode=C2=A0 =C2=A0 =C2=A0 =C2=A0:url "https://codeberg.org/pranshu/haskell-ts-mode"
> +=C2=A0 :doc "README.org"

Are you sure that you want the README to be installed as a manual?

> +=C2=A0 :ignored-files ("*.png" "LICENSE"))

You can list the files you wish to ignore in an .elpaignore file in your repository; its preferable to using :ignored-files as it is more
flexible and easier to adjust if something changes on your end.

>=C2=A0 =C2=A0(hcel=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:url "https://g.ypei.me/hc.el.git= ")
>=C2=A0 =C2=A0(heap=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:url nil) ;"http://www= .dr-qubit.org/git/predictive.git"
>=C2=A0 =C2=A0(hiddenquote=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 :url "https://gitlab.com/mauro= aranda/hiddenquote/hiddenquote")
>

--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Philip Kaludercic on peregrine
--0000000000004f330a0620cd5dda--