summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-04 23:26:42 -0600
committerCraig Jennings <c@cjennings.net>2025-11-04 23:26:42 -0600
commiteda461086e94265b67ab5b21032e7ee23112ad87 (patch)
tree90983461736e8b7f0aa435a7b1fddb4b2825cefa /modules
parentb520add37ae23f0411e2c6512fe6b8d7418bd525 (diff)
feat: Add LanguageTool integration for comprehensive grammar checking
Integrated LanguageTool as an on-demand grammar checker, replacing the previously disabled proselint checker. Changes: - Created scripts/languagetool-flycheck wrapper for flycheck integration - Converts LanguageTool JSON output to flycheck format - Includes suggestions in error messages - 30-second timeout for large files - Updated modules/flycheck-config.el: - Defined languagetool checker for text/markdown/org/gfm modes - Updated cj/flycheck-prose-on-demand to use LanguageTool - Added installation instructions (sudo pacman -S languagetool) - Improved documentation clarity - Usage: Press C-; ? in org/text/markdown files - Enables flycheck with LanguageTool - Shows errors in *Flycheck errors* buffer - On-demand only (no performance impact) - Updated docs/NOTES.org: - Added best practice: Test Emacs launch after non-trivial changes - Example: emacs --eval "(kill-emacs)" - Catches startup errors before committing - Disabled weather debug mode (wttrin-debug nil) - Marked todo.org grammar checker task as DONE LanguageTool catches real grammar issues (subject-verb agreement, tense, punctuation, common mistakes) that proselint missed. Installation: LanguageTool 6.6 (222MB) from Arch repos Dependencies: Python 3 (for wrapper script) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/flycheck-config.el54
-rw-r--r--modules/weather-config.el2
2 files changed, 29 insertions, 27 deletions
diff --git a/modules/flycheck-config.el b/modules/flycheck-config.el
index ea19f08f..e2e8abe9 100644
--- a/modules/flycheck-config.el
+++ b/modules/flycheck-config.el
@@ -6,30 +6,30 @@
;; This file configures Flycheck for on-demand syntax and grammar checking.
;; - Flycheck starts automatically only in sh-mode and emacs-lisp-mode
-;; - This binds a custom helper (=cj/flycheck-list-errors=) to “C-; ?”
+;; - This binds a custom helper (=cj/flycheck-list-errors=) to "C-; ?"
;; for popping up Flycheck's error list in another window.
-;; - It also customizes Checkdoc to suppress only the “sentence-end-double-space”
-;; and “warn-escape” warnings.
+;; - It also customizes Checkdoc to suppress only the "sentence-end-double-space"
+;; and "warn-escape" warnings.
-;; - It registers a Proselint checker for prose files
-;; (text-mode, markdown-mode, gfm-mode).
+;; - It registers LanguageTool for comprehensive grammar checking of prose files
+;; (text-mode, markdown-mode, gfm-mode, org-mode).
-;; Note: I do use proselint quite a bit in emails and org-mode files. However, some
-;; org-files can be large and running proselint on them will slow Emacs to a crawl.
-;; Therefore, hitting "C-; ?" also runs cj/flycheck-prose-on-demand if in an org buffer.
+;; Note: Grammar checking is on-demand only to avoid performance issues.
+;; Hitting "C-; ?" runs cj/flycheck-prose-on-demand if in an org buffer.
-;;
;; The cj/flycheck-prose-on-demand function:
;; - Turns on flycheck for the local buffer
-;; - ensures proselint is added
-;; - triggers an immediate check
-;;
-;; Since this is called within cj/flycheck-list-errors, flycheck's error list will still
-;; display and the focus transferred to that buffer.
+;; - Enables LanguageTool checker
+;; - Triggers an immediate check
+;; - Displays errors in the *Flycheck errors* buffer
-;; OS Dependencies:
-;; proselint (in the Arch AUR)
+;; Installation:
+;; On Arch Linux:
+;; sudo pacman -S languagetool
+;;
+;; The wrapper script at scripts/languagetool-flycheck formats LanguageTool's
+;; JSON output into flycheck-compatible format. It requires Python 3.
;;; Code:
@@ -62,20 +62,20 @@
;; use the load-path of the currently running Emacs instance
(setq flycheck-emacs-lisp-load-path 'inherit)
- ;; Define the prose checker (installed separately via OS).
- (flycheck-define-checker proselint
- "A linter for prose."
- :command ("proselint" source-inplace)
+ ;; Define LanguageTool checker for comprehensive grammar checking
+ (flycheck-define-checker languagetool
+ "A grammar checker using LanguageTool.
+Uses a wrapper script to format output for flycheck."
+ :command ("~/.emacs.d/scripts/languagetool-flycheck"
+ source-inplace)
:error-patterns
((warning line-start (file-name) ":" line ":" column ": "
- (id (one-or-more (not (any " "))))
(message) line-end))
:modes (text-mode markdown-mode gfm-mode org-mode))
- (add-to-list 'flycheck-checkers 'proselint)
+ (add-to-list 'flycheck-checkers 'languagetool)
(defun cj/flycheck-list-errors ()
"Display flycheck's error list and switch to its buffer.
-
Runs flycheck-prose-on-demand if in an org-buffer."
(interactive)
(when (derived-mode-p 'org-mode)
@@ -85,12 +85,14 @@ Runs flycheck-prose-on-demand if in an org-buffer."
(switch-to-buffer-other-window "*Flycheck errors*"))
(defun cj/flycheck-prose-on-demand ()
- "Enable Flycheck+Proselint in this buffer, run it, and show errors."
+ "Enable Flycheck with LanguageTool in this buffer, run it, and show errors."
(interactive)
;; turn on Flycheck locally
(flycheck-mode 1)
- ;; ensure proselint is valid for org/text
- (flycheck-add-mode 'proselint major-mode)
+ ;; ensure LanguageTool is valid for current mode
+ (flycheck-add-mode 'languagetool major-mode)
+ ;; select LanguageTool as the checker
+ (setq-local flycheck-checker 'languagetool)
;; trigger immediate check
(flycheck-buffer)))
diff --git a/modules/weather-config.el b/modules/weather-config.el
index 55eddf16..3a30aa17 100644
--- a/modules/weather-config.el
+++ b/modules/weather-config.el
@@ -14,7 +14,7 @@
(add-to-list 'load-path "/home/cjennings/code/wttrin")
;; Set debug flag BEFORE loading wttrin (checked at load time)
-(setq wttrin-debug t)
+(setq wttrin-debug nil)
(use-package wttrin
;; Uncomment the next line to use vc-install instead of local directory: