 (set-variable 'virtualenv-root-dir "/home/alex/v/")
 (defun workon-postactivate (virtualenv)
   (require 'virtualenv)
-  (virtualenv-activate-environment virtualenv))
+  (virtualenv-activate-environment virtualenv)
+  (rope-open-project (concat virtualenv "/rope")))
 
 (require 'pymacs)
 (pymacs-load "ropemacs" "rope-")
 (setq ropemacs-enable-autoimport t)
 
+(setq python-check-command "pyflakes")
+
+;; auto-complete
 (add-to-list 'load-path "~/.emacs.d/auto-complete-1.3")
 (require 'auto-complete-config)
 (add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete-1.3/dict")
 (ac-config-default)
+(add-to-list 'ac-modes 'yaml-mode)
+;; This is too slow to be usable, and the delay doesn't work right
+(add-hook 'python-mode-hook 'ac-ropemacs-setup)
 (global-auto-complete-mode 1)
 
-(setq python-check-command "pyflakes")
-
+;; (defun ryan-python-tab ()
+;;   ;; Try the following:
+;;   ;; 1) Do a yasnippet expansion
+;;   ;; 2) Do a Rope code completion
+;;   ;; 3) Do an indent
+;;   (interactive)
+;;   (if (eql (ac-start) 0)
+;;       (indent-for-tab-command)))
+
+;; (defadvice ac-start (before advice-turn-on-auto-start activate)
+;;   (set (make-local-variable 'ac-auto-start) t))
+;; (defadvice ac-cleanup (after advice-turn-off-auto-start activate)
+;;   (set (make-local-variable 'ac-auto-start) nil))
+
+;; (define-key python-mode-map "\t" 'ryan-python-tab)
 ; ;; Varnish conf support
 ; (autoload 'vcl-mode "vcl-mode" "Edit Varnish VCL files" t)
 ; (add-to-list 'auto-mode-alist '("\\.vcl$" . vcl-mode))

             (delete-region beg end)
             (insert completion)))))

(defun better-pdb-breakpoints ()
  (gud-def gud-break  "break %d/%f:%l"  "\C-b" "Set breakpoint at current line.")
  (gud-def gud-remove "clear %d/%f:%l"  "\C-d" "Remove breakpoint at current line")
  )
(add-hook 'pdb-mode-hook 'better-pdb-breakpoints)
;; (defun ipython-shell-hook ()
;;       ;; the following is to synchronize dir-changes
;;       (make-local-variable 'shell-dirstack)

(defun flymake-get-tex-args (file-name)
(list "pdflatex"
(list "-file-line-error" "-interaction=nonstopmode" file-name)))
(add-hook 'LaTeX-mode-hook 'flymake-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
