|
136 | 136 | (require 'haskell-complete-module)
|
137 | 137 | (require 'haskell-compat)
|
138 | 138 | (require 'haskell-align-imports)
|
| 139 | +(require 'haskell-lexeme) |
139 | 140 | (require 'haskell-sort-imports)
|
140 | 141 | (require 'haskell-string)
|
141 | 142 |
|
@@ -652,6 +653,7 @@ Minor modes that work well with `haskell-mode':
|
652 | 653 | (set (make-local-variable 'comment-start-skip) "[-{]-[ \t]*")
|
653 | 654 | (set (make-local-variable 'comment-end) "")
|
654 | 655 | (set (make-local-variable 'comment-end-skip) "[ \t]*\\(-}\\|\\s>\\)")
|
| 656 | + (set (make-local-variable 'forward-sexp-function) #'haskell-forward-sexp) |
655 | 657 | (set (make-local-variable 'parse-sexp-ignore-comments) nil)
|
656 | 658 | (set (make-local-variable 'indent-line-function) 'haskell-mode-suggest-indent-choice)
|
657 | 659 | ;; Set things up for eldoc-mode.
|
@@ -747,6 +749,31 @@ Minor modes that work well with `haskell-mode':
|
747 | 749 | ;; (skip-syntax-forward "^w")
|
748 | 750 | ;; (make-string (- (point) line-start) ?\s))))))
|
749 | 751 |
|
| 752 | +;;;###autoload |
| 753 | +(defun haskell-forward-sexp (&optional arg) |
| 754 | + "Haskell specific version of `forward-sexp'. |
| 755 | +
|
| 756 | +Move forward across one balanced expression (sexp). With ARG, do |
| 757 | +it that many times. Negative arg -N means move backward across N |
| 758 | +balanced expressions. This command assumes point is not in a |
| 759 | +string or comment. |
| 760 | +
|
| 761 | +Note that negative arguments do not work so well." |
| 762 | + (interactive "^p") |
| 763 | + (or arg (setq arg 1)) |
| 764 | + (if (< arg 0) |
| 765 | + ;; Fall back to native Emacs method for negative arguments. |
| 766 | + ;; Haskell has maximum munch rule that does not work well |
| 767 | + ;; backwards. |
| 768 | + (progn |
| 769 | + (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) |
| 770 | + (backward-prefix-chars)) |
| 771 | + (save-match-data |
| 772 | + (if (haskell-lexeme-looking-at-token) |
| 773 | + (if (member (match-string 0) (list "(" "[" "{")) |
| 774 | + (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) |
| 775 | + (goto-char (match-end 0))))))) |
| 776 | + |
750 | 777 |
|
751 | 778 |
|
752 | 779 | ;;;###autoload
|
|
0 commit comments