Lorenzo Trojan
Lorenzo Trojan

Reputation: 117

Emacs - Python completion in inferior shell with partially typed command

A feature that I tend to use quite often in the ipython shell is auto-completion of partially typed command from the history. At the repl, one can type only the first few letters of the command and hit the up to find in the command history the last executed command that begin with the partially typed string.

Is this feature available in emacs? by pressing C-up, the python command history can be recalled, but it does not use the partially typed command?

Upvotes: 0

Views: 768

Answers (1)

Chillar Anand
Chillar Anand

Reputation: 29594

You can get completion for partially typed commands using comint-previous-matching-input-from-input and comint-next-matching-input-from-input.

By default they are bind to C-c M-r and C-c M-s.

If you have typed l = 1 and now you can typel and press C-c M-r to get previous completion.

If you dont want to use C-c M-r and like to use up arrow, you put this code in your config.

(eval-after-load 'comint
    '(progn      
         (define-key comint-mode-map (kbd "<up>") 
            #'comint-previous-matching-input-from-input)
         (define-key comint-mode-map (kbd "<down>")
            #'comint-next-matching-input-from-input)))

Now you can use up/down arrows for it.

Upvotes: 1

Related Questions