flycheck-guile.el 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ;;; flycheck-guile.el --- A Flycheck checker for GNU Guile -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2019 Ricardo Wurmus <rekado@elephly.net>
  3. ;; Copyright (C) 2020 Free Software Foundation, Inc
  4. ;; Author: Ricardo Wurmus <rekado@elephly.net>
  5. ;; Maintainer: Andrew Whatson <whatson@gmail.com>
  6. ;; Version: 0.1
  7. ;; URL: https://github.com/flatwhatson/flycheck-guile
  8. ;; Package-Requires: ((emacs "24.1") (flycheck "0.22") (geiser "0.11"))
  9. ;; This file is not part of GNU Emacs.
  10. ;; This program is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation, either version 3 of the License, or
  13. ;; (at your option) any later version.
  14. ;; This program is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;; GNU General Public License for more details.
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. ;;; Commentary:
  21. ;; GNU Guile syntax checking support for Flycheck.
  22. ;;; Code:
  23. (require 'flycheck)
  24. (defgroup flycheck-guile nil
  25. "GNU Guile support for Flycheck."
  26. :prefix "flycheck-guile-"
  27. :group 'flycheck
  28. :link '(url-link :tag "Github" "https://github.com/flatwhatson/flycheck-guile"))
  29. (defcustom flycheck-guile-warnings
  30. '(;"unsupported-warning" ; warn about unknown warning types
  31. "unused-variable" ; report unused variables
  32. ;"unused-toplevel" ; report unused local top-level variables
  33. ;"shadowed-toplevel" ; report shadowed top-level variables
  34. "unbound-variable" ; report possibly unbound variables
  35. "macro-use-before-definition" ; report possibly mis-use of macros before they are defined
  36. "arity-mismatch" ; report procedure arity mismatches (wrong number of arguments)
  37. "duplicate-case-datum" ; report a duplicate datum in a case expression
  38. "bad-case-datum" ; report a case datum that cannot be meaningfully compared using `eqv?'
  39. "format" ; report wrong number of arguments to `format'
  40. )
  41. "A list of warnings to enable for `guild compile'.
  42. The value of this variable is a list of strings, where each
  43. string names a supported warning type.
  44. The list of supported warning types can be found by running
  45. `guild compile -W help'."
  46. :type '(repeat string)
  47. :group 'flycheck-guile)
  48. (flycheck-define-checker guile
  49. "A GNU Guile syntax checker using `guild compile'."
  50. :command ("guild" "compile" "--to=cps"
  51. (option-list "-W" flycheck-guile-warnings)
  52. (option-list "-L" geiser-guile-load-path list expand-file-name)
  53. source)
  54. :predicate
  55. (lambda ()
  56. (and (boundp 'geiser-impl--implementation)
  57. (eq geiser-impl--implementation 'guile)))
  58. :verify
  59. (lambda (checker)
  60. (let ((geiser-impl (bound-and-true-p geiser-impl--implementation)))
  61. (list
  62. (flycheck-verification-result-new
  63. :label "Geiser Implementation"
  64. :message (cond
  65. ((eq geiser-impl 'guile) "Guile")
  66. (geiser-impl (format "Other: %s" geiser-impl))
  67. (t "Geiser not active"))
  68. :face (cond
  69. ((or (eq geiser-impl 'guile)) 'success)
  70. (t '(bold error)))))))
  71. :error-patterns
  72. ((warning
  73. line-start
  74. (file-name) ":" line ":" column ": warning:" (message) line-end)
  75. (error
  76. line-start
  77. "ice-9/boot-9.scm:" (+ digit) ":" (+ digit) ":" (+ (any space "\n"))
  78. "In procedure raise-exception:" (+ (any space "\n"))
  79. "In procedure " (id (+ (not (any ":")))) ":" (+ (any space "\n"))
  80. (file-name) ":" line ":" column ":" (message (+? anything)) (* space) string-end)
  81. (error
  82. line-start
  83. "ice-9/boot-9.scm:" (+ digit) ":" (+ digit) ":" (+ (any space "\n"))
  84. "In procedure raise-exception:" (+ (any space "\n"))
  85. (id (+ (not (any ":")))) ":" (+ (any space "\n"))
  86. (file-name) ":" line ":" column ":" (message (+? anything)) (* space) string-end)
  87. (error
  88. line-start
  89. (file-name) ":" line ":" column ":" (message (+? anything)) (* space) string-end))
  90. :modes (scheme-mode geiser-mode))
  91. (add-to-list 'flycheck-checkers 'guile)
  92. (provide 'flycheck-guile)
  93. ;;; flycheck-guile.el ends here