|
6 | 6 | ;; 1992-1994 Tim Peters <[email protected]> |
7 | 7 | |
8 | 8 | ;; Created: Feb 1992 |
9 | | -;; Version: 2.13 |
10 | | -;; Last Modified: 1995/03/14 22:05:53 |
| 9 | +;; Version: 2.16 |
| 10 | +;; Last Modified: 1995/03/15 16:23:59 |
11 | 11 | ;; Keywords: python editing language major-mode |
12 | 12 |
|
13 | 13 | ;; This software is provided as-is, without express or implied |
|
48 | 48 | ;; - proper interaction with pending-del and del-sel modes. |
49 | 49 | ;; - New py-electric-colon (:) command for improved outdenting. Also |
50 | 50 | ;; py-indent-line (TAB) should handle outdented lines better. |
| 51 | +;; - New commands py-outdent-left (C-c C-l) and py-indent-right (C-c C-r) |
51 | 52 |
|
52 | 53 | ;; Here's a brief to do list: |
53 | 54 | ;; |
|
68 | 69 | ;; LCD Archive Entry: |
69 | 70 | ;; python-mode|Barry A. Warsaw|[email protected] |
70 | 71 | ;; |Major mode for editing Python programs |
71 | | -;; |1995/03/14 22:05:53|2.13| |
| 72 | +;; |1995/03/15 16:23:59|2.16| |
72 | 73 |
|
73 | 74 | ;;; Code: |
74 | 75 |
|
@@ -247,6 +248,8 @@ Currently-active file is at the head of the list.") |
247 | 248 | ("\n" . py-newline-and-indent) |
248 | 249 | ("\C-c:" . py-guess-indent-offset) |
249 | 250 | ("\C-c\t" . py-indent-region) |
| 251 | + ("\C-c\C-l" . py-outdent-left) |
| 252 | + ("\C-c\C-r" . py-indent-right) |
250 | 253 | ("\C-c<" . py-shift-region-left) |
251 | 254 | ("\C-c>" . py-shift-region-right) |
252 | 255 | ("\C-c\C-n" . py-next-statement) |
@@ -319,7 +322,7 @@ Currently-active file is at the head of the list.") |
319 | 322 |
|
320 | 323 | (defconst py-no-outdent-re |
321 | 324 | (concat "\\(" (mapconcat 'identity |
322 | | - '("try\\s +.*:" |
| 325 | + '("try:" |
323 | 326 | "except\\(\\s +.*\\)?:" |
324 | 327 | "while\\s +.*:" |
325 | 328 | "for\\s +.*:" |
@@ -433,11 +436,53 @@ argument is provided, that many colons are inserted non-electrically." |
433 | 436 | (py-compute-indentation))) |
434 | 437 | ) |
435 | 438 | (setq outdent py-indent-offset)) |
436 | | - (goto-char here) |
437 | | - (beginning-of-line) |
438 | | - (delete-horizontal-space) |
439 | | - (indent-to (- indent outdent)) |
440 | | - ))) |
| 439 | + ;; electric colon won't re-indent lines that start in column |
| 440 | + ;; zero. you'd have to use TAB for that. TBD: Is there a |
| 441 | + ;; better way to determine this??? |
| 442 | + (if (zerop (current-indentation)) nil |
| 443 | + (goto-char here) |
| 444 | + (beginning-of-line) |
| 445 | + (delete-horizontal-space) |
| 446 | + (indent-to (- indent outdent)) |
| 447 | + )))) |
| 448 | + |
| 449 | +(defun py-indent-right (arg) |
| 450 | + "Indent the line by one `py-indent-offset' level. |
| 451 | +With numeric arg, indent by that many levels. You cannot indent |
| 452 | +farther right than the distance the line would be indented by |
| 453 | +\\[py-indent-line]." |
| 454 | + (interactive "p") |
| 455 | + (let ((col (current-indentation)) |
| 456 | + (want (* arg py-indent-offset)) |
| 457 | + (indent (py-compute-indentation)) |
| 458 | + (pos (- (point-max) (point))) |
| 459 | + (bol (save-excursion (beginning-of-line) (point)))) |
| 460 | + (if (<= (+ col want) indent) |
| 461 | + (progn |
| 462 | + (beginning-of-line) |
| 463 | + (delete-horizontal-space) |
| 464 | + (indent-to (+ col want)) |
| 465 | + (if (> (- (point-max) pos) (point)) |
| 466 | + (goto-char (- (point-max) pos))) |
| 467 | + )))) |
| 468 | + |
| 469 | +(defun py-outdent-left (arg) |
| 470 | + "Outdent the line by one `py-indent-offset' level. |
| 471 | +With numeric arg, outdent by that many levels. You cannot outdent |
| 472 | +farther left than column zero." |
| 473 | + (interactive "p") |
| 474 | + (let ((col (current-indentation)) |
| 475 | + (want (* arg py-indent-offset)) |
| 476 | + (pos (- (point-max) (point))) |
| 477 | + (bol (save-excursion (beginning-of-line) (point)))) |
| 478 | + (if (<= 0 (- col want)) |
| 479 | + (progn |
| 480 | + (beginning-of-line) |
| 481 | + (delete-horizontal-space) |
| 482 | + (indent-to (- col want)) |
| 483 | + (if (> (- (point-max) pos) (point)) |
| 484 | + (goto-char (- (point-max) pos))) |
| 485 | + )))) |
441 | 486 |
|
442 | 487 |
|
443 | 488 | ;;; Functions that execute Python commands in a subprocess |
@@ -1863,7 +1908,7 @@ local bindings to py-newline-and-indent.")) |
1863 | 1908 | (setq zmacs-region-stays t))) |
1864 | 1909 |
|
1865 | 1910 |
|
1866 | | -(defconst py-version "2.13" |
| 1911 | +(defconst py-version "2.16" |
1867 | 1912 | "`python-mode' version number.") |
1868 | 1913 | ( defconst py-help-address "[email protected]" |
1869 | 1914 | "Address accepting submission of bug reports.") |
|
0 commit comments