haskell / haskell/haskell-mode

QuasiQuotes that are not part of the Haskell standard or haskell-font-lock-quasi-quote-modes will cause haskell-indentation to be incorrect afterwards

Open
#1,789 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

The indent function is buggy when using anything other than hardcoded QuasiQuote.

I was editing [ncaq/dic-nico-intersection-pixiv](https://github.com/ncaq/dic-nico-intersection-pixiv/blob/master/src/Main.hs) and thought `haskell-indentation-newline-and-indent` was wrong.

When I use `QuasiQuote`, the `haskell-indentation-newline-and-indent` inside that function and the `indent-for-tab-command` on TAB are strange.

Haskell standard ones such as `[|foo|]` and `[d|foo|]` and `hsx` in `haskell-font-lock-quasi-quote-modes` do not go wrong.

# Reproduction procedure.

`stack new foo`

Add `template-haskell` to `dependencies`.

Put the following in `src/DoNothing.hs`.

```
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module DoNothing where

import Language.Haskell.TH
import Language.Haskell.TH.Quote

doNothing :: QuasiQuoter
doNothing = QuasiQuoter
{ quoteExp = litE . . stringL
, quotePat = undefined
, quoteType = undefined
, quoteDec = undefined
}
```

Put the following in `src/Lib.hs`.

```
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Lib
( someFunc
) where

import DoNothing

someFunc :: IO ()
someFunc = do
print [doNothing|aaa|]]
print "foo"
```

If I move the cursor over `print "foo"` here and invoke `indent-for-tab-command` with TAB, it should return to the original indentation level after a few presses, but it is fixed at a strange indentation, like this.

```
someFunc :: IO ()
someFunc = do
print [doNothing|aaa|]]
print "foo"
```

As I mentioned at the beginning, I confirmed that this does not happen with already registered Quote names such as `hsx`.
Also, the font-lock looks different.
I took a quick peek at the code and couldn't figure it out, so I'm reporting it anyway.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.