(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and

C-c C-l respectively.
This commit is contained in:
Barry Warsaw 1995-03-15 16:23:59 +00:00
parent 00198bef6a
commit 1a6c82f1e6
1 changed files with 41 additions and 0 deletions

View File

@ -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 ()