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 19:29:17 +1000 Message-ID: References: <874j74u15e.fsf@posteo.net> <87a5gvsnnn.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000085704a0620cf1c1a" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35544"; 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 12:51:47 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 1sjckl-00097W-Kc for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Aug 2024 12:51:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjcjy-0007Gh-LG; Thu, 29 Aug 2024 06:50:58 -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 1sjbTD-0007Vz-I0 for emacs-devel@gnu.org; Thu, 29 Aug 2024 05:29:35 -0400 Original-Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjbT8-0005AQ-Ul for emacs-devel@gnu.org; Thu, 29 Aug 2024 05:29:35 -0400 Original-Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2d439583573so307026a91.3 for ; Thu, 29 Aug 2024 02:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724923769; x=1725528569; 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=1OnfqVOQUChAnjiyW9mdBqUs5lcZB6279bCbgl4wRyI=; b=ZYU6+PD5anpg1iVV+Zmnz4Tig5uts+c6dr9uPtRTOknyIjn5wZFpgXEiA4GfVT4jmb zIO/iO1lNqvyctpvoFjCkuE3VZaF16vkFCp+QerIhK0KDzHvV8AJW6GjW9d9yuplNpXX d0IwVf7JEwm89OhoxMV0OoXoSb6oE+MJcYej0DxOf6RPm0RgbTZkdAimobMuvIiisCqQ K3cZLCB7ASESd9s5zMBzXJE8ZUimpBQ8x08Ed0KrXp2Fov/jC9K/BN4c1ME583cr3a0e ReaEJCtpAEU5mhZ89Ks4mg3C6QwOiGMFaHDbcIC9Wnx1SsNoRs2J6J9yhKrGTiYjXi++ YYgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724923769; x=1725528569; 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=1OnfqVOQUChAnjiyW9mdBqUs5lcZB6279bCbgl4wRyI=; b=X7860BUtEzA3zksHfYqpekDJTeXVm8H8YLdTYFUDmB9JQpGsvz47l5uT5XmutBjw8p U7bLBrs2PY579E28NLBmJ40DZqtBjvPpsgmZmfxBifvhFRY14fxoeksone+48DIjnan0 PKgj2Yxr8LDdy4j+EvzSW8NO7U85QJAQ0T/CWIPZEuCLQruUND6Dj8X4k2iaNcF2/voC Qz1HTc0q4HA5jmoC/4uE791saGRBs1C4EzZA1Mh9niFe4nnDcCUIATpEdYIZGFOUdTbs z80GLbHLvLZ5z4s6Dzg3/fDBgXARvINJU4aQRc3oS60dGG/LzE596utIcax2h8KK0bVB RDSw== X-Gm-Message-State: AOJu0YzkLAqDhBthj+Tzd/C+Tms7956veiTdP45pITwxTCF49yPyFW1J Jnr4nATNP0GqA/euoTV9c7ENKh3AEj7GA9Unv3X8aTzRox43vNkLBg0QDH2yAhdSK8SNynk5ofu pPzthX/8lrrGiSccy15lJj8HS9BM= X-Google-Smtp-Source: AGHT+IFEh/Xsp4DkzifMtB62oev0z6OgmfytaLXZ+CT+dO4J2bKPjYwmOq2SgNzypZefX/4HgMUtAZpdW7XEAn8BSzA= X-Received: by 2002:a17:90a:cf95:b0:2d3:d066:f58b with SMTP id 98e67ed59e1d1-2d8561a13bfmr1959802a91.12.1724923769088; Thu, 29 Aug 2024 02:29:29 -0700 (PDT) In-Reply-To: <87a5gvsnnn.fsf@posteo.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=sirsharmapranshu@gmail.com; helo=mail-pj1-x1036.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 06:50:56 -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:323177 Archived-At: --00000000000085704a0620cf1c1a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Oh yeah, I just realised that and fixed the electric pair mode error. The seq-do part I did not code myself, I copied it from haskell-tng-mode, as stated in the comment. Homework? students? do you teach your students elisp? On Thu, Aug 29, 2024 at 7:07=E2=80=AFPM Philip Kaludercic wrote: > Pranshu Sharma writes: > > > 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 properl= y > > supported by treesit. > > OK, sorry about the last suggestion then, as I said, I am not familiar > with treesitter. > > > With the spacing, I did what you suggested then used emacs to indent th= e > > whole page, and added elpaignore file > > 1+ > > Note that `electric-pair-pairs' is now malconstructed. It is a list of > lists, where each list begins with the symbol `cons'. Not a list of > cons-cells holding two characters. > > > Also no, I did not use Ai, what made you think so? > > There were a some unusual constructs repeated a number of times that I > have never seen before (the way you used seq-do was the main example). > It reminded me of homework submissions I have seen students submit that > /were/ AI generated. > > > > > 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 y= ou > >> 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 < > https://www.gnu.org/licenses/>. > >> > >> ;;; 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, bu= t > >> can you at least also add the ARGLIST argument. Also, some functions > such > >> 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-rule= s) > >> (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-alit= s) > >> ;; 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 t= o > >> +;; 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 yo= ur > >> 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 > >> > > -- > Philip Kaludercic on peregrine > --00000000000085704a0620cf1c1a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Oh yeah, I just realised that and fixed=C2=A0the electric = pair mode error.

The seq-do part I did not code myself, = I copied it from haskell-tng-mode, as stated in the comment.=C2=A0
Homework? students? do you teach your students elisp?

On Thu, Aug 29= , 2024 at 7:07=E2=80=AFPM Philip Kaludercic <philipk@posteo.net> wrote:
Pranshu Sharma <sirsharmapranshu@gmail.com> wri= tes:

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

