Function: haskell-cabal-indent-line

haskell-cabal-indent-line is an interactive and natively compiled function defined in haskell-cabal.el.

Signature

(haskell-cabal-indent-line)

Documentation

Indent current line according to subsection

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/9lz2mhw95f9fqxr9mnq46k3f6qz3aq83-emacs-packages-deps/share/emacs/site-lisp/elpa/haskell-mode-20260904.1042/haskell-cabal.el
(defun haskell-cabal-indent-line ()
  "Indent current line according to subsection"
  (interactive)
  (cl-case (haskell-cabal-classify-line)
    (section-data
     (save-excursion
       (let* ((subsection (haskell-cabal-subsection))
              (beginning (haskell-cabal-section-start subsection))
              (indent-column (haskell-cabal-section-data-indent-column subsection))
              (subsection-leading-comma-p (save-excursion
                                            (goto-char beginning)
                                            (looking-at ",\\|\n[ \t\n]*,"))))
         (indent-line-to indent-column)
         (beginning-of-line)
         ;; Only do extra adjustment if the first item is not comma leading.
         ;; Example of the two cases:
         ;;
         ;; |  aaa     |    aaa
         ;; |  , bbb   |  , bbb
         ;;
         ;; |  , aaa |  , aaa
         ;; |  , bbb |  , bbb
         (when (and (not subsection-leading-comma-p)
                    (looking-at "[ ]*\\([ ]\\{2\\},[ ]*\\)"))
           (replace-match ", " t t nil 1)))))
    (empty
     (indent-relative)))
  (haskell-cabal-forward-to-line-entry))