Skip to content

Commit a8e924b

Browse files
committed
Merge pull request #990 from bergey/message-truncate
Truncate multi-line messages less aggressively
2 parents c6f5e04 + 327df6d commit a8e924b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

haskell-interactive-mode.el

+9-7
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,15 @@ SESSION, otherwise operate on the current buffer.
412412

413413
(defun haskell-mode-message-line (str)
414414
"Message only one line, multiple lines just disturbs the programmer."
415-
(let ((lines (split-string str "\n" t)))
416-
(when (and (car lines) (stringp (car lines)))
417-
(message "%s"
418-
(concat (car lines)
419-
(if (and (cdr lines) (stringp (cadr lines)))
420-
(format " [ %s .. ]" (haskell-string-take (haskell-string-trim (cadr lines)) 10))
421-
""))))))
415+
(message (haskell-mode-one-line str (frame-width))))
416+
417+
(defun haskell-mode-one-line (str width)
418+
"Try to fit as much as possible on one line."
419+
(let*
420+
((long-line (replace-regexp-in-string "\n" " " str))
421+
(condensed (replace-regexp-in-string " +" " "
422+
(haskell-string-trim long-line))))
423+
(truncate-string-to-width condensed width nil nil "")))
422424

423425
(defun haskell-interactive-mode-tab ()
424426
"Do completion if at prompt or else try collapse/expand."

0 commit comments

Comments
 (0)