diff options
| author | mgmarlow <graham@mgmarlow.com> | 2023-07-30 12:24:17 -0700 |
|---|---|---|
| committer | mgmarlow <graham@mgmarlow.com> | 2023-07-30 12:24:17 -0700 |
| commit | fb4ce2e9b9f7703bd38a2acc2595a02f3822cac7 (patch) | |
| tree | 5bdb57ad9d73cd1bc8cd98e1db5720cd92e5c435 | |
| parent | 1879f358a3d61db0b87832443386f9e1f9ec132d (diff) | |
| download | flymake-clippy-fb4ce2e9b9f7703bd38a2acc2595a02f3822cac7.tar.gz | |
Rename to flymake-clippy for MELPA release
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | README.md | 22 | ||||
| -rw-r--r-- | flymake-clippy-test.el (renamed from clippy-flymake-test.el) | 6 | ||||
| -rw-r--r-- | flymake-clippy.el (renamed from clippy-flymake.el) | 38 |
4 files changed, 36 insertions, 36 deletions
@@ -1,10 +1,10 @@ .PHONY: build test clean test: build - emacs -batch -l ert -L . -l clippy-flymake-test.el -f ert-run-tests-batch-and-exit + emacs -batch -l ert -L . -l flymake-clippy-test.el -f ert-run-tests-batch-and-exit build: clean - emacs -batch -L . -f batch-byte-compile clippy-flymake.el + emacs -batch -L . -f batch-byte-compile flymake-clippy.el clean: - rm -f clippy-flymake.elc + rm -f flymake-clippy.elc @@ -1,4 +1,4 @@ -# clippy-flymake +# flymake-clippy A Flymake backend for [Clippy](https://doc.rust-lang.org/stable/clippy/index.html), the Rust linter. @@ -9,20 +9,20 @@ You probably want to install [rust-mode](https://github.com/rust-lang/rust-mode) With Emacs 30: ``` elisp -(use-package clippy-flymake - :vc (:url "https://git.sr.ht/~mgmarlow/clippy-flymake" :branch main) - :hook (rust-mode . clippy-flymake-setup-backend)) +(use-package flymake-clippy + :vc (:url "https://git.sr.ht/~mgmarlow/flymake-clippy" :branch main) + :hook (rust-mode . flymake-clippy-setup-backend)) ``` Alternatively, clone the repo and update your load path: ``` -git clone https://git.sr.ht/~mgmarlow/clippy-flymake /path/to/clippy-flymake +git clone https://git.sr.ht/~mgmarlow/flymake-clippy /path/to/flymake-clippy ``` ```elisp -(add-to-list 'load-path "/path/to/clippy-flymake") -(require 'clippy-flymake) +(add-to-list 'load-path "/path/to/flymake-clippy") +(require 'flymake-clippy) ``` Emacs versions prior to 30 can also install [use-package](https://github.com/jwiegley/use-package) and [vc-use-package](https://github.com/slotThe/vc-use-package) for an easier setup. @@ -50,7 +50,7 @@ You can confirm that Flymake is running correctly by opening up a Rust buffer an ``` M-x flymake-running-backends -Running backends: clippy-flymake-backend, eglot-flymake-backend +Running backends: flymake-clippy-backend, eglot-flymake-backend ``` ### Complete eglot + rust-mode + use-package example @@ -61,9 +61,9 @@ Emacs 30, eglot 1.6+: (use-package rust-mode :ensure t) -(use-package clippy-flymake - :vc (:url "https://git.sr.ht/~mgmarlow/clippy-flymake" :branch main) - :hook (rust-mode . clippy-flymake-setup-backend)) +(use-package flymake-clippy + :vc (:url "https://git.sr.ht/~mgmarlow/flymake-clippy" :branch main) + :hook (rust-mode . flymake-clippy-setup-backend)) (defun manually-activate-flymake () (add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t) diff --git a/clippy-flymake-test.el b/flymake-clippy-test.el index 6039824..0cc3018 100644 --- a/clippy-flymake-test.el +++ b/flymake-clippy-test.el @@ -1,11 +1,11 @@ -;;; clippy-flymake-test.el -*- lexical-binding: t; -*- +;;; flymake-clippy-test.el -*- lexical-binding: t; -*- -(require 'clippy-flymake) +(require 'flymake-clippy) (require 'ert) (defun run-regexp () (set-match-data nil) - (search-forward-regexp (clippy-flymake--build-regexp) nil t) + (search-forward-regexp (flymake-clippy--build-regexp) nil t) (list (match-string 1) (match-string 2) (match-string 3))) diff --git a/clippy-flymake.el b/flymake-clippy.el index 205f5a1..2ecf61e 100644 --- a/clippy-flymake.el +++ b/flymake-clippy.el @@ -1,10 +1,10 @@ -;;; clippy-flymake.el --- Flymake backend for Clippy -*- lexical-binding: t; -*- +;;; flymake-clippy.el --- Flymake backend for Clippy -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Graham Marlow ;; Author: Graham Marlow <info@mgmarlow.com> ;; Keywords: tools -;; URL: https://sr.ht/~mgmarlow/clippy-flymake/ +;; URL: https://sr.ht/~mgmarlow/flymake-clippy/ ;; Version: 1.0.0 ;; Package-Requires: ((emacs "26.1")) @@ -34,8 +34,8 @@ ;; "warning: ..." ;; --> src/filename.rs ;; 98 | ... -(defun clippy-flymake--build-regexp () - "Create a regular expression to search Clippy warnings for FILENAME." +(defun flymake-clippy--build-regexp () + "Regexp for Clippy output." (rx (seq line-start ;; Message (group (or "warning:" "error:") @@ -58,16 +58,16 @@ (any "0-9"))) line-end))) -(defvar-local clippy-flymake--proc nil +(defvar-local flymake-clippy--proc nil "Clippy subprocess object, used to ensure obsolete processes aren't reused.") -(defun clippy-flymake-backend (report-fn &rest _args) +(defun flymake-clippy-backend (report-fn &rest _args) "Flymake backend for Clippy, the Rust linter. Calls REPORT-FN with a list of Flymake diagnostics for the current buffer. -Use `clippy-flymake-setup-backend' to register the backend +Use `flymake-clippy-setup-backend' to register the backend with the appropriate Flymake hook." (unless (executable-find "cargo") (error "Cannot find cargo")) @@ -76,23 +76,23 @@ with the appropriate Flymake hook." (filename (buffer-file-name source))) (save-restriction (widen) - (setq clippy-flymake--proc + (setq flymake-clippy--proc (make-process - :name "clippy-flymake" :noquery t :connection-type 'pipe - :buffer (generate-new-buffer "*clippy-flymake*") + :name "flymake-clippy" :noquery t :connection-type 'pipe + :buffer (generate-new-buffer "*flymake-clippy*") :command '("cargo" "clippy") :sentinel (lambda (proc _event) (when (memq (process-status proc) '(exit signal)) (unwind-protect - (if (with-current-buffer source (eq proc clippy-flymake--proc)) + (if (with-current-buffer source (eq proc flymake-clippy--proc)) (with-current-buffer (process-buffer proc) (goto-char (point-min)) ;; Collect output buffer into diagnostic messages/locations, ;; exposing them via `report-fn'. (cl-loop while (search-forward-regexp - (clippy-flymake--build-regexp) + (flymake-clippy--build-regexp) nil t) for msg = (match-string 1) for sourcefile = (match-string 2) @@ -109,13 +109,13 @@ with the appropriate Flymake hook." (flymake-log :warning "Canceling obsolete check %s" proc)) ;; Cleanup temp buffer. (kill-buffer (process-buffer proc))))))) - (process-send-region clippy-flymake--proc (point-min) (point-max)) - (process-send-eof clippy-flymake--proc)))) + (process-send-region flymake-clippy--proc (point-min) (point-max)) + (process-send-eof flymake-clippy--proc)))) -(defun clippy-flymake-setup-backend () - "Add `clippy-flymake' to `flymake-diagnostic-functions' hook." - (add-hook 'flymake-diagnostic-functions #'clippy-flymake-backend nil t)) +(defun flymake-clippy-setup-backend () + "Add `flymake-clippy' to `flymake-diagnostic-functions' hook." + (add-hook 'flymake-diagnostic-functions #'flymake-clippy-backend nil t)) -(provide 'clippy-flymake) +(provide 'flymake-clippy) -;;; clippy-flymake.el ends here +;;; flymake-clippy.el ends here |
