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
base: master
Are you sure you want to change the base?
Conversation
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 |
(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? |
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 |
There was a problem hiding this comment.
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)))))))) |
There was a problem hiding this comment.
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)))
Hope this can be optional; I find the editability more intuitive as an Eshell user. |
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 asface
, and therefore the new value oft
is suspect: it doesn't seem to have changed anything visible & the tests all pass (except for one which fails even on the currentmaster
). However, I found that unless I changed the value forrear-nonsticky
, formatting withread-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 isslime-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?