Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introduce `haskell-indentation-where-{pre,post}-offset' for offsets a…

…round `where' keyword.

Ignore-this: 2ca7e130fbd7fd60f8a3b0bd04a86b18

darcs-hash:20100601041912-0d607-ea06402293e73fded3c91ce37aefd539ce2fd46c.gz
  • Loading branch information...
commit fda1f36a687b15b886f6065a1f91407de394de75 1 parent 57c4ceb
@iquiw iquiw authored
Showing with 27 additions and 5 deletions.
  1. +27 −5 haskell-indentation.el
View
32 haskell-indentation.el
@@ -67,6 +67,16 @@
:type 'integer
:group 'haskell-indentation)
+(defcustom haskell-indentation-where-pre-offset 2
+ "Extra indentation before the keyword `where'."
+ :type 'integer
+ :group 'haskell-indentation)
+
+(defcustom haskell-indentation-where-post-offset 2
+ "Extra indentation after the keyword `where'."
+ :type 'integer
+ :group 'haskell-indentation)
+
;; Avoid a global bogus definition (which the original run-time
;; `defun' made), and support Emacs 21 without the syntax.el add-on.
(eval-when-compile
@@ -446,7 +456,7 @@ Preserves indentation and removes extra whitespace"
'(haskell-indentation-expression
"->" haskell-indentation-expression))))
("where" . (lambda () (haskell-indentation-with-starter
- #'haskell-indentation-declaration-layout nil)))
+ #'haskell-indentation-declaration-layout nil t)))
("::" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-type)))
("=" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-expression)))
("<-" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-expression)))
@@ -571,7 +581,7 @@ Preserves indentation and removes extra whitespace"
,stmt-sep))
end))
-(defun haskell-indentation-with-starter (parser end)
+(defun haskell-indentation-with-starter (parser end &optional where-expr?)
(let ((starter-column (haskell-current-column))
(current-indent current-indent)
(left-indent (if (= (haskell-current-column) (current-indentation))
@@ -580,8 +590,10 @@ Preserves indentation and removes extra whitespace"
(when (equal current-token 'end-tokens)
(if (equal following-token end)
(haskell-indentation-add-indentation starter-column)
+ (if where-expr?
+ (haskell-indentation-add-where-post-indent left-indent)
(haskell-indentation-add-indentation
- (+ left-indent haskell-indentation-left-offset)))
+ (+ left-indent haskell-indentation-left-offset))))
(throw 'parse-end nil))
(let* ((current-indent (haskell-current-column))
(starter-indent (min starter-column current-indent))
@@ -659,8 +671,7 @@ Preserves indentation and removes extra whitespace"
((equal current-token 'end-tokens)
(cond ((equal following-token "where")
- (haskell-indentation-add-indentation
- (+ left-indent haskell-indentation-left-offset)))
+ (haskell-indentation-add-where-pre-indent))
((haskell-indentation-expression-token following-token)
(haskell-indentation-add-indentation
current-indent)))
@@ -803,6 +814,17 @@ Preserves indentation and removes extra whitespace"
(defun haskell-indentation-add-layout-indent ()
(haskell-indentation-push-indentation layout-indent))
+(defun haskell-indentation-add-where-pre-indent ()
+ (haskell-indentation-push-indentation
+ (+ layout-indent haskell-indentation-where-pre-offset))
+ (if (= layout-indent haskell-indentation-layout-offset)
+ (haskell-indentation-push-indentation
+ haskell-indentation-where-pre-offset)))
+
+(defun haskell-indentation-add-where-post-indent (indent)
+ (haskell-indentation-push-indentation
+ (+ indent haskell-indentation-where-post-offset)))
+
(defun haskell-indentation-push-indentation (indent)
(when (or (null possible-indentations)
(< indent (car possible-indentations)))
Please sign in to comment.
Something went wrong with that request. Please try again.