On 09 October 2002, Jonathan Corbet said:
> You gonna share your work? :) I've been meaning to do that for a long
> time, but I've been busy, and stock python.el is generally good enough, so
> I never got around to it...
Sorry, here's the patch. This is over a year old -- no idea if it'll
apply against a current python-mode.el. Guess I should put this on the
Quixote web site...
--- python-mode.el.orig Mon Jul 23 13:09:12 2001
+++ python-mode.el Fri Jul 27 14:29:30 2001
@@ -8,6 +8,9 @@
;; Created: Feb 1992
;; Keywords: python languages oop
+;; hacked GPW 2001/07/23 (yet another attempt to support PTL)
+;; 2001/07/27 (fixed so imenu regexes work with PTL and Python)
+
(defconst py-version "$Revision: 4.6 $"
"`python-mode' version number.")
@@ -311,7 +314,7 @@
"from" "global" "if" "import"
"in" "is" "lambda" "not"
"or" "pass" "print" "raise"
- "return" "while" "yield"
+ "template" "return" "while" "yield"
)
"\\|"))
(kw2 (mapconcat 'identity
@@ -409,7 +412,7 @@
"Regular expression matching lines not to dedent after.")
(defconst py-defun-start-re
- "^\\([ \t]*\\)def[ \t]+\\([a-zA-Z_0-9]+\\)\\|\\(^[a-zA-Z_0-9]+\\)[ \t]*="
+ "^\\([ \t]*\\)\\(def\\|template\\)[ \t]+\\([a-zA-Z_0-9]+\\)\\|\\(^[a-zA-
Z_0-9]+\\)[ \t]*="
;; If you change this, you probably have to change py-current-defun
;; as well. This is only used by py-current-defun to find the name
;; for add-log.el.
@@ -747,7 +750,7 @@
(concat ; <>
"\\(" ;
"^[ \t]*" ; new line and maybe whitespace
- "\\(def[ \t]+" ; function definitions start with def
+ "\\(\\(def\\|template\\)[ \t]+" ; function definitions start with def
"\\([a-zA-Z0-9_]+\\)" ; name is here
; function arguments...
;; "[ \t]*(\\([-+/a-zA-Z0-9_=,\* \t\n.()\"'#]*\\))"
@@ -759,7 +762,7 @@
"Regexp for Python methods/functions for use with the Imenu package."
)
-(defvar py-imenu-method-no-arg-parens '(2 8)
+(defvar py-imenu-method-no-arg-parens '(2 9)
"Indices into groups of the Python regexp for use with Imenu.
Using these values will result in smaller Imenu lists, as arguments to
@@ -2265,9 +2268,9 @@
(let ((at-or-before-p (<= (current-column) (current-indentation)))
(start-of-line (goto-char (py-point 'bol)))
(start-of-stmt (goto-char (py-point 'bos)))
- (start-re (cond ((eq class 'either) "^[ \t]*\\(class\\|def\\)\\>")
+ (start-re (cond ((eq class 'either) "^[
\t]*\\(class\\|def\\|template\\)\\>")
(class "^[ \t]*class\\>")
- (t "^[ \t]*def\\>")))
+ (t "^[ \t]*\\(def\\|template\\)\\>")))
)
;; searching backward
(if (and (< 0 count)
@@ -2318,9 +2321,9 @@
(if (and count (/= count 1))
(py-beginning-of-def-or-class (- 1 count)))
(let ((start (progn (py-goto-initial-line) (point)))
- (which (cond ((eq class 'either) "\\(class\\|def\\)")
+ (which (cond ((eq class 'either) "\\(class\\|def\\|template\\)")
(class "class")
- (t "def")))
+ (t "def\\|template")))
(state 'not-found))
;; move point to start of appropriate def/class
(if (looking-at (concat "[ \t]*" which "\\>")) ; already on one
@@ -2505,9 +2508,9 @@
pleasant."
(interactive "P") ; raw prefix arg
(let ((start (point))
- (which (cond ((eq class 'either) "\\(class\\|def\\)")
+ (which (cond ((eq class 'either) "\\(class\\|def\\|template\\)")
(class "class")
- (t "def"))))
+ (t "def\\|template"))))
(push-mark start)
(if (not (py-go-up-tree-to-keyword which))
(progn (goto-char start)
--
Greg Ward - software developer gward@mems-exchange.org
MEMS Exchange http://www.mems-exchange.org