summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1995-03-15 16:23:59 (GMT)
committerBarry Warsaw <barry@python.org>1995-03-15 16:23:59 (GMT)
commit1a6c82f1e63b97c37f3362d9d91195bab203a923 (patch)
tree7faacad47bf544bcfee8c1ed8cdf6b15016bf3df
parent00198bef6a8c40669640299d47d2e69c77fd8414 (diff)
downloadcpython-1a6c82f1e63b97c37f3362d9d91195bab203a923.zip
cpython-1a6c82f1e63b97c37f3362d9d91195bab203a923.tar.gz
cpython-1a6c82f1e63b97c37f3362d9d91195bab203a923.tar.bz2
(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and
C-c C-l respectively.
-rw-r--r--Misc/python-mode.el41
1 files changed, 41 insertions, 0 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index ec2b5cb..be08e00 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -48,6 +48,7 @@
;; - proper interaction with pending-del and del-sel modes.
;; - New py-electric-colon (:) command for improved outdenting. Also
;; py-indent-line (TAB) should handle outdented lines better.
+;; - New commands py-outdent-left (C-c C-l) and py-indent-right (C-c C-r)
;; Here's a brief to do list:
;;
@@ -247,6 +248,8 @@ Currently-active file is at the head of the list.")
("\n" . py-newline-and-indent)
("\C-c:" . py-guess-indent-offset)
("\C-c\t" . py-indent-region)
+ ("\C-c\C-l" . py-outdent-left)
+ ("\C-c\C-r" . py-indent-right)
("\C-c<" . py-shift-region-left)
("\C-c>" . py-shift-region-right)
("\C-c\C-n" . py-next-statement)
@@ -443,6 +446,44 @@ argument is provided, that many colons are inserted non-electrically."
(indent-to (- indent outdent))
))))
+(defun py-indent-right (arg)
+ "Indent the line by one `py-indent-offset' level.
+With numeric arg, indent by that many levels. You cannot indent
+farther right than the distance the line would be indented by
+\\[py-indent-line]."
+ (interactive "p")
+ (let ((col (current-indentation))
+ (want (* arg py-indent-offset))
+ (indent (py-compute-indentation))
+ (pos (- (point-max) (point)))
+ (bol (save-excursion (beginning-of-line) (point))))
+ (if (<= (+ col want) indent)
+ (progn
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (indent-to (+ col want))
+ (if (> (- (point-max) pos) (point))
+ (goto-char (- (point-max) pos)))
+ ))))
+
+(defun py-outdent-left (arg)
+ "Outdent the line by one `py-indent-offset' level.
+With numeric arg, outdent by that many levels. You cannot outdent
+farther left than column zero."
+ (interactive "p")
+ (let ((col (current-indentation))
+ (want (* arg py-indent-offset))
+ (pos (- (point-max) (point)))
+ (bol (save-excursion (beginning-of-line) (point))))
+ (if (<= 0 (- col want))
+ (progn
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (indent-to (- col want))
+ (if (> (- (point-max) pos) (point))
+ (goto-char (- (point-max) pos)))
+ ))))
+
;;; Functions that execute Python commands in a subprocess
(defun py-shell ()