Skip to content

Commit ded887b

Browse files
committed
Fix a couple obvious bugs in haskell-process-log
Fix bugs visible in coding style.
1 parent 08cbbbb commit ded887b

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

haskell-process.el

+29-27
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
137137
'face '((:weight bold))))
138138
(haskell-process-log
139139
(propertize "Process reset.\n"
140-
'face font-lock-comment-face))
140+
'face 'font-lock-comment-face))
141141
(run-hook-with-args 'haskell-process-ended-functions process))))))
142142

143143
(defun haskell-process-filter (proc response)
@@ -146,7 +146,7 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
146146
(cl-loop for line in (split-string response "\n")
147147
do (haskell-process-log
148148
(concat (if (= i 0)
149-
(propertize "<- " 'face font-lock-comment-face)
149+
(propertize "<- " 'face 'font-lock-comment-face)
150150
" ")
151151
(propertize line 'face 'haskell-interactive-face-compile-warning)))
152152
do (setq i (1+ i))))
@@ -155,9 +155,7 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
155155
(if (haskell-process-cmd (haskell-session-process session))
156156
(haskell-process-collect session
157157
response
158-
(haskell-session-process session))
159-
(haskell-process-log
160-
(replace-regexp-in-string "\4" "" response))))))
158+
(haskell-session-process session))))))
161159

162160
(defun haskell-process-log (msg)
163161
"Effective append MSG to the process log (if enabled)."
@@ -166,24 +164,23 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
166164
(windows (get-buffer-window-list append-to t t))
167165
move-point-in-windows)
168166
(with-current-buffer append-to
169-
(setq buffer-read-only nil)
170-
;; record in which windows we should keep point at eob.
171-
(dolist (window windows)
172-
(when (= (window-point window) (point-max))
173-
(push window move-point-in-windows)))
174-
(let (return-to-position)
175-
;; decide whether we should reset point to return-to-position
176-
;; or leave it at eob.
177-
(unless (= (point) (point-max))
178-
(setq return-to-position (point))
179-
(goto-char (point-max)))
180-
(insert "\n" msg "\n")
181-
(when return-to-position
182-
(goto-char return-to-position)))
183-
;; advance to point-max in windows where it is needed
184-
(dolist (window move-point-in-windows)
185-
(set-window-point window (point-max)))
186-
(setq buffer-read-only t)))))
167+
(let ((buffer-read-only nil))
168+
;; record in which windows we should keep point at eob.
169+
(dolist (window windows)
170+
(when (= (window-point window) (point-max))
171+
(push window move-point-in-windows)))
172+
(let (return-to-position)
173+
;; decide whether we should reset point to return-to-position
174+
;; or leave it at eob.
175+
(unless (= (point) (point-max))
176+
(setq return-to-position (point))
177+
(goto-char (point-max)))
178+
(insert msg "\n")
179+
(when return-to-position
180+
(goto-char return-to-position)))
181+
;; advance to point-max in windows where it is needed
182+
(dolist (window move-point-in-windows)
183+
(set-window-point window (point-max))))))))
187184

188185
(defun haskell-process-project-by-proc (proc)
189186
"Find project by process."
@@ -227,10 +224,15 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
227224
(let ((child (haskell-process-process process)))
228225
(if (equal 'run (process-status child))
229226
(let ((out (concat string "\n")))
230-
(haskell-process-log
231-
(propertize (concat (propertize "-> " 'face font-lock-comment-face)
232-
(propertize string 'face font-lock-string-face))
233-
'face '((:weight bold))))
227+
(let ((i 0))
228+
(cl-loop for line in (split-string out "\n")
229+
do (unless (string-equal "" line)
230+
(haskell-process-log
231+
(concat (if (= i 0)
232+
(propertize "-> " 'face 'font-lock-comment-face)
233+
" ")
234+
(propertize line 'face 'font-lock-string-face))))
235+
do (setq i (1+ i))))
234236
(process-send-string child out))
235237
(unless (haskell-process-restarting process)
236238
(run-hook-with-args 'haskell-process-ended-functions process)))))

0 commit comments

Comments
 (0)