Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement indentation support for TeX-style literate Haskell buffers #1829

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

DataKinds
Copy link
Contributor

This PR implements a new function haskell-indentation-literate-outside-code-p which may be used to detect when the point is outside a code block in both Bird-style and TeX-style literate buffers. Note that GHC accepts a mixture of both Bird-style and TeX-style delimiting in the same file, so changing the possible values of the haskell-literate variable might be in-scope here as well.

@DataKinds DataKinds changed the title Implement support for TeX-style literate Haskell buffers Implement indentation support for TeX-style literate Haskell buffers Oct 24, 2023
@purcell purcell merged commit d16c68c into haskell:master Oct 25, 2023
10 checks passed
@purcell
Copy link
Member

purcell commented Oct 25, 2023

Thanks!

@purcell
Copy link
Member

purcell commented Oct 25, 2023

Hey @DataKinds, @smonnier suggests a simpler formulation of the new function:

(defun haskell-indentation-tex-outside-code-p ()
  "Non-NIL if we are in tex literate mode, but outside of code."
  (and (haskell-indentation-tex-p)
       (not (and (save-excursion
                   (re-search-backward "\\\\end{code}\\|\\\\begin{code}\\(\\)"
                                       nil t))
                 (match-end 1)))))

Would you mind testing it out to see if it works?

@DataKinds
Copy link
Contributor Author

Hey @DataKinds, @smonnier suggests a simpler formulation of the new function:

(defun haskell-indentation-tex-outside-code-p ()
  "Non-NIL if we are in tex literate mode, but outside of code."
  (and (haskell-indentation-tex-p)
       (not (and (save-excursion
                   (re-search-backward "\\\\end{code}\\|\\\\begin{code}\\(\\)"
                                       nil t))
                 (match-end 1)))))

Would you mind testing it out to see if it works?

Tested both in and out of evil-mode on the same file I wrote my PR with. As far as I can tell the simpler formulation works well. The empty group at the end of the regex is a cool trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants