Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,16 @@ Note that negative arguments do not work so well."
(goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
(backward-prefix-chars))
(save-match-data
(if (haskell-lexeme-looking-at-token)
(if (member (match-string 0) (list "(" "[" "{"))
(goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
(goto-char (match-end 0)))))))
(while (> arg 0)
(when (haskell-lexeme-looking-at-token)
(cond ((member (match-string 0) (list "(" "[" "{"))
(goto-char (or (scan-sexps (point) 1) (buffer-end 1))))
((member (match-string 0) (list ")" "]" "}"))
(signal 'scan-error (list "Containing expression ends prematurely."
(match-beginning 0)
(match-end 0))))
(t (goto-char (match-end 0)))))
(setf arg (1- arg))))))



Expand Down
54 changes: 54 additions & 0 deletions tests/haskell-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,58 @@ Also should respect 10 column fill."
(string= "hello world"
(buffer-substring 1 (point-max))))))

(ert-deftest forward-sexp-function-1 ()
"Check if `forward-sexp-function' behaves properly on end of
sexp."
(should (with-temp-buffer
(haskell-mode)
(insert "(foo) bar")
(goto-char 5)
(condition-case err
(progn (forward-sexp)
nil)
(scan-error (equal (cddr err) (list 5 6)))))))

(ert-deftest forward-sexp-function-2 ()
"Check if `forward-sexp-function' behaves properly on beginning
of sexp."
(should (with-temp-buffer
(haskell-mode)
(insert "(foo) bar")
(goto-char 1)
(forward-sexp)
(eq (point) 6))))

(ert-deftest haskell-forward-sexp-1 ()
"Check if `haskell-forward-sexp' properly moves over sexps."
(should (with-temp-buffer
(insert "foo = bar . baz")
(goto-char 1)
(haskell-forward-sexp 4)
(eq (point) 12))))

(ert-deftest haskell-forward-sexp-2 ()
"Check if `haskell-forward-sexp' properly moves over sexps."
(should (with-temp-buffer
(insert "foo = bar . baz")
(goto-char 1)
(haskell-forward-sexp 1)
(eq (point) 4))))

(ert-deftest haskell-forward-sexp-3 ()
"Check if `haskell-forward-sexp' properly moves over sexps."
(should (with-temp-buffer
(insert "(a b) c = d . e")
(goto-char 1)
(haskell-forward-sexp 5)
(eq (point) 14))))

(ert-deftest haskell-forward-sexp-4 ()
"Check if `haskell-forward-sexp' properly moves over sexps."
(should (with-temp-buffer
(insert "(a b) c = d . e")
(goto-char 1)
(haskell-forward-sexp 1)
(eq (point) 6))))

(provide 'haskell-mode-tests)