]> git.eshelyaron.com Git - emacs.git/commitdiff
Implemented python-indent-electric-colon
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:04 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:04 +0000 (00:03 -0300)
lisp/progmodes/python.el

index 564638c1b58d17d4c4cb4f456fb4ca3794649fc9..76546aa97993d4f6eced9ac004a4f3e966683be2 100644 (file)
     (define-key map (kbd "<backtab>") '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)
+
 \f
 ;;; Navigation