-
Notifications
You must be signed in to change notification settings - Fork 0
/
flymake-cursor.el
44 lines (39 loc) · 1.83 KB
/
flymake-cursor.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;; -*- 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)))