Jason Pellerin committed b0d1000

Removed all use of setq in favor of let/let* for cleanliness

Comments (0)

Files changed (1)

          (where (nose-find-project-root))
          (args (if debug "--pdb" ""))
          (tnames (if tests tests "")))
-    (funcall (if debug 'pdb '(lambda (command)
-                               (compilation-start command
-                                                  nil
-                                                  (lambda (mode) (concat "*nosetests*")))))
+    (funcall (if debug 
+                 'pdb 
+               '(lambda (command)
+                  (compilation-start command
+                                     nil
+                                     (lambda (mode) (concat "*nosetests*")))))
              (format "%s -v %s -w %s -c %ssetup.cfg %s"
                      (nose-find-test-runner) args where where tnames)))
 (defun nose-find-test-runner ()
-   (let ((result (reduce '(lambda (x y) (or x y))
-                         (mapcar 'nose-find-test-runner-names nose-project-names))))
+   (let ((result 
+          (reduce '(lambda (x y) (or x y))
+        (mapcar 'nose-find-test-runner-names nose-project-names))))
      (if result
 (defun nose-find-test-runner-names (runner)
   "find eggs/bin/test in a parent dir of current buffer's file"
-  (nose-find-test-runner-in-dir-named (file-name-directory buffer-file-name) runner))
+  (nose-find-test-runner-in-dir-named 
+   (file-name-directory buffer-file-name) runner))
 (defun nose-find-test-runner-in-dir-named (dn runner)
   (let ((fn (expand-file-name runner dn)))
 (defun nose-py-testable ()
-  (let ((remember-point (point)))
+  (let* ((inner-obj (inner-testable))
+         (outer (outer-testable))
+         ;; elisp can't return multiple values
+         (outer-def (car outer))
+         (outer-obj (cdr outer)))
+    (cond ((equal outer-def "def") outer-obj)
+          ((equal inner-obj outer-obj) outer-obj)
+          (t (format "%s.%s" outer-obj inner-obj)))))
+(defun inner-testable ()
+  (save-excursion
      "^ \\{0,4\\}\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t)
-    (setq t1 (buffer-substring-no-properties (match-beginning 2) (match-end 2)))
-    (goto-char remember-point)
+    (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
+(defun outer-testable ()
+  (save-excursion
      "^\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t)
-    (setq outer
-          (buffer-substring-no-properties (match-beginning 1) (match-end 1)))
-    (setq t2 (buffer-substring-no-properties (match-beginning 2) (match-end 2)))
-    (let
-        ((result (cond ((string= outer "def") t2)
-                       ((string= t1 t2) t2)
-                       (t (format "%s.%s" t2 t1)))))
-      (goto-char remember-point)
-      result)))
+    (let ((result 
+            (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
+      (cons 
+       (buffer-substring-no-properties (match-beginning 1) (match-end 1))
+       result))))
 (defun nose-find-project-root (&optional dirname)  
-  (when (null dirname) (setq dirname (file-name-directory buffer-file-name)))
-  (cond ((nose-project-root dirname) (expand-file-name dirname))
-        ((string= (expand-file-name dirname) "/") nil)
-        (t (nose-find-project-root
-            (file-name-directory (directory-file-name dirname))))))
+  (let ((dn
+         (if dirname
+             dirname 
+           (file-name-directory buffer-file-name))))
+    (cond ((nose-project-root dn) (expand-file-name dn))
+          ((equal (expand-file-name dn) "/") nil)
+        (t1 (nose-find-project-root
+             (file-name-directory (directory-file-name dn)))))))
 (defun nose-project-root (dirname)
   (reduce '(lambda (x y) (or x y))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.