Skip to content

Add front-sticky property to read-only text in REPL #1136

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

Merged
merged 1 commit into from
Feb 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 38 additions & 34 deletions haskell-interactive-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -298,26 +298,24 @@ do the
(defun haskell-interactive-mode-prompt (&optional session)
"Show a prompt at the end of the REPL buffer.
If SESSION is non-nil, use the REPL buffer associated with
SESSION, otherwise operate on the current buffer.
"
SESSION, otherwise operate on the current buffer."
(with-current-buffer (if session
(haskell-session-interactive-buffer session)
(current-buffer))
(goto-char (point-max))
(insert (propertize haskell-interactive-prompt
'font-lock-face 'haskell-interactive-face-prompt
'read-only t
'rear-nonsticky t
'prompt t))
(let ((prompt (propertize haskell-interactive-prompt
'font-lock-face 'haskell-interactive-face-prompt
'prompt t
'read-only t
'rear-nonsticky t)))
;; At the time of writing, front-stickying the first char gives an error
;; Has unfortunate side-effect of being able to insert before the prompt
(insert (substring prompt 0 1)
(propertize (substring prompt 1)
'front-sticky t)))
(let ((marker (set (make-local-variable 'haskell-interactive-mode-prompt-start)
(make-marker))))
(set-marker marker
(point)
(current-buffer))
(when nil
(let ((o (make-overlay (point) (point-max) nil nil t)))
(overlay-put o 'line-prefix (make-string (length haskell-interactive-prompt)
? )))))
(set-marker marker (point)))
(when haskell-interactive-mode-scroll-to-bottom
(haskell-interactive-mode-scroll-to-bottom))))

Expand All @@ -328,9 +326,10 @@ SESSION, otherwise operate on the current buffer.
(insert (ansi-color-apply
(propertize text
'font-lock-face 'haskell-interactive-face-result
'rear-nonsticky t
'read-only t
'front-sticky t
'prompt t
'read-only t
'rear-nonsticky t
'result t)))
(haskell-interactive-mode-handle-h)
(let ((marker (set (make-local-variable 'haskell-interactive-mode-result-end)
Expand Down Expand Up @@ -365,22 +364,25 @@ SESSION, otherwise operate on the current buffer.
(save-excursion
(haskell-interactive-mode-goto-end-point)
(let ((lines (string-match "^\\(.*\\)\n\\([[:unibyte:][:nonascii:]]+\\)" message)))
(when lines
(insert (propertize (concat (match-string 1 message) " …\n")
'font-lock-face type
'read-only t
'rear-nonsticky t
'expandable t))
(insert (propertize (concat (match-string 2 message) "\n")
'font-lock-face type
'read-only t
'rear-nonsticky t
'collapsible t
'invisible haskell-interactive-mode-hide-multi-line-errors
'message-length (length (match-string 2 message)))))
(unless lines
(if lines
(progn
(insert (propertize (concat (match-string 1 message) " …\n")
'expandable t
'font-lock-face type
'front-sticky t
'read-only t
'rear-nonsticky t))
(insert (propertize (concat (match-string 2 message) "\n")
'collapsible t
'font-lock-face type
'front-sticky t
'invisible haskell-interactive-mode-hide-multi-line-errors
'message-length (length (match-string 2 message))
'read-only t
'rear-nonsticky t)))
(insert (propertize (concat message "\n")
'font-lock-face type
'front-sticky t
'read-only t
'rear-nonsticky t)))))))

Expand All @@ -390,6 +392,7 @@ SESSION, otherwise operate on the current buffer.
(save-excursion
(haskell-interactive-mode-goto-end-point)
(insert (propertize message
'front-sticky t
'read-only t
'rear-nonsticky t)))))

Expand Down Expand Up @@ -736,8 +739,7 @@ wrapped in compiler directive at the top of FILE."
(error "don't know where to find %S" file)))))))

(defun haskell-interactive-session ()
"Get the `haskell-session', throw an error if it's not
available."
"Get the `haskell-session', throw an error if it's not available."
(or (haskell-session-maybe)
(haskell-session-assign
(or (haskell-session-from-buffer)
Expand All @@ -751,8 +753,8 @@ wrapped in compiler directive at the top of FILE."
buffer. Maybe run M-x haskell-process-restart?")))

(defun haskell-interactive-mode-do-presentation (expr)
"Present the given expression. Requires the `present` package
to be installed. Will automatically import it qualified as Present."
"Present the given expression. Requires the `present' package
to be installed. Will automatically import it qualified as Present."
(let ((p (haskell-interactive-process)))
;; If Present.code isn't available, we probably need to run the
;; setup.
Expand Down Expand Up @@ -1083,6 +1085,7 @@ don't care when the thing completes as long as it's soonish."
(concat message "\n")
mode)
(propertize (concat message "\n")
'front-sticky t
'read-only t
'rear-nonsticky t))))))

Expand Down Expand Up @@ -1118,6 +1121,7 @@ don't care when the thing completes as long as it's soonish."
(save-excursion
(haskell-interactive-mode-goto-end-point)
(insert (propertize message
'front-sticky t
'font-lock-face 'haskell-interactive-face-garbage
'read-only t
'rear-nonsticky t)))))
Expand Down