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

Make slime repl output read-only #557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Make slime repl output read-only #557

wants to merge 1 commit into from

Conversation

anlsh
Copy link

@anlsh anlsh commented Apr 21, 2020

I found it a bit jarring that it was possible to edit past output in the slime repl, so I messed around a bit & made the output read-only.

I should note that I don't know why rear-nonsticky was set as face, and therefore the new value of t is suspect: it doesn't seem to have changed anything visible & the tests all pass (except for one which fails even on the current master). However, I found that unless I changed the value for rear-nonsticky, formatting with read-only t would complain about some sort of "timer error" and never display the input prompt or cursor after any output had been written to the repl.

I was also hoping to do the same for the results returned by functions instead of just printed output: after trying to make analogous changes to slime-repl.el/slime-repl-emit-result, I figured out that this function wasn't actually involved in emitting results. The function actually responsible is slime-presentations.el/slime-presentation-write-result. Unfortunately trying the same trick makes the repl very slow to display evaluation results & seems to reset the font color.

Anyways. I thought I'd submit what I had. Perhaps someone who knows what they're doing could finish the job for evaluation results?

@luismbo
Copy link
Member

luismbo commented Apr 24, 2020

This is a bit of an Emacs tradition with repls. ielm and eshell, for instance, have the same behaviour. I'm not sure why that is.

@joaotavora
Copy link
Contributor

This is a bit of an Emacs tradition with repls. ielm and eshell, for instance, have the same behaviour. I'm not sure why that is.

It's sort of by design in comint.el, and there is prior art for fixing those. I sympathise with this, and the relative sanity comint.el offers prompted me to choose it for SLY's REPL (sorry for the plug).

@luismbo
Copy link
Member

luismbo commented Apr 24, 2020

(defun my-comint-preoutput-turn-buffer-read-only (text)
  (propertize text 'read-only t))

(add-hook 'comint-preoutput-filter-functions 'my-comint-preoutput-turn-buffer-read-only)

is this what you're suggesting for fixing the issue in comint-based repls?

@joaotavora
Copy link
Contributor

joaotavora commented Apr 24, 2020

is this what you're suggesting for fixing the issue in comint-based repls?

Something like that, yes. But I don't think SLIME's REPL is comint-based (maybe I'm wrong). By "sympathise" I mean I sympathise with the OP's report.

@easye
Copy link
Contributor

easye commented Jun 12, 2020

Something like that, yes. But I don't think SLIME's REPL is comint-based (maybe I'm wrong). By "sympathise" I mean I sympathise with the OP's report.

I would love a toggle here, to switch between the traditional mode and the "safety" mode. Especially on presentations that can be inspected, as many is the time I had to re-run the code to get a new presentation to inspect.

@@ -280,13 +280,14 @@ This is set to nil after displaying the buffer.")
(slime-save-marker slime-output-start
(slime-propertize-region '(face slime-repl-output-face
slime-repl-output t
rear-nonsticky (face))
read-only t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe read-only could be set to the value of some new variable, e.g. slime-repl-output-read-only, which the user can configure? That way the default behavior would be the same (for now) but you could get read-only by tweaking your .emacs.

(when (and (= (point) slime-repl-prompt-start-mark)
(not (bolp)))
(insert-before-markers "\n")
(set-marker slime-output-end (1- (point))))))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some spaces-to-tabs conversions sneaked in here. You might like to run untabify on the buffer to put that back and maybe even make that default with an emacs config line like

(add-hook 'lisp-mode-hook (defun my-lisp-mode-hook () (setq indent-tabs-mode nil)))

@spwhitton
Copy link

Hope this can be optional; I find the editability more intuitive as an Eshell user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants