#+TITLE: Emacs Writing Configuration
#+property: header-args :tangle ~/.emacs.d/modules/writing.el

* Spell Checking
#+begin_src elisp
  (use-package flyspell
    :config (setq ispell-program-name "hunspell"
                  ispell-default-dictionary "en_US"
                  )
    :diminish (flyspell-mode . "φ")
    :hook (text-mode . flyspell-mode)
    :bind (
           ("M-<f7>" . flyspell-buffer)
           ("<f7>" . flyspell-word)
           ("C-;" . flyspell-auto-correct-previous-word)
           )
    )
#+end_src

* Syntax Checking
#+begin_src elisp
  (use-package flycheck
    :init (global-flycheck-mode)
    :diminish (flycheck-mode . "")
    :config
    (add-hook 'after-init-hook #'global-flycheck-mode)
    (setq flycheck-emacs-lisp-load-path 'inherit)
    (setq flycheck-emacs-lisp-load-path (concat user-emacs-directory "straight/build"))
    )
#+end_src

* Text Manipulation
#+begin_src elisp
  (subword-mode)
  (setq sentence-end-double-space nil)

  (defun my/fill-or-unfill-paragraph (&optional unfill region)
    "Fill paragraph (or REGION). With the prefix argument UNFILL, fill it instead."
    (interactive (progn
                   (barf-if-buffer-read-only)
                   (list (if current-prefix-arg 'fill) t)))
    (let ((fill-column (if unfill fill-column (point-max))))
      (fill-paragraph nil region)))

  (bind-key "M-q" 'my/fill-or-unfill-paragraph)

  (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
#+end_src
