annotate .elisp/nose.el @ 92:2563edf11e59

Latest nosemacs.
author Augie Fackler <durin42@gmail.com>
date Wed, 22 Apr 2009 10:17:31 -0500
parents 79eec81404c3
children e83373ab1581
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
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 (defun run-nose (&optional tests debug)
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))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 (args (if debug "--pdb" ""))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 (tnames (if tests tests "")))
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
66 (funcall (if debug
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
67 'pdb
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
68 '(lambda (command)
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
69 (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
70 nil
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
71 (lambda (mode) (concat "*nosetests*")))))
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
72 (format
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
73 (concat "%s "
92
2563edf11e59 Latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 88
diff changeset
74 (if nose-use-verbose "-v " "")
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
75 "%s -w %s -c %ssetup.cfg %s")
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
76 (nose-find-test-runner) args where where tnames)))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 )
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 (defun nosetests-all (&optional debug)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 "run all tests"
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 (run-nose nil debug))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 (defun nosetests-pdb-all ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 (nosetests-all t))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 (defun nosetests-module (&optional debug)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 "run nosetests (via eggs/bin/test) on current buffer"
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 (run-nose buffer-file-name debug))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 (defun nosetests-pdb-module ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 (nosetests-module t))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 (defun nosetests-one (&optional debug)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 "run nosetests (via eggs/bin/test) on testable thing
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 at point in current buffer"
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 (run-nose (format "%s:%s" buffer-file-name (nose-py-testable)) debug))
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-pdb-one ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 (interactive)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 (nosetests-one t))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 (defun nose-find-test-runner ()
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108 (message
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
109 (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
110 (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
111 (mapcar 'nose-find-test-runner-names nose-project-names))))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112 (if result
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 result
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 nose-global-name))))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 (defun nose-find-test-runner-names (runner)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 "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
118 (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
119 (file-name-directory buffer-file-name) runner))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 (defun nose-find-test-runner-in-dir-named (dn runner)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 (let ((fn (expand-file-name runner dn)))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 (cond ((file-regular-p fn) fn)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124 ((equal dn "/") nil)
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 (t (nose-find-test-runner-in-dir-named
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 (file-name-directory (directory-file-name dn))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 runner)))))
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 (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
130 (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
131 (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
132 ;; 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
133 (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
134 (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
135 (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
136 ((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
137 (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
138
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
139 (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
140 (save-excursion
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 (re-search-backward
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 "^ \\{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
143 (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
144
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
145 (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
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 "^\\(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
149 (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
150 (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
151
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
152 (cons
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
153 (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
154 result))))
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
156 (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
157 (let ((dn
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
158 (if dirname
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
159 dirname
84
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
160 (file-name-directory buffer-file-name))))
88
79eec81404c3 Import latest nosemacs.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
161 (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
162 ((equal (expand-file-name dn) "/") nil)
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
163 (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
164 (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
165
f013f40e7b63 Import latest nosemacs, set nose to output dots instead of verbose output.
Augie Fackler <durin42@gmail.com>
parents: 80
diff changeset
166 (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
167 (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
168 (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
169 nose-project-root-files)))
85
4b9b90486260 Fix an error in nose.el
Augie Fackler <durin42@gmail.com>
parents: 84
diff changeset
170
76
2b2a667092fd Add nose.el.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 (provide 'nose)