Function: inferior-emacs-lisp-mode
inferior-emacs-lisp-mode is an interactive and byte-compiled function
defined in ielm.el.gz.
Signature
(inferior-emacs-lisp-mode)
Documentation
Major mode for interactively evaluating Emacs Lisp expressions.
Uses the interface provided by comint-mode (which see).
* C-j (ielm-send-input) evaluates the sexp following the prompt. There must be at most
one top level sexp per prompt.
* RET (ielm-return) inserts a newline and indents, or evaluates a
complete expression (but see variable ielm-dynamic-return).
Inputs longer than one line are moved to the line following the
prompt (but see variable ielm-dynamic-multiline-inputs).
* M-RET (ielm-return-for-effect) works like ielm-return, except
that it doesn't print the result of evaluating the input. This
functionality is useful when forms would generate voluminous
output.
* C-M-i (completion-at-point) completes Lisp symbols (or filenames, within strings),
or indents the line if there is nothing to complete.
The current working buffer may be changed (with a call to set-buffer,
or with C-c C-b (ielm-change-working-buffer)), and its value is preserved between successive
evaluations. In this way, expressions may be evaluated in a different
buffer than the *ielm* buffer. By default, its name is shown on the
mode line; you can always display it with C-c C-v (ielm-print-working-buffer), or the buffer itself
with C-c C-f (ielm-display-working-buffer).
During evaluations, the values of the variables *, **, and ***
are the results of the previous, second previous and third previous
evaluations respectively. If the working buffer is another IELM
buffer, then the values in the working buffer are used. The variables
*1, *2 and *3, yield the process buffer values.
If, at the start of evaluation, standard-output is t (the
default), standard-output is set to a special function that
causes output to be directed to the ielm buffer.
standard-output is restored after evaluation unless explicitly
set to a different value during evaluation. You can use (princ
VALUE) or (pp VALUE) to write to the ielm buffer.
The behavior of IELM may be customized with the following variables:
* To stop beeping on error, set ielm-noisy to nil.
* If you don't like the prompt, you can change it by setting ielm-prompt.
* If you do not like that the prompt is (by default) read-only, set
ielm-prompt-read-only to nil.
* Set ielm-dynamic-return to nil for bindings like lisp-interaction-mode.
* Entry to this mode runs comint-mode-hook and ielm-mode-hook
(in that order).
Customized bindings may be defined in ielm-map, which currently contains:
C-M-i completion-at-point
C-M-q indent-sexp
C-M-x eval-defun
C-c C-b ielm-change-working-buffer
C-c C-f ielm-display-working-buffer
C-c C-v ielm-print-working-buffer
C-j ielm-send-input
DEL backward-delete-char-untabify
M-RET ielm-return-for-effect
RET ielm-return
TAB ielm-tab
In addition to any hooks its parent mode might have run, this mode runs
the hook inferior-emacs-lisp-mode-hook, as the final or penultimate
step during initialization.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/ielm.el.gz
;;; Major mode
(define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM"
"Major mode for interactively evaluating Emacs Lisp expressions.
Uses the interface provided by `comint-mode' (which see).
* \\<ielm-map>\\[ielm-send-input] evaluates the sexp following the prompt. There must be at most
one top level sexp per prompt.
* \\[ielm-return] inserts a newline and indents, or evaluates a
complete expression (but see variable `ielm-dynamic-return').
Inputs longer than one line are moved to the line following the
prompt (but see variable `ielm-dynamic-multiline-inputs').
* \\[ielm-return-for-effect] works like `ielm-return', except
that it doesn't print the result of evaluating the input. This
functionality is useful when forms would generate voluminous
output.
* \\[completion-at-point] completes Lisp symbols (or filenames, within strings),
or indents the line if there is nothing to complete.
The current working buffer may be changed (with a call to `set-buffer',
or with \\[ielm-change-working-buffer]), and its value is preserved between successive
evaluations. In this way, expressions may be evaluated in a different
buffer than the *ielm* buffer. By default, its name is shown on the
mode line; you can always display it with \\[ielm-print-working-buffer], or the buffer itself
with \\[ielm-display-working-buffer].
During evaluations, the values of the variables `*', `**', and `***'
are the results of the previous, second previous and third previous
evaluations respectively. If the working buffer is another IELM
buffer, then the values in the working buffer are used. The variables
`*1', `*2' and `*3', yield the process buffer values.
If, at the start of evaluation, `standard-output' is t (the
default), `standard-output' is set to a special function that
causes output to be directed to the ielm buffer.
`standard-output' is restored after evaluation unless explicitly
set to a different value during evaluation. You can use (princ
VALUE) or (pp VALUE) to write to the ielm buffer.
The behavior of IELM may be customized with the following variables:
* To stop beeping on error, set `ielm-noisy' to nil.
* If you don't like the prompt, you can change it by setting `ielm-prompt'.
* If you do not like that the prompt is (by default) read-only, set
`ielm-prompt-read-only' to nil.
* Set `ielm-dynamic-return' to nil for bindings like `lisp-interaction-mode'.
* Entry to this mode runs `comint-mode-hook' and `ielm-mode-hook'
(in that order).
Customized bindings may be defined in `ielm-map', which currently contains:
\\{ielm-map}"
:syntax-table emacs-lisp-mode-syntax-table
:after-hook
(and (null comint-use-prompt-regexp)
ielm-fontify-input-enable
(comint-fontify-input-mode))
(setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt)))
(setq-local paragraph-separate "\\'")
(setq-local paragraph-start comint-prompt-regexp)
(setq comint-input-sender 'ielm-input-sender)
(setq comint-process-echoes nil)
(dolist (f '(elisp-completion-at-point
ielm-complete-filename
comint-replace-by-expanded-history))
(add-hook 'completion-at-point-functions f nil t))
(add-hook 'eldoc-documentation-functions
#'elisp-eldoc-var-docstring nil t)
(add-hook 'eldoc-documentation-functions
#'elisp-eldoc-funcall nil t)
(setq-local ielm-prompt-internal ielm-prompt)
(setq-local comint-prompt-read-only ielm-prompt-read-only)
(setq comint-get-old-input 'ielm-get-old-input)
(setq-local comint-completion-addsuffix '("/" . ""))
(setq mode-line-process '(":%s on " (:eval (buffer-name ielm-working-buffer))))
;; Useful for `hs-minor-mode'.
(setq-local comment-start ";")
(setq-local comment-use-syntax t)
(setq-local lexical-binding t)
(add-function :around (local 'cl-print-expand-ellipsis-function)
#'ielm--expand-ellipsis)
(setq-local indent-line-function #'ielm-indent-line)
(setq-local ielm-working-buffer (current-buffer))
(setq-local fill-paragraph-function #'lisp-fill-paragraph)
;; Value holders
(setq-local * nil)
(setq-local ** nil)
(setq-local *** nil)
(setq-local ielm-match-data nil)
;; font-lock support
(setq-local font-lock-defaults
'(ielm-font-lock-keywords nil nil ((?: . "w") (?- . "w") (?* . "w"))))
(add-hook 'comint-indirect-setup-hook
#'ielm-indirect-setup-hook 'append t)
(setq comint-indirect-setup-function #'emacs-lisp-mode)
;; Input history
(setq-local comint-input-ring-file-name ielm-history-file-name)
(setq-local ielm--exit (ielm--input-history-writer (current-buffer)))
(setq-local kill-buffer-hook
(lambda ()
(funcall ielm--exit)
(remove-hook 'kill-emacs-hook ielm--exit)))
(unless noninteractive
(add-hook 'kill-emacs-hook ielm--exit))
(comint-read-input-ring t)
;; A dummy process to keep comint happy. It will never get any input
(unless (comint-check-proc (current-buffer))
;; Was cat, but on non-Unix platforms that might not exist, so
;; use hexl instead, which is part of the Emacs distribution.
(condition-case nil
(start-process "ielm" (current-buffer) hexl-program-name)
(file-error (start-process "ielm" (current-buffer) "cat")))
(set-process-query-on-exit-flag (ielm-process) nil)
(goto-char (point-max))
;; Lisp output can include raw characters that confuse comint's
;; carriage control code.
(setq-local comint-inhibit-carriage-motion t)
;; Add a silly header
(insert (substitute-command-keys ielm-header))
(ielm-set-pm (point-max))
(unless comint-use-prompt-regexp
(let ((inhibit-read-only t))
(add-text-properties
(point-min) (point-max)
'(rear-nonsticky t field output inhibit-line-move-field-capture t))))
(comint-output-filter (ielm-process) ielm-prompt-internal)
(set-marker comint-last-input-start (ielm-pm))
(set-process-filter (get-buffer-process (current-buffer))
'comint-output-filter)
(add-hook 'interrupt-process-functions
#'ielm--write-history-on-interrupt -1 t)))