Function: ghostel--enter-readonly
ghostel--enter-readonly is a natively compiled function defined in
ghostel.el.
Signature
(ghostel--enter-readonly MODE FREEZE LABEL ENTRY-MESSAGE)
Documentation
Enter or transition between read-only modes.
MODE is copy or emacs. FREEZE non-nil pauses live terminal
output (copy mode); nil keeps it streaming (Emacs mode). LABEL is
the mode-line-process tag. ENTRY-MESSAGE is shown on entry from
a non-read-only mode.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--enter-readonly (mode freeze label entry-message)
"Enter or transition between read-only modes.
MODE is `copy' or `emacs'. FREEZE non-nil pauses live terminal
output (copy mode); nil keeps it streaming (Emacs mode). LABEL is
the `mode-line-process' tag. ENTRY-MESSAGE is shown on entry from
a non-read-only mode."
;; Manual mode switch — see `ghostel-semi-char-mode' for why.
(setq ghostel--line-mode-paused nil)
(let ((from ghostel--input-mode))
;; Track the mode we just left so a later exit returns to it.
;; Line mode is stateful and not safely resumable — fall back
;; to semi-char when exiting copy or Emacs in that case.
(setq ghostel--pre-readonly-mode
(pcase from
('line 'semi-char)
(m m)))
(cond
;; Toggle between the two read-only modes — buffer is already
;; read-only, just adjust the freeze state, mode-line, and keymap.
((memq from '(copy emacs)) nil)
;; First entry from a non-read-only mode.
(t
(pcase from
('line (ghostel--line-mode-teardown)
(ghostel--enter-readonly-state))
(_ (ghostel--enter-readonly-state)))
(setq ghostel--char-mode-override-active nil)
(message "%s" entry-message)))
(if freeze
(ghostel--freeze-terminal)
;; Live mode: the redraw timer must be running so output keeps
;; flowing. `--invalidate' restarts it if a previous freeze
;; cancelled it.
(when ghostel--term
(ghostel--invalidate)))
(setq ghostel--input-mode mode)
(ghostel--sync-read-only)
(use-local-map (ghostel--readonly-keymap))
(setq ghostel--mode-line-tag (ghostel--mode-line-tag-make mode label))
(ghostel--mode-line-refresh)
(ghostel--fake-cursor-update)))