branch: elpa/haskell-tng-mode commit ac55d33005c4e4c126d91aff4845030eb7fb376b Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
interactive SMIE debugging --- haskell-tng-smie.el | 26 ++++++++++++++++++++++++-- test/haskell-tng-indent-test.el | 4 +++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index ce9dde1..0d10bc3 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -85,10 +85,32 @@ ))) +(defvar haskell-tng-smie:debug nil) +(defun haskell-tng-smie:debug (command) + "An alternative to RETURN that outputs SMIE debugging +information, to aid in the creation of new rules." + (let ((output " *haskell-tng-smie*")) + (when (get-buffer output) + (kill-buffer output)) + (let ((haskell-tng-smie:debug (get-buffer-create output)) + (inhibit-read-only t)) + (with-current-buffer haskell-tng-smie:debug + (read-only-mode 1)) + (call-interactively command) + (display-buffer output)))) +(defun haskell-tng-smie:debug-newline () + (interactive) + (haskell-tng-smie:debug #'newline-and-indent)) +(defun haskell-tng-smie:debug-tab () + (interactive) + (haskell-tng-smie:debug #'indent-for-tab-command)) + ;; https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Indentation (defun haskell-tng-smie:rules (method arg) ;; see docs for `smie-rules-function' - ;; (message "INDENT %S %S" method arg) + (when haskell-tng-smie:debug + (with-current-buffer haskell-tng-smie:debug + (insert (format "INDENT %S %S\n" method arg)))) (pcase method (:elem (pcase arg @@ -104,7 +126,7 @@ (if (smie-rule-parent-p "module") '(column . 0) smie-indent-basic)) - ((or "::" "=" "let" "do" "of") + ((or "::" "=" "let" "do" "of" "{") smie-indent-basic) )) diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el index f1e62f5..d8d6d14 100644 --- a/test/haskell-tng-indent-test.el +++ b/test/haskell-tng-indent-test.el @@ -19,7 +19,7 @@ ;; 2. newline-and-indent with the rest of the file intact (insert) ;; 3. indent-line-function at the beginning of each line (re-indent) ;; - ;; each with alternative indentation suggestions. + ;; each maybe with alternative indentation suggestions. ;; ;; Expectations could use lines of symbols such as | and . or digits to ;; indicate where the indentation(s) go. @@ -30,6 +30,8 @@ (should (have-expected-newline-indent-insert (testdata "src/medley.hs"))) ;; TODO more tests ;; https://raw.githubusercontent.com/kadena-io/chainweb-node/master/test/Chainweb/Test/TreeDB.hs + + ;; FIXME type 3 tests without alternatives ) ;; TODO enable this test and get it passing, which requires a TAB command that