annotate .elisp/nose.el @ 129:1286c27cf0c0

Need to use paths default instead of the outdated svn url now.
author Augie Fackler <durin42@gmail.com>
date Thu, 23 Jul 2009 10:23:52 -0500
parents e83373ab1581
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 ;; nose.el --- Easy Python test running in Emacs
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 ;; Copyright (C) 2009 Jason Pellerin, Augie Fackler
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 ;; Licensed under the same terms as Emacs.
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 ;; Version: 0.1.0
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 ;; Keywords: nose python testing
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 ;; Created: 04 Apr 2009
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 ;; This file is NOT part of GNU Emacs.
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 ;; Licensed under the same terms as Emacs.
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 ;;; Commentary:
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 ;; This gives a bunch of functions that handle running nosetests on a
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 ;; particular buffer or part of a buffer.
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 ;;; Installation
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 ;; In your emacs config:
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 ;;
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 ;; (require 'nose)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 ;; ; next line only for people with non-eco non-global test runners
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 ;; ; (add-to-list 'nose-project-names "my/crazy/runner")
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 ;; Note that if your global nose isn't called "nosetests", then you'll want to
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 ;; redefine nose-global-name to be the command that should be used.
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
30 ;; By default, the root of a project is found by looking for any of the files
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
31 ;; 'setup.py', '.hg' and '.git'. You can add files to check for to the file
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
32 ;; list:
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
33 ;;
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
34 ;; ; (add-to-list 'nose-project-root-files "something")
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
35
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
36 ;; or you can change the project root test to detect in some other way
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
37 ;; whether a directory is the project root:
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
38 ;;
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
39 ;; ; (setq nose-project-root-test (lambda (dirname) (equal dirname "foo")))
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
40
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
41 ;; If you want dots as output, rather than the verbose output:
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
42 ;; (defvar nose-use-verbose nil) ; default is t
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
43
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 ;; Probably also want some keybindings:
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 ;; (add-hook 'python-mode-hook
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 ;; (lambda ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 ;; (local-set-key "\C-ca" 'nosetests-all)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 ;; (local-set-key "\C-cm" 'nosetests-module)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 ;; (local-set-key "\C-c." 'nosetests-one)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 ;; (local-set-key "\C-cpa" 'nosetests-pdb-all)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 ;; (local-set-key "\C-cpm" 'nosetests-pdb-module)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 ;; (local-set-key "\C-cp." 'nosetests-pdb-one)))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 (defvar nose-project-names '("eco/bin/test"))
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
55 (defvar nose-project-root-files '("setup.py" ".hg" ".git"))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
56 (defvar nose-project-root-test 'nose-project-root)
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 (defvar nose-global-name "nosetests")
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
58 (defvar nose-use-verbose t)
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59
120
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
60 (defun run-nose (&optional tests debug failed)
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 "run nosetests"
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 (let* ((nose (nose-find-test-runner))
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
63 (where (nose-find-project-root))
120
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
64 (args (concat (if debug "--pdb" "")
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
65 " "
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
66 (if failed "--failed" "")))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 (tnames (if tests tests "")))
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
68 (funcall (if debug
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
69 'pdb
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
70 '(lambda (command)
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
71 (compilation-start command
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
72 nil
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
73 (lambda (mode) (concat "*nosetests*")))))
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
74 (format
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
75 (concat "%s "
92
2563edf11e59 Latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 88
diff changeset
76 (if nose-use-verbose "-v " "")
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
77 "%s -w %s -c %ssetup.cfg %s")
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
78 (nose-find-test-runner) args where where tnames)))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 )
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80
120
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
81 (defun nosetests-all (&optional debug failed)
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 "run all tests"
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 (interactive)
120
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
84 (run-nose nil debug failed))
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
85
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
86 (defun nosetests-failed (&optional debug)
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
87 (interactive)
e83373ab1581 Latest nosemacs, python menu item for running nose with --failed.
Augie Fackler <durin42@gmail.com>
parents: 92
diff changeset
88 (nosetests-all debug t))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90 (defun nosetests-pdb-all ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 (nosetests-all t))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 (defun nosetests-module (&optional debug)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 "run nosetests (via eggs/bin/test) on current buffer"
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 (run-nose buffer-file-name debug))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 (defun nosetests-pdb-module ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 (nosetests-module t))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 (defun nosetests-one (&optional debug)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 "run nosetests (via eggs/bin/test) on testable thing
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 at point in current buffer"
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 (run-nose (format "%s:%s" buffer-file-name (nose-py-testable)) debug))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 (defun nosetests-pdb-one ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 (nosetests-one t))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 (defun nose-find-test-runner ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 (message
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
115 (let ((result
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
116 (reduce '(lambda (x y) (or x y))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
117 (mapcar 'nose-find-test-runner-names nose-project-names))))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 (if result
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 result
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 nose-global-name))))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 (defun nose-find-test-runner-names (runner)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 "find eggs/bin/test in a parent dir of current buffer's file"
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
124 (nose-find-test-runner-in-dir-named
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
125 (file-name-directory buffer-file-name) runner))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 (defun nose-find-test-runner-in-dir-named (dn runner)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 (let ((fn (expand-file-name runner dn)))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 (cond ((file-regular-p fn) fn)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 ((equal dn "/") nil)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 (t (nose-find-test-runner-in-dir-named
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 (file-name-directory (directory-file-name dn))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 runner)))))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 (defun nose-py-testable ()
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
136 (let* ((inner-obj (inner-testable))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
137 (outer (outer-testable))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
138 ;; elisp can't return multiple values
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
139 (outer-def (car outer))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
140 (outer-obj (cdr outer)))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
141 (cond ((equal outer-def "def") outer-obj)
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
142 ((equal inner-obj outer-obj) outer-obj)
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
143 (t (format "%s.%s" outer-obj inner-obj)))))
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
144
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
145 (defun inner-testable ()
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
146 (save-excursion
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 (re-search-backward
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 "^ \\{0,4\\}\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t)
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
149 (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
150
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
151 (defun outer-testable ()
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
152 (save-excursion
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 (re-search-backward
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 "^\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t)
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
155 (let ((result
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
156 (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
157
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
158 (cons
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
159 (buffer-substring-no-properties (match-beginning 1) (match-end 1))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
160 result))))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
162 (defun nose-find-project-root (&optional dirname)
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
163 (let ((dn
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
164 (if dirname
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
165 dirname
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
166 (file-name-directory buffer-file-name))))
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
167 (cond ((funcall nose-project-root-test dn) (expand-file-name dn))
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
168 ((equal (expand-file-name dn) "/") nil)
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
169 (t (nose-find-project-root
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
170 (file-name-directory (directory-file-name dn)))))))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
171
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
172 (defun nose-project-root (dirname)
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
173 (reduce '(lambda (x y) (or x y))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
174 (mapcar (lambda (d) (member d (directory-files dirname)))
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
175 nose-project-root-files)))
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
176
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 (provide 'nose)