Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d97cc37

Browse files
committed
barry's 2.13 -- minor reworking of code (added py-outdent-p)
1 parent d865bc5 commit d97cc37

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

Misc/python-mode-old.el

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
;; 1992-1994 Tim Peters <[email protected]>
77
;; Maintainer: [email protected]
88
;; Created: Feb 1992
9-
;; Version: 2.12
10-
;; Last Modified: 1995/03/14 20:53:08
9+
;; Version: 2.13
10+
;; Last Modified: 1995/03/14 22:05:53
1111
;; Keywords: python editing language major-mode
1212

1313
;; This software is provided as-is, without express or implied
@@ -68,7 +68,7 @@
6868
;; LCD Archive Entry:
6969
;; python-mode|Barry A. Warsaw|[email protected]
7070
;; |Major mode for editing Python programs
71-
;; |1995/03/14 20:53:08|2.12|
71+
;; |1995/03/14 22:05:53|2.13|
7272

7373
;;; Code:
7474

@@ -403,6 +403,19 @@ py-beep-if-tab-change\tring the bell if tab-width is changed"
403403

404404

405405
;; electric characters
406+
(defun py-outdent-p ()
407+
;; returns non-nil if the current line should outdent one level
408+
(save-excursion
409+
(and (progn (back-to-indentation)
410+
(looking-at py-outdent-re))
411+
(progn (backward-to-indentation 1)
412+
(while (or (looking-at py-blank-or-comment-re)
413+
(bobp))
414+
(backward-to-indentation 1))
415+
(not (looking-at py-no-outdent-re)))
416+
)))
417+
418+
406419
(defun py-electric-colon (arg)
407420
"Insert a colon.
408421
In certain cases the line is outdented appropriately. If a numeric
@@ -414,13 +427,7 @@ argument is provided, that many colons are inserted non-electrically."
414427
(outdent 0)
415428
(indent (py-compute-indentation)))
416429
(if (and (not arg)
417-
(progn
418-
(back-to-indentation)
419-
(looking-at py-outdent-re))
420-
(prog2
421-
(backward-to-indentation 1)
422-
(not (looking-at py-no-outdent-re))
423-
(goto-char here))
430+
(py-outdent-p)
424431
(= indent (progn
425432
(forward-line -1)
426433
(py-compute-indentation)))
@@ -650,11 +657,7 @@ needed so that only a single column position is deleted."
650657
(move-to-indentation-p (<= (current-column) ci))
651658
(need (py-compute-indentation)))
652659
;; see if we need to outdent
653-
(if (save-excursion
654-
(and (progn (back-to-indentation)
655-
(looking-at py-outdent-re))
656-
(progn (backward-to-indentation 1)
657-
(not (looking-at py-no-outdent-re)))))
660+
(if (py-outdent-p)
658661
(setq need (- need py-indent-offset)))
659662
(if (/= ci need)
660663
(save-excursion
@@ -1860,7 +1863,7 @@ local bindings to py-newline-and-indent."))
18601863
(setq zmacs-region-stays t)))
18611864

18621865

1863-
(defconst py-version "2.12"
1866+
(defconst py-version "2.13"
18641867
"`python-mode' version number.")
18651868
(defconst py-help-address "[email protected]"
18661869
"Address accepting submission of bug reports.")

0 commit comments

Comments
 (0)