Like suggested in this question How to automatically run inferior process when loading major mode for the first time? I want to automatically run run-python
when entering python major mode. However,
(add-hook 'python-mode-hook 'run-python)
doesn't work and gives the error
Wrong number of arguments: (1 . 3), 0
Which argument is needed by run-python
? How to automatically start an inferior python interpreter when entering python-mode
?
Edit: After M-x
toggle-debug-on-error
the output gives
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 3) 0)
run-python()
run-hooks(change-major-mode-after-body-hook prog-mode-hook python-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook python-mode-hook))
run-mode-hooks(python-mode-hook)
python-mode()
call-interactively(python-mode record nil)
command-execute(python-mode record)
execute-extended-command(nil "python-mode")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
run-python
doesn't require any arguments, at least not in the version of Emacs that I have. You could doC-h f
run-python
to see what's the function signature you have, though I'm almost sure the error comes from some other place.M-x toggle-debug-on-error
would help to find the problem.24.5.1
and also tried an empty init.el with only(add-hook 'python-mode-hook 'run-python)
in it.C-h f
run-python
gives the signature(run-python CMD &optional DEDICATED SHOW)
. For debug output see edited question above. I tried an Emacs ver.23.4.1
on a different machine and indeed there is(add-hook 'python-mode-hook 'run-python)
working as expected.run-python
requiresCMD
argument... well, if that's the case you could change your code to(add-hook 'python-mode-hook (lambda () (run-python (python-shell-calculate-command)))
.