1

I would like to combine flyspell-region with writegood-mode, but writegood-mode does not provide a function to check a region of text.

This is what I came up with to work around the limitation:

(defun writegood-region (beginning end)
  "Check style between BEGINNING and END."
  (interactive "r")
  (narrow-to-region beginning end)
  (writegood-mode)
  (widen))

(defun prose-check-region (beginning end)
  "Check spelling and style between BEGINNING and END."
  (interactive "r")
  (when (use-region-p)
    (writegood-region beginning end)
    (flyspell-region beginning end)
    (setq deactivate-mark t)))

The problem is that writegood-mode remains enabled after the function writegood-region returns.

Any ideas?

Cross-posted: https://github.com/bnbeckwith/writegood-mode/issues/30

7
  • Why not just toggle writegood-modeafter the (widen)? Or am I missing something? May 24 at 11:16
  • @FranBurstall That is what I had thought would work. But, when I toggle (turn off) writegood-mode after (widen), the highlights (fontification) is gone as well. May 24 at 18:21
  • To expressly turn off a minor-mode, Emacs uses: (writegood-mode -1). To expressly turn on a minor-mode on, Emacs uses (writegood-mode 1). This is generally the same for all minor-modes.
    – lawlist
    May 26 at 5:08
  • There is nothing I see in the code of writegood-mode that removes / deletes overlays, whether it be flyspell overlays or any other overlays.
    – lawlist
    May 26 at 5:17
  • @lawlist I must be missing something. When I turn writegood-mode on and off via M-x, the highlights show/hide, as expected. In my function, I would like the highlights to stay (for the region) even after the mode is turned off. flyspell has the same behavior, but it also provides flyspell-region that keeps the highlights in place. May 26 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.