@@ -393,6 +393,20 @@ Currently-active file is at the head of the list.")
393393 " \\ )" )
394394 " Regexp matching lines to not outdent after." )
395395
396+ (defvar py-defun-start-re
397+ " ^\\ ([ \t ]*\\ )def[ \t ]+\\ ([a-zA-Z_0-9]+\\ )\\ |\\ (^[a-zA-Z_0-9]+\\ )[ \t ]*="
398+ " Regexp matching a function, method or variable assignment.
399+
400+ If you change this, you probably have to change `py-current-defun' as well.
401+ This is only used by `py-current-defun' to find the name for add-log.el." )
402+
403+ (defvar py-class-start-re " ^class[ \t ]*\\ ([a-zA-Z_0-9]+\\ )"
404+ " Regexp for finding a class name.
405+
406+ If you change this, you probably have to change `py-current-defun' as well.
407+ This is only used by `py-current-defun' to find the name for add-log.el." )
408+
409+
396410
397411; ; Menu definitions, only relevent if you have the easymenu.el package
398412; ; (standard in the latest Emacs 19 and XEmacs 19 distributions).
@@ -671,6 +685,7 @@ py-beep-if-tab-change\t\tring the bell if tab-width is changed"
671685 (make-local-variable 'comment-column )
672686 (make-local-variable 'indent-region-function )
673687 (make-local-variable 'indent-line-function )
688+ (make-local-variable 'add-log-current-defun-function )
674689 ; ;
675690 (set-syntax-table py-mode-syntax-table)
676691 (setq major-mode 'python-mode
@@ -685,6 +700,8 @@ py-beep-if-tab-change\t\tring the bell if tab-width is changed"
685700 comment-column 40
686701 indent-region-function 'py-indent-region
687702 indent-line-function 'py-indent-line
703+ ; ; tell add-log.el how to find the current function/method/variable
704+ add-log-current-defun-function 'py-current-defun
688705 )
689706 (use-local-map py-mode-map)
690707 ; ; add the menu
@@ -2330,6 +2347,17 @@ local bindings to py-newline-and-indent."))
23302347 (set-buffer cbuf))
23312348 (sit-for 0 ))
23322349
2350+ (defun py-current-defun ()
2351+ ; ; tell add-log.el how to find the current function/method/variable
2352+ (save-excursion
2353+ (if (re-search-backward py-defun-start-re nil t )
2354+ (or (match-string 3 )
2355+ (let ((method (match-string 2 )))
2356+ (if (and (not (zerop (length (match-string 1 ))))
2357+ (re-search-backward py-class-start-re nil t ))
2358+ (concat (match-string 1 ) " ." method)
2359+ method)))
2360+ nil )))
23332361
23342362
23352363(defconst py-version " $Revision$"
0 commit comments