 (define-key dired-mode-map (kbd "<backspace>") 'diredp-kill-this-tree)
 
 ;; python-mode insert breakpoint
-(define-key python-mode-map (leader+ "C-d")
-  (cmd (let ((indent (current-indent)))
+(define-key-cmd python-mode-map (leader+ "C-b")
+  (let ((indent (current-indent)))
          (beginning-of-line)
          (insert (concat (str* " " indent)
                          "import ipdb; ipdb.set_trace()\n"))
          (forward-line -1)
-         (goto-char (+ (point) indent)))))
+         (forward-char indent)))
+
+;; Go to first pep8 error
+(define-key-cmd python-mode-map (kbd "<f5>")
+  (let ((result (call-process-buffer-str "pep8" "-")))
+    (if (/= (length (strip result)) 0)
+        (let ((parts (parse-pep8 result)))
+          (beginning-of-buffer)
+          (forward-line (1- (nth 0 parts)))
+          (forward-char (1- (nth 1 parts)))
+          (popup-tip (nth 2 parts)))
+      (popup-tip "No pep8 errors."))))
 
 
 ;;;; Useful Functions

                                    (line-end-position)))

(defun current-indent ()
  (let ((old-pos (point)))
    (move-down-to-nonempty-line)
    (let ((s (current-line)))

;;;; Macros
(defmacro comment (&rest args) nil)
(defmacro cmd (&rest args) `(lambda () (interactive) (progn ,@args)))
(defmacro define-key-cmd (keymap key &rest body)
  `(define-key ,keymap ,key (lambda () (interactive) (progn ,@body))))

(defmacro ->> (&rest body)
  (let ((result (pop body)))
    (dolist (form body result)
      (let ((lform (list-wrap form)))
        (setq result (append lform (list result)))))))

(defmacro -> (&rest body)
  (let ((result (pop body)))
    (dolist (form body result)
      (let ((lform (list-wrap form)))
        (setq result (append (list (car lform) result)
                             (cdr lform)))))))

;; Used in the above macros
(defun list-wrap (x) (if (listp x) x (list x)))


;;;; Prepare package manager
