summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-14 21:31:47 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-14 21:31:47 (GMT)
commit1d5645d727c97cc95028777ef173e5ad79d55116 (patch)
treed1be5cc94a26fb67780c2d396c87cdcbcfd1098c
parent4f009fb092aceb7bb9d85319b541e4e22e54977f (diff)
downloadcpython-1d5645d727c97cc95028777ef173e5ad79d55116.zip
cpython-1d5645d727c97cc95028777ef173e5ad79d55116.tar.gz
cpython-1d5645d727c97cc95028777ef173e5ad79d55116.tar.bz2
Barry's version 2.11 -- electric colon
-rw-r--r--Misc/python-mode-old.el78
1 files changed, 68 insertions, 10 deletions
diff --git a/Misc/python-mode-old.el b/Misc/python-mode-old.el
index 33f32f4..3560669 100644
--- a/Misc/python-mode-old.el
+++ b/Misc/python-mode-old.el
@@ -6,8 +6,8 @@
;; 1992-1994 Tim Peters <tim@ksr.com>
;; Maintainer: bwarsaw@cnri.reston.va.us
;; Created: Feb 1992
-;; Version: 2.7
-;; Last Modified: 1995/03/10 15:58:16
+;; Version: 2.11
+;; Last Modified: 1995/03/14 18:32:54
;; Keywords: python editing language major-mode
;; This software is provided as-is, without express or implied
@@ -36,10 +36,27 @@
;; (setq auto-mode-alist
;; (cons '("\\.py$" . python-mode) auto-mode-alist))
+;; Here's a brief list of recent additions/improvements:
+;;
+;; - Wrapping and indentation within triple quote strings should work
+;; properly now.
+;; - `Standard' bug reporting mechanism (use C-c C-b)
+;; - py-mark-block was moved to C-c C-m
+;; - C-c C-v shows you the python-mode version
+;; - a basic python-font-lock-keywords has been added for Emacs 19
+;; font-lock colorizations.
+;; - 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.
+
;; Here's a brief to do list:
;;
-;; 1. Better integration with gud-mode for debugging.
-;; 2. Rewrite according to GNU Emacs Lisp standards.
+;; - Better integration with gud-mode for debugging.
+;; - Rewrite according to GNU Emacs Lisp standards.
+;; - py-delete-char should obey numeric arguments.
+;; - even better support for outdenting. Guido suggests outdents of
+;; at least one level after a return, raise, break, or continue
+;; statement.
;; If you can think of more things you'd like to see, drop me a line.
;; If you want to report bugs, use py-submit-bug-report (C-c C-b).
@@ -51,7 +68,7 @@
;; LCD Archive Entry:
;; python-mode|Barry A. Warsaw|bwarsaw@cnri.reston.va.us
;; |Major mode for editing Python programs
-;; |1995/03/10 15:58:16|2.7|
+;; |1995/03/14 18:32:54|2.11|
;;; Code:
@@ -222,7 +239,8 @@ Currently-active file is at the head of the list.")
(mapcar (function
(lambda (x)
(define-key py-mode-map (car x) (cdr x))))
- '(("\C-c\C-c" . py-execute-buffer)
+ '((":" . py-electric-colon)
+ ("\C-c\C-c" . py-execute-buffer)
("\C-c|" . py-execute-region)
("\C-c!" . py-shell)
("\177" . py-delete-char)
@@ -289,6 +307,15 @@ Currently-active file is at the head of the list.")
(defconst py-blank-or-comment-re "[ \t]*\\($\\|#\\)"
"Regexp matching blank or comment lines.")
+(defconst py-outdent-re
+ (concat "\\(" (mapconcat 'identity
+ '("else:"
+ "except\\s +.*:"
+ "finally:"
+ "elif\\s +.*:")
+ "\\|")
+ "\\)")
+ "Regexp matching clauses to be outdented one level.")
;;;###autoload
@@ -363,6 +390,30 @@ py-beep-if-tab-change\tring the bell if tab-width is changed"
(run-hooks 'py-mode-hook)))
+;; electric characters
+(defun py-electric-colon (arg)
+ "Insert a colon.
+In certain cases the line is outdented appropriately. If a numeric
+argument is provided, that many colons are inserted non-electrically."
+ (interactive "P")
+ (self-insert-command (prefix-numeric-value arg))
+ (let (this-indent)
+ (if (and (not arg)
+ (save-excursion
+ (back-to-indentation)
+ (looking-at py-outdent-re))
+ (= (setq this-indent (py-compute-indentation))
+ (save-excursion
+ (forward-line -1)
+ (py-compute-indentation)))
+ )
+ (save-excursion
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (indent-to (- this-indent py-indent-offset)))
+ )))
+
+
;;; Functions that execute Python commands in a subprocess
(defun py-shell ()
"Start an interactive Python interpreter in another window.
@@ -578,7 +629,12 @@ needed so that only a single column position is deleted."
(interactive)
(let* ((ci (current-indentation))
(move-to-indentation-p (<= (current-column) ci))
- (need (py-compute-indentation)) )
+ (need (py-compute-indentation)))
+ ;; watch for outdents
+ (if (save-excursion
+ (back-to-indentation)
+ (looking-at py-outdent-re))
+ (setq need (- need py-indent-offset)))
(if (/= ci need)
(save-excursion
(beginning-of-line)
@@ -1783,7 +1839,7 @@ local bindings to py-newline-and-indent."))
(setq zmacs-region-stays t)))
-(defconst py-version "2.7"
+(defconst py-version "2.11"
"`python-mode' version number.")
(defconst py-help-address "bwarsaw@cnri.reston.va.us"
"Address accepting submission of bug reports.")
@@ -1804,11 +1860,13 @@ With \\[universal-argument] just submit an enhancement request."
(interactive
(list (not (y-or-n-p
"Is this a bug report? (hit `n' to send other comments) "))))
- (let ((reporter-prompt-for-summary-p (not enhancement-p)))
+ (let ((reporter-prompt-for-summary-p (if enhancement-p
+ "(Very) brief summary: "
+ t)))
(require 'reporter)
(reporter-submit-bug-report
py-help-address ;address
- "python-mode" ;pkgname
+ (concat "python-mode " py-version) ;pkgname
;; varlist
(if enhancement-p nil
'(py-python-command