@@ -90,33 +90,41 @@ column, `tab-to-tab-stop' is done instead."
90
90
(interactive )
91
91
(let* ((start-column (current-column ))
92
92
(invisible-from nil ) ; `nil' means infinity here
93
- (indent
94
- (catch 'haskell-simple-indent-break
95
- (save-excursion
96
- (while (progn (beginning-of-line )
97
- (not (bobp )))
98
- (forward-line -1 )
99
- (if (not (looking-at " [ \t ]*\n " ))
100
- (let ((this-indentation (current-indentation )))
101
- (if (or (not invisible-from)
102
- (< this-indentation invisible-from))
103
- (if (> this-indentation start-column)
104
- (setq invisible-from this-indentation)
105
- (let ((end (line-beginning-position 2 )))
106
- (move-to-column start-column)
107
- ; ; Is start-column inside a tab on this line?
108
- (if (> (current-column ) start-column)
109
- (backward-char 1 ))
110
- (or (looking-at " [ \t ]" )
111
- (skip-chars-forward " ^ \t " end))
112
- (skip-chars-forward " \t " end)
113
- (let ((col (current-column )))
114
- (throw 'haskell-simple-indent-break
115
- (if (or (= (point ) end)
116
- (and invisible-from
117
- (> col invisible-from)))
118
- invisible-from
119
- col)))))))))))))
93
+ (indent))
94
+ (save-excursion
95
+ ; ; Loop stops if there no more lines above this one or when has
96
+ ; ; found a line starting at first column.
97
+ (while (and (or (not invisible-from)
98
+ (not (zerop invisible-from)))
99
+ (zerop (forward-line -1 )))
100
+ ; ; Ignore empty lines.
101
+ (if (not (looking-at " [ \t ]*\n " ))
102
+ (let ((this-indentation (current-indentation )))
103
+ ; ; Is this line so indented that it cannot have
104
+ ; ; influence on indentation points?
105
+ (if (or (not invisible-from)
106
+ (< this-indentation invisible-from))
107
+ (if (> this-indentation start-column)
108
+ (setq invisible-from this-indentation)
109
+ (let ((end (line-end-position )))
110
+ (move-to-column start-column)
111
+ ; ; Is start-column inside a tab on this line?
112
+ (if (> (current-column ) start-column)
113
+ (backward-char 1 ))
114
+ ; ; Skip to the end of non-whitespace.
115
+ (skip-chars-forward " ^ \t " end)
116
+ ; ; Skip over whitespace.
117
+ (skip-chars-forward " \t " end)
118
+ ; ; Indentation point found if not at the end of
119
+ ; ; line and if not covered by any line below
120
+ ; ; this one. In that case use invisible-from.
121
+ (setq indent (if (or (= (point ) end)
122
+ (and invisible-from
123
+ (> (current-column ) invisible-from)))
124
+ invisible-from
125
+ (current-column )))
126
+ ; ; Signal that solution is found.
127
+ (setq invisible-from 0 ))))))))
120
128
(if indent
121
129
(let ((opoint (point-marker )))
122
130
(indent-line-to indent)
0 commit comments