From 5098b845e9eb0b3a39495f4fd7890cae0d426c3e Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Sat, 4 Nov 2023 23:47:58 +0100 Subject: Disable unused-variable warnings in flymake-guile These produce too many false positives, e.g. every time `match' is used. Also, reduce indentation by inverting the `if' condition. --- tw/home/files/emacs-packages/flymake-guile.el | 60 +++++++++++++++++---------- 1 file changed, 37 insertions(+), 23 deletions(-) (limited to 'tw') diff --git a/tw/home/files/emacs-packages/flymake-guile.el b/tw/home/files/emacs-packages/flymake-guile.el index a482cf18..edfbce82 100644 --- a/tw/home/files/emacs-packages/flymake-guile.el +++ b/tw/home/files/emacs-packages/flymake-guile.el @@ -60,7 +60,20 @@ Any running invocations are killed before running another one." ;; Direct output to a temporary buffer. :buffer (generate-new-buffer " *flymake-guile*") ;; Guild can't read from stdin; it needs a file. - :command (list flymake-guile-guild-executable "compile" "-W3" + :command (list flymake-guile-guild-executable "compile" + ;; See "guild --warn=help" for details. + ;; "--warn=unsupported-warning" ; ignore unsupported warning types + ;; "--warn=unused-variable" ; too many false positives from macros + "--warn=unused-toplevel" + "--warn=shadowed-toplevel" + "--warn=unbound-variable" + "--warn=macro-use-before-definition" + "--warn=use-before-definition" + "--warn=non-idempotent-definition" + "--warn=arity-mismatch" + "--warn=duplicate-case-datum" + "--warn=bad-case-datum" + "--warn=format" "-L" (expand-file-name (project-root (project-current nil (file-name-directory (buffer-file-name source))))) @@ -72,28 +85,29 @@ Any running invocations are killed before running another one." (when (memq (process-status proc) '(exit signal)) (unwind-protect ;; Only proceed if we've got the "latest" process. - (if (with-current-buffer source (eq proc flymake-guile--flymake-proc)) - (with-current-buffer (process-buffer proc) - (goto-char (point-min)) - (cl-loop - with msg-regexp = (rx bol (literal temp-file) ":" ; filename - (group (+ digit)) ":" ; line - (group (+ digit)) ": " ; column - (group (or "warning" "error")) ": " ; type - (group (+ not-newline)) eol) ; message - while (search-forward-regexp msg-regexp nil t) - for (beg . end) = (flymake-diag-region - source ; we filter for messages matching our buffer in the regexp - (string-to-number (match-string 1)) - (string-to-number (match-string 2))) - for type = (pcase (match-string 3) - ("warning" :warning) - ("error" :error) - (type (error "Unknown guild error type %s" type))) - collect (flymake-make-diagnostic source beg end type (match-string 4)) - into diags - finally (funcall report-fn diags))) - (flymake-log :warning "Canceling obsolete check %s" proc)) + (if (with-current-buffer source (not (eq proc flymake-guile--flymake-proc))) + (flymake-log :warning "Canceling obsolete check %s" proc) + (with-current-buffer (process-buffer proc) + (goto-char (point-min)) + (cl-loop + with msg-regexp = (rx bol (literal temp-file) ":" ; filename + (group (+ digit)) ":" ; line + (group (+ digit)) ": " ; column + (group (or "warning" "error")) ": " ; type + (group (+ not-newline)) eol) ; message + while (search-forward-regexp msg-regexp nil t) + for (beg . end) = (flymake-diag-region + source ; we filter for messages matching our buffer in the regexp + (string-to-number (match-string 1)) + ;; guild outputs 0-based column numbers + (1+ (string-to-number (match-string 2)))) + for type = (pcase (match-string 3) + ("warning" :warning) + ("error" :error) + (type (error "Unknown guild error type %s" type))) + collect (flymake-make-diagnostic source beg end type (match-string 4)) + into diags + finally (funcall report-fn diags)))) ;; Clean up temporary buffer. (kill-buffer (process-buffer proc)) (delete-file temp-file))))))))) -- cgit v1.2.3