0

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?

Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
Lorenzo Trojan
  • 117
  • 1
  • 9
  • `M-r`, which is short for `M-x comint-history-isearch-backward-regexp` may be what you are looking for. – unutbu Jun 22 '15 at 19:24
  • @unutbu just tried it... well, it kind of works, maybe not as quick as the behaviour of the normal ipython shell... whould you know what's the command that is boud to C^ArrowUp? – Lorenzo Trojan Jun 22 '15 at 19:34
  • I'm not familiar with `C^ArrowUp` (perhaps because I don't use elpy?). But you should be able to find out what function it is bound to by pressing `C-h k` `C^ArrowUp`. Or, you can peruse `C-h b`, which shows all the key bindings understood by the current buffer. – unutbu Jun 22 '15 at 19:37

1 Answers1

1

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.

Chillar Anand
  • 27,936
  • 9
  • 119
  • 136