Created
July 29, 2013 05:33
-
-
Save eentzel/6102309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; http://www.plope.com/Members/chrism/flymake-mode | |
(when (load "flymake" t) | |
(defun flymake-pyflakes-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "pyflakes" (list local-file)))) | |
(add-to-list 'flymake-allowed-file-name-masks | |
'("\\.py\\'" flymake-pyflakes-init))) | |
;; (add-hook 'find-file-hook 'flymake-find-file-hook) | |
;; -*- emacs-lisp -*- | |
;; License: Gnu Public License | |
;; | |
;; Additional functionality that makes flymake error messages appear | |
;; in the minibuffer when point is on a line containing a flymake | |
;; error. This saves having to mouse over the error, which is a | |
;; keyboard user's annoyance | |
;;flymake-ler(file line type text &optional full-file) | |
(defun show-fly-err-at-point () | |
"If the cursor is sitting on a flymake error, display the | |
message in the minibuffer" | |
(interactive) | |
(let ((line-no (line-number-at-pos))) | |
(dolist (elem flymake-err-info) | |
(if (eq (car elem) line-no) | |
(let ((err (car (second elem)))) | |
(message "%s" (fly-pyflake-determine-message err))))))) | |
(defun fly-pyflake-determine-message (err) | |
"pyflake is flakey if it has compile problems, this adjusts the | |
message to display, so there is one ;)" | |
(cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t))) | |
((null (flymake-ler-file err)) | |
;; normal message do your thing | |
(flymake-ler-text err)) | |
(t ;; could not compile err | |
(format "compile error, problem on line %s" (flymake-ler-line err))))) | |
(defadvice flymake-goto-next-error (after display-message activate compile) | |
"Display the error in the mini-buffer rather than having to mouse over it" | |
(show-fly-err-at-point)) | |
(defadvice flymake-goto-prev-error (after display-message activate compile) | |
"Display the error in the mini-buffer rather than having to mouse over it" | |
(show-fly-err-at-point)) | |
(defadvice flymake-mode (before post-command-stuff activate compile) | |
"Add functionality to the post command hook so that if the | |
cursor is sitting on a flymake error the error information is | |
displayed in the minibuffer (rather than having to mouse over | |
it)" | |
(set (make-local-variable 'post-command-hook) | |
(cons 'show-fly-err-at-point post-command-hook))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment