Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get proselint to load as checker #192

Open
atanasj opened this issue Jun 19, 2024 · 1 comment
Open

Cannot get proselint to load as checker #192

atanasj opened this issue Jun 19, 2024 · 1 comment

Comments

@atanasj
Copy link

atanasj commented Jun 19, 2024

I want to use proselint as a grammar checker in org-msg-edit-mode. I can get it working by running consult-flycheck in message-mode, but not when using org-msg.

Some advice about how to get this working would be truly appreciated. Can someone please help / share their experience to help me get this working?

@jeremy-compostella
Copy link
Owner

I installed the flymake-proselint package and the following configuration seems to be working for me:

(defun org-msg-flymake-proselint-backend (report-fn &rest _args)
  "Flymake backend for Proselint.
REPORT-FN is the flymake reporter function.  See the Info
node (flymake) Backend functions for more details."
  (unless (executable-find flymake-proselint-executable)
    (user-error "Executable proselint not found on PATH"))

  (when (process-live-p flymake-proselint--flymake-proc)
    (kill-process flymake-proselint--flymake-proc))

  (let ((proc (make-process
               :name "proselint-flymake" :noquery t :connection-type 'pipe
               :buffer (generate-new-buffer " *proselint-flymake*")
               :command
               (if-let* ((conf (flymake-proselint-generate-configuration)))
                   (list flymake-proselint-executable "--config" conf "--json" "-")
                 (list flymake-proselint-executable "--json" "-"))
               :sentinel #'flymake-proselint-sentinel)))
    (process-put proc 'source (current-buffer))
    (process-put proc 'report-fn report-fn)
    (setq flymake-proselint--flymake-proc proc)
    (save-restriction
      (widen)
      (process-send-region proc (point-min) (org-msg-end))
      (process-send-eof proc))))

(defun org-msg-flymake-proselint-setup ()
  "Enable Flymake backend proselint."
  (add-hook 'flymake-diagnostic-functions #'org-msg-flymake-proselint-backend nil t))

(add-hook 'org-msg-edit-mode-hook #'flymake-mode)
(add-hook 'org-msg-edit-mode-hook #'org-msg-flymake-proselint-setup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants