From: Fabián Ezequiel Gallina Date: Thu, 17 May 2012 03:03:04 +0000 (-0300) Subject: Implemented python-indent-electric-colon X-Git-Tag: emacs-24.2.90~1199^2~598 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ffdb56c385f40e22031828cf08b7dd8482aea109;p=emacs.git Implemented python-indent-electric-colon --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 564638c1b58..76546aa9799 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -142,6 +142,7 @@ (define-key map (kbd "") 'python-indent-dedent-line) (define-key map "\C-c<" 'python-indent-shift-left) (define-key map "\C-c>" 'python-indent-shift-right) + (define-key map ":" 'python-indent-electric-colon) ;; Shell interaction (define-key map "\C-c\C-s" 'python-shell-send-string) (define-key map "\C-c\C-r" 'python-shell-send-region) @@ -786,6 +787,19 @@ lie." (setq count python-indent-offset)) (indent-rigidly start end count)) +;; Directly from Dave Love's python.el +(defun python-indent-electric-colon (arg) + "Insert a colon and maybe outdent the line if it is a statement like `else'. +With numeric ARG, just insert that many colons. With \\[universal-argument], +just insert a single colon." + (interactive "*P") + (self-insert-command (if (not (integerp arg)) 1 arg)) + (and (not arg) + (eolp) + (not (nth 8 (syntax-ppss))) + (save-excursion (python-indent-line)))) +(put 'python-indent-electric-colon 'delete-selection t) + ;;; Navigation