1. Jason Pellerin
  2. dotfiles

Commits

jpellerin  committed da2bf12

More uptodate .emacs

  • Participants
  • Parent commits 6d07571
  • Branches default

Comments (0)

Files changed (1)

File .emacs

View file
  • Ignore whitespace
 ;; start the server so emacsclient can work
 (server-start)
 
-;; lfo nose integration
-;; if you want to use this, you'll probably need to redefine find-test-runner
-(defun run-nose (&optional tests debug)
-  "run nosetests"
-  (interactive)
-  
-  (let* ((nose (find-test-runner))
-         (where (expand-file-name "../.." (file-name-directory nose)))
-         (args (if debug "--pdb" ""))
-         (tnames (if tests tests "")))
-    (print nose)
-    (print args)
-    (print tnames)
-    (funcall (if debug 'pdb 'compile)
-             (format "%s -v %s -w %s -c %s/setup.cfg %s" 
-                     (find-test-runner) args where where tnames)))
-  )
-
-(defun nosetests-all (&optional debug)
-  "run all tests"
-  (interactive)
-  (run-nose nil debug))
-
-(defun nosetests-pdb-all ()
-  (interactive)
-  (nosetests-all t))
-
-(defun nosetests-module (&optional debug)
-  "run nosetests (via eggs/bin/test) on current buffer"
-  (interactive)
-  (run-nose buffer-file-name debug))
-
-(defun nosetests-pdb-module ()
-  (interactive)
-  (nosetests-module t))
-
-(defun nosetests-one (&optional debug)
-  "run nosetests (via eggs/bin/test) on testable thing
- at point in current buffer"
-  (interactive)
-  (run-nose (format "%s:%s" buffer-file-name (py-testable)) debug))
-
-(defun nosetests-pdb-one ()
-  (interactive)
-  (nosetests-one t))
-
-(defun find-test-runner()
-  "find eggs/bin/test in a parent dir of current buffer's file"
-  (interactive)
-  (find-test-runner-in-dir (file-name-directory buffer-file-name)))
-
-(defun find-test-runner-in-dir (dn)
-  (let ((fn (expand-file-name "eggs/bin/test" dn)))
-    (if (file-regular-p fn)
-        fn
-      (if (eq dn "/")
-          nil
-        (find-test-runner-in-dir 
-         (file-name-directory (directory-file-name dn)))))))
-
-(defun py-testable ()
-  (interactive)
-  (let ((remember-point (point)))
-    (re-search-backward 
-     "^ \\{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)
-    (re-search-backward 
-     "^\\(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)))
-
-(eval-after-load "compile"
-  '(add-to-list 'compilation-error-regexp-alist
-                '(".*File \"\\(.+\\)\", line \\([0-9]+\\)" 1 2)))
-
-(add-hook 'python-mode-hook 
+(add-to-list 'nose-project-names "eggs/bin/test")
+(add-to-list 'nose-project-names "selftest.py")
+(add-hook 'python-mode-hook
+          (lambda ()
+            (local-set-key "\C-ca" 'nosetests-all)
+            (local-set-key "\C-cm" 'nosetests-module)
+            (local-set-key "\C-c." 'nosetests-one)
+            (local-set-key "\C-cpa" 'nosetests-pdb-all)
+            (local-set-key "\C-cpm" 'nosetests-pdb-module)
+            (local-set-key "\C-cp." 'nosetests-pdb-one)))
+(add-hook 'doctest-mode-hook
           (lambda ()
             (local-set-key "\C-ca" 'nosetests-all)
             (local-set-key "\C-cm" 'nosetests-module)
             (local-set-key "\C-cp." 'nosetests-pdb-one)))
 
 
-    
-        
+;; trailing whitespace mode
+(custom-set-faces
+ '(my-tab-face            ((((class color)) (:background "grey50"))) t)
+ '(my-long-line-face      ((((class color)) (:background "grey90"))) t)
+ '(my-trailing-space-face ((((class color)) (:background "gray80"))) t)
+ )
+
+(add-hook 'font-lock-mode-hook
+          (function
+           (lambda ()
+             (setq font-lock-keywords
+                   (append font-lock-keywords
+                           '(("\t+" (0 'my-tab-face t))
+                             ("^.\\{82,\\}$" (0 'my-long-line-face t))
+                             ("[ \t]+$"      (0 'my-trailing-space-face t)))))))
+          )