Hi Barry,
herewith a function I'm used to when editing and didn't want miss it in
python-mode.
Maybe have a look, if it seems useful for others too.
Needs
(require 'beg-end)
(require 'thing-at-point-utils)
(require 'thingatpt-utils-base)
from https://code.launchpad.net/s-x-emacs-werkstatt/
which are present already in branches:
lp:~a-roehler/python-mode/paragraph-fill-warts
lp:~a-roehler/python-mode/python-mode-components
;
;; (define-key py-mode-map [(%)] 'py-match-paren)
(defun py-match-paren (arg)
Go to the matching brace, bracket or parenthesis if on its counterpart.
Otherwise insert the character, the key is assigned to, here `%'.
With universal arg \C-u insert a `%'.
(interactive P)
(if arg
(self-insert-command (if (numberp arg) arg 1))
(cond
((looking-at ()
(goto-char (ar-parentized-end-position-atpt))
(backward-char 1))
((looking-at ))
(goto-char (ar-parentized-beginning-position-atpt)))
((looking-at \\\[)
(goto-char (ar-bracketed-end-position-atpt))
(backward-char 1))
((looking-at ])
(goto-char (ar-bracketed-beginning-position-atpt)))
((looking-at {)
(goto-char (ar-braced-end-position-atpt))
(backward-char 1))
((looking-at })
(goto-char (ar-braced-beginning-position-atpt)))
(t (self-insert-command 1))
___
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode