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

Remove indentation safety hack #966

Merged
merged 1 commit into from
Oct 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 7 additions & 14 deletions haskell-indentation.el
Expand Up @@ -210,7 +210,7 @@ negative ARG. Handles bird style literate Haskell too."
(catch 'parse-error
;; - save the current column
(let* ((ci (haskell-indentation-current-indentation))
(indentations (haskell-indentation-find-indentations-safe)))
(indentations (haskell-indentation-find-indentations)))
;; - jump to the next line and reindent to at the least same level
(delete-horizontal-space)
(newline)
Expand Down Expand Up @@ -261,20 +261,18 @@ indentation points to the right, we switch going to the left."
(unless (save-excursion
(beginning-of-line)
(nth 8 (syntax-ppss)))
;; parse error is intentionally not catched here, it may come from
;; `haskell-indentation-find-indentations-safe', but escapes the scope
;; parse error is intentionally not cought here, it may come from
;; `haskell-indentation-find-indentations', but escapes the scope
;; and aborts the opertaion before any moving happens
(let* ((cc (current-column))
(ci (haskell-indentation-current-indentation))
(inds (save-excursion
(move-to-column ci)
(haskell-indentation-find-indentations-safe)))
(haskell-indentation-find-indentations)))
(valid (memq ci inds))
(cursor-in-whitespace (< cc ci)))
;; can't happen right now, because of -safe, but we may want to have
;; this in the future
;; (when (null inds)
;; (error "returned indentations empty, but no parse error"))
(when (null inds)
(error "returned indentations empty, but no parse error"))
(if (and valid cursor-in-whitespace)
(move-to-column ci)
(haskell-indentation-reindent-to
Expand Down Expand Up @@ -349,7 +347,7 @@ indentation points to the right, we switch going to the left."
(ci (haskell-indentation-current-indentation))
(inds (save-excursion
(move-to-column ci)
(haskell-indentation-find-indentations-safe)))
(haskell-indentation-find-indentations)))
(cursor-in-whitespace (< cc ci))
(pi (haskell-indentation-previous-indentation ci inds)))
(if (null pi)
Expand Down Expand Up @@ -485,11 +483,6 @@ indentation points to the right, we switch going to the left."
(t
(haskell-indentation-parse-to-indentations)))))

;; XXX: this is a hack, the parser shouldn't return nil without parse-error
(defun haskell-indentation-find-indentations-safe ()
(or (haskell-indentation-find-indentations)
(haskell-indentation-first-indentation)))

(defconst haskell-indentation-unicode-tokens
'(("→" . "->") ;; #x2192 RIGHTWARDS ARROW
("∷" . "::") ;; #x2237 PROPORTION
Expand Down