aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-05-17 00:03:04 -0300
committerFabián Ezequiel Gallina2012-05-17 00:03:04 -0300
commitffdb56c385f40e22031828cf08b7dd8482aea109 (patch)
treee7b6c1dbfc618dfc2898b05a779138b0cc9c5003
parent17d13b85268a6b864e92af05cb8f0ed4461e3cc5 (diff)
downloademacs-ffdb56c385f40e22031828cf08b7dd8482aea109.tar.gz
emacs-ffdb56c385f40e22031828cf08b7dd8482aea109.zip
Implemented python-indent-electric-colon
-rw-r--r--lisp/progmodes/python.el14
1 files changed, 14 insertions, 0 deletions
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 @@
142 (define-key map (kbd "<backtab>") 'python-indent-dedent-line) 142 (define-key map (kbd "<backtab>") 'python-indent-dedent-line)
143 (define-key map "\C-c<" 'python-indent-shift-left) 143 (define-key map "\C-c<" 'python-indent-shift-left)
144 (define-key map "\C-c>" 'python-indent-shift-right) 144 (define-key map "\C-c>" 'python-indent-shift-right)
145 (define-key map ":" 'python-indent-electric-colon)
145 ;; Shell interaction 146 ;; Shell interaction
146 (define-key map "\C-c\C-s" 'python-shell-send-string) 147 (define-key map "\C-c\C-s" 'python-shell-send-string)
147 (define-key map "\C-c\C-r" 'python-shell-send-region) 148 (define-key map "\C-c\C-r" 'python-shell-send-region)
@@ -786,6 +787,19 @@ lie."
786 (setq count python-indent-offset)) 787 (setq count python-indent-offset))
787 (indent-rigidly start end count)) 788 (indent-rigidly start end count))
788 789
790;; Directly from Dave Love's python.el
791(defun python-indent-electric-colon (arg)
792 "Insert a colon and maybe outdent the line if it is a statement like `else'.
793With numeric ARG, just insert that many colons. With \\[universal-argument],
794just insert a single colon."
795 (interactive "*P")
796 (self-insert-command (if (not (integerp arg)) 1 arg))
797 (and (not arg)
798 (eolp)
799 (not (nth 8 (syntax-ppss)))
800 (save-excursion (python-indent-line))))
801(put 'python-indent-electric-colon 'delete-selection t)
802
789 803
790;;; Navigation 804;;; Navigation
791 805