[IPython-user] Re: ipython.el + pdb rocks!!!

Alexander Schmolck a.schmolck at gmx.net
Fri Feb 11 12:18:36 CST 2005


Fernando Perez <Fernando.Perez at colorado.edu> writes:

Hi Fernando,

> Hey Alex,
>
> [cc-ed to the list, in case someone else wants to try this out and have the
> same epiphany I've had today]
>
> I can't thank you enough for ipython.el and the pdb integration.  I know I
> should have tried this long ago, you'd said as much.

Yes, I think it's one of the major benefits of using emacs and ipython over
other solutions (not that it required much originality or work on my part --
just integration) -- it's a pitty that even amongst users of both ipython and
emacs many don't seem to be aware of this feature -- sort of makes me wonder
how many really useful things I'm missing out on.

> ps. Now that I've suckered up to you, let me ask a question: the one thing
> that's annoying me is keyboard management.  In a terminal, ctrl p/n do
> previous/next _only_ in the history that matches the current line.  Is it
> possible to rebind the keys in Xemacs so that, in an ipython buffer, you get
> also ctrl p/n to do history matching (like ctrl up/down do?).  I'm OK with
> losing ctrl p/n for moving the text caret, the arrow keys still do that.  It's
> just that my muscle memory is tripping me badly, when  I switch from ipython
> in a terminal to ipython in an emacs buffer.

I use the following (just change ``meta`` to ``control` in the first 2
keybindings to get the behaviour you want; I find it useful leave C-p as
previous-line, because I not infrequently walk around in command output or
copy and paste stuff etc.)

    (require 'comint)
    (define-key comint-mode-map [(meta p)] 
      'comint-previous-matching-input-from-input)
    (define-key comint-mode-map [(meta n)] 
      'comint-next-matching-input-from-input)
    (define-key comint-mode-map [(control meta n)]
       'comint-next-input)
    (define-key comint-mode-map [(control meta p)]
       'comint-previous-input)


Two notes: 

1. I think this should also work under Xemacs, but I'm mostly using emacs, so
   I can't guarantee

2. I've got this in some special part of my config (it's done pretty much
   before everything else), but I can't remember why -- maybe some other
   package I use for some reasons tries to override these keybindings for some
   obscure reason -- I mention that just in case you find adding the above has
   no discernible effect.

Tell me if it works 0K for you then I'll presumably add it as a tip to the
commentary of ipython.el.

alex




More information about the IPython-user mailing list