commit | author | age
|
5cb5f7
|
1 |
;;; flymake-tip.el --- show flymake's error by popup-tip -*- lexical-binding: t; -*- |
C |
2 |
|
|
3 |
;; Copyright (C) 2014 by Yuta Yamada |
|
4 |
|
|
5 |
;; Author: Yuta Yamada <cokesboy"at"gmail.com> |
|
6 |
;; URL: https://github.com/yuutayamada/flycheck-tip |
|
7 |
;; Version: 0.5.0 |
|
8 |
;; Package-Requires: ((emacs "24.1")) |
|
9 |
;; Keywords: flymake |
|
10 |
|
|
11 |
;;; License: |
|
12 |
;; This program is free software: you can redistribute it and/or modify |
|
13 |
;; it under the terms of the GNU General Public License as published by |
|
14 |
;; the Free Software Foundation, either version 3 of the License, or |
|
15 |
;; (at your option) any later version. |
|
16 |
;; |
|
17 |
;; This program is distributed in the hope that it will be useful, |
|
18 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
;; GNU General Public License for more details. |
|
21 |
;; |
|
22 |
;; You should have received a copy of the GNU General Public License |
|
23 |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 |
;;; Commentary: |
|
25 |
|
|
26 |
;;; Code: |
|
27 |
|
|
28 |
(require 'error-tip) |
|
29 |
(require 'flymake) |
|
30 |
(require 'cl-lib) |
|
31 |
|
|
32 |
(defvar flymake-tip--err-info-function |
|
33 |
(cond |
|
34 |
((version<= "26" (number-to-string emacs-major-version)) |
|
35 |
'(lambda () |
|
36 |
;; Return list of string of error/warning info on the current cursor |
|
37 |
(cl-loop for diag in (flymake-diagnostics (point-at-bol) (point-at-eol)) |
|
38 |
collect (flymake-diagnostic-text diag)))) |
|
39 |
|
|
40 |
((fboundp 'flymake-find-err-info) |
|
41 |
'(lambda () |
|
42 |
;; Old implementation for emacs-major-version < 26 |
|
43 |
(cl-loop |
|
44 |
with errors = (flymake-find-err-info flyamke-err-info (line-number-at-pos)) |
|
45 |
for err in (car errors) |
|
46 |
if (vectorp err) |
|
47 |
collect (elt err 4)))))) |
|
48 |
|
|
49 |
;;;###autoload |
|
50 |
(defun flymake-tip-cycle (reverse) |
|
51 |
(interactive) |
|
52 |
(let ((jump (lambda () |
|
53 |
(if reverse |
|
54 |
(flymake-goto-prev-error) |
|
55 |
(flymake-goto-next-error))))) |
|
56 |
(let ((line (line-number-at-pos))) |
|
57 |
(funcall jump) |
|
58 |
(when (eq line (line-number-at-pos)) |
|
59 |
(goto-char (if reverse (point-at-bol) (point-at-eol))) |
|
60 |
(funcall jump)))) |
|
61 |
(error-tip-popup-error-message |
|
62 |
(funcall flymake-tip--err-info-function))) |
|
63 |
|
|
64 |
;;;###autoload |
|
65 |
(defun flymake-tip-cycle-reverse () |
|
66 |
(interactive) |
|
67 |
(flymake-tip-cycle t)) |
|
68 |
|
|
69 |
(provide 'flymake-tip) |
|
70 |
|
|
71 |
;; Local Variables: |
|
72 |
;; coding: utf-8 |
|
73 |
;; mode: emacs-lisp |
|
74 |
;; End: |
|
75 |
|
|
76 |
;;; flymake-tip.el ends here |