4

I can't seem to get indentation working properly in the REPLs I've used so far (IELM, MIT-Scheme, and Python).

Suppose I type the following and RET:

ELISP> (defun something ()
_

My cursor ends up at the underscore, and pressing TAB doesn't seem to do anything. The same thing happens with the MIT-Scheme REPL.

To be explicit, I'd like to have it automatically indent it like so:

ELISP> (defun something ()
         _

In IELM, TAB is bound to ielm-tab which is supposed to "Indent or complete". The function calls ielm-indent-line at the beginning of a line. Calling ielm-indent-line directly does not indent the line as advertised.

In the Python REPL, it does indent just enough to get past the prompt, but not more. For example:

>>> def something():
... _

I was hoping to be able to have the Python REPL automatically indent like in regular Python files. The mode description doesn't seem to turn up any relevant results for 'indent'.

electric-indent-mode is enabled in all cases. Would anybody know what I'm missing?

Edit: I noticed that ielm-indent-line is supposed to (but evidently does not) call lisp-indent-line. Calling lisp-indent-line directly does work in IELM, but not Inferior Scheme/MIT-Scheme. Calling python-indent-line in the Python REPL also does not work.

  • FWIW, I have run into this issue as well, which, at first glance, looks like an Emacs24-specific bug, as IELM indentation works OOTB in both 23 and 25. – Basil Sep 15 '17 at 16:24
1

A combination of changes in ielm and comint from Emacs 23 to 24 introduced what looks like a bug in determining the position of the start of a comint-derived line, which in turn affects whether indentation is attempted in ielm. This bug seems to have been fixed in Emacs 25.

Compare the definition of ielm-indent-line in Emacs 23 and 24:

(defun ielm-indent-line nil
  "Indent the current line as Lisp code if it is not a prompt line."
  (when (save-excursion (comint-bol) (bolp))
    (lisp-indent-line)))

with that in Emacs 25:

(defun ielm-indent-line nil
  "Indent the current line as Lisp code if it is not a prompt line."
  (when (save-excursion (comint-bol t) (bolp))
    (lisp-indent-line)))

I haven't investigated what happens in other REPLs, but anything derived from comint could conceivably suffer from a similar issue. Evaluating the Emacs 25 definition of ielm-indent-line in Emacs 24 resolved the indentation issues I was seeing in ielm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.