OK, sorry about the last suggestion then, as I said, I am not familiar
with treesitter.

> With the spacing, I did what you suggested then used emacs to indent t= he
> whole page, and added elpaignore file

1+

Note that `electric-pair-pairs' is now malconstructed.=C2=A0 It is a li= st of
lists, where each list begins with the symbol `cons'.=C2=A0 Not a list = of
cons-cells holding two characters.

> Also no, I did not use Ai, what made you think so?

There were a some unusual constructs repeated a number of times that I
have never seen before (the way you used seq-do was the main example).
It reminded me of homework submissions I have seen students submit that
/were/ AI generated.

>
> On Thu, Aug 29, 2024 at 1:18=E2=80=AFAM Philip Kaludercic <philipk@posteo.net>=
> wrote:
>
>> Pranshu Sharma <sirsharmapranshu@gmail.com> writes:
>>
>> > Hello all
>> >
>> > haskell-ts-mode is a major mode for haskell that uses treesit= ter to
>> provide
>> > features such as indentation and colouring. The mode can be f= ound at
>> > pranshu/haskell-ts-mode:
>> > A haskelll mode that uses treesitter - Codeberg.org
>> > <https://codeberg.org/pranshu/haskell-t= s-mode>.
>>
>> First of all, the spacing and indentation is inconsistent.=C2=A0 P= lease
>> address that, and perhaps add a directory local option to enforce<= br> >> 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 li= ke 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><= br> >>=C2=A0 ;; URL: https://codeberg.org/pranshu/hask= ell-ts-mode
>>=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 th= e 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 f= unctions such
>> 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")<= br> >> @@ -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= .")
>> +=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 a= nd 4 for maximum.")
>> +;; both of these variables are actually user options and should b= e
>> declared using `'defcustom'!
>>
>>=C2=A0 (defvar haskell-ts-prettify-symbols-alits
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 '(("\\" . "=CE=BB&qu= ot;)
>> @@ -60,6 +62,7 @@
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0("<=3D" . "=E2= =89=A5")
>>=C2=A0 =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 =C2=A0:language 'haskell
>> @@ -157,7 +160,7 @@
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((parent-is "apply&q= uot;) parent -1)
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((node-is "quasiquot= e") grand-parent 2)
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((parent-is "quasiqu= ote_body") (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 &q= uot;Hg" 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 =C2=A0(let ((n (tr= eesit-node-prev-sibling node)))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(whil= e (string=3D "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 =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 =C2=A0(modi= fy-syntax-entry k "_" table))))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (char-table-parent table))
>>=C2=A0 =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 re= latively high
>> overhead, try to avoid it
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda (it) (modify-syntax-entr= y it " " 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 =C2=A0;; ascSymbol
>> @@ -268,46 +272,40 @@
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(modify-syntax-entry ?\{=C2=A0 &q= uot;(}1nb" table)
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(modify-syntax-entry ?\}=C2=A0 &q= uot;){4nb" table)
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(modify-syntax-entry ?-=C2=A0 &qu= ot;_ 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 "&g= t;" table))
>> +
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0table))
>>
>> +(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-ts-compile-region-and-go)
>>=C2=A0 =C2=A0 =C2=A0 (define-key km (kbd "C-c C-r") '= haskell-ts-run-haskell)
>> -=C2=A0 =C2=A0 (define-key km (kbd "C-M-q") 'haskell= -ts-indent-para)
>> +=C2=A0 =C2=A0 (define-key km (kbd "C-M-q") 'haskell= -ts-indent-para) ;is this
>> necessary when `prog-fill-reindent-defun' is bound to M-q?
>>=C2=A0 =C2=A0 =C2=A0 km)
>> -=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"
>>=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 av= ailable"))
>>=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 =C2=A0(setq-local treesit-simple-indent= -rules haskell-ts-indent-rules)
>>=C2=A0 =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 "\\(?: \\|^\\)-+&= quot;)
>>=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-de= fun-name)
>> +=C2=A0 (setq-local treesit-defun-name-function #'haskell-ts-d= efun-name)
>>=C2=A0 =C2=A0 (setq-local treesit-defun-type-regexp "function&= quot;)
>>=C2=A0 =C2=A0 (setq-local prettify-symbols-alist haskell-ts-prettif= y-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 =C2=A0`((nil haske= ll-ts-imenu-func-node-p nil
>> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ,(haskell-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 ,(haskell-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(&quo= t;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 =C2=A0(&quo= t;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 (lam= bda (node)
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (treesit-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-l= ock-level)
>>=C2=A0 =C2=A0 (setq-local treesit-font-lock-settings (haskell-ts-fo= nt-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&= quot; 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-site= r, so there is
>> +=C2=A0 =C2=A0 ;; no case where tree-sitter is available, but eglo= t 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 '(haske= ll-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.=C2=A0 That will modify eglot-server-programs a= nd
>> +;; evaluate the result when eglot is loaded.=C2=A0 You presumably= wanted to
>> +;; use `with-eval-after-load'?
>> +
>>=C2=A0 (when (treesit-ready-p 'haskell)
>>=C2=A0 =C2=A0 (add-to-list 'auto-mode-alist '("\\.hs\\= '" . 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.e= l"
>> >=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 i= n 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&qu= ot;
>> >=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/mauroaranda/hidden= quote/hiddenquote")
>> >
>>
>> --
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Philip Kaludercic on peregrine >>

--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Philip Kaludercic on peregrine
--00000000000085704a0620cf1c1a--