.emacs.d/flymake-point.el
author Adam Gomaa <adam@gomaa.us>
Sun Dec 18 13:13:02 2011 -0500
changeset 521 67f37d330ad0
permissions -rw-r--r--
Remove project & _list_projects, I don't use them anymore.
     1 ;; -*- emacs-lisp -*-
     2 ;; License: Gnu Public License
     3 ;;
     4 ;; Additional functionality that makes flymake error messages appear
     5 ;; in the minibuffer when point is on a line containing a flymake
     6 ;; error. This saves having to mouse over the error, which is a
     7 ;; keyboard user's annoyance
     8 
     9 (defun show-fly-err-at-point ()
    10   "If the cursor is sitting on a flymake error, display the
    11 message in the minibuffer"
    12   (interactive)
    13   (let ((line-no (line-number-at-pos)))
    14     (dolist (elem flymake-err-info)
    15       (if (eq (car elem) line-no)
    16 	  (let ((err (car (nth 1 elem))))
    17 	    (message "%s" (fly-pyflake-determine-message err)))))))
    18 
    19 (defun fly-pyflake-determine-message (err)
    20   "pyflake is flakey if it has compile problems, this adjusts the
    21 message to display, so there is one ;)"
    22   (cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t)))
    23 	((null (flymake-ler-file err))
    24 	 ;; normal message do your thing
    25 	 (flymake-ler-text err))
    26 	(t ;; could not compile err
    27 	 (format "compile error, problem on line %s" (flymake-ler-line err)))))
    28 
    29 (defadvice flymake-goto-next-error (after display-message activate compile)
    30   "Display the error in the mini-buffer rather than having to mouse over it"
    31   (show-fly-err-at-point))
    32 
    33 (defadvice flymake-goto-prev-error (after display-message activate compile)
    34   "Display the error in the mini-buffer rather than having to mouse over it"
    35   (show-fly-err-at-point))
    36 
    37 (defadvice flymake-mode (before post-command-stuff activate compile)
    38   "Add functionality to the post command hook so that if the
    39 cursor is sitting on a flymake error the error information is
    40 displayed in the minibuffer (rather than having to mouse over
    41 it)"
    42   (set (make-local-variable 'post-command-hook)
    43        (cons 'show-fly-err-at-point post-command-hook)))
    44 
    45 (provide 'flymake-point)