emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/haskell-ts-mode 9566f23699 60/61: new indent funciton


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-ts-mode 9566f23699 60/61: new indent funciton
Date: Wed, 4 Sep 2024 04:00:32 -0400 (EDT)

branch: elpa/haskell-ts-mode
commit 9566f23699dadfbe00f90b38445c122d06e2390e
Author: pranshu <pranshusharma366@gmail.com>
Commit: pranshu <pranshusharma366@gmail.com>

    new indent funciton
    
    Replaced haskell-ts-indent-paragraph with a function based alt.
---
 haskell-ts-mode.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/haskell-ts-mode.el b/haskell-ts-mode.el
index ff6ab5572e..463e17f3a3 100644
--- a/haskell-ts-mode.el
+++ b/haskell-ts-mode.el
@@ -287,17 +287,21 @@
         (haskell-ts-defun-name node)
        nil)))
 
-(defun haskell-ts-indent-para ()
-  "Indent the current paragraph."
-  (interactive)
-  (when-let ((par (bounds-of-thing-at-point 'paragraph)))
-    (indent-region (car par) (cdr par))))
+(defun haskell-ts-indent-defun (pos)
+  "Indent the current function."
+  (interactive "d")
+  (let ((node (treesit-node-at pos)))
+    (while (not (string-match
+                "declarations\\|haskell"
+                (treesit-node-type (treesit-node-parent node))))
+      (setq node (treesit-node-parent node)))
+    (indent-region (treesit-node-start node) (treesit-node-end node))))
 
 (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) ; For those who 
don't have emacs 30
+    (define-key km (kbd "C-M-q") 'haskell-ts-indent-defun) ; For those who 
don't have emacs 30
     km)
   "Map for haskell-ts-mode.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]