app/write: major refactor+rewrite
+ Make synosaurus unconditional + Move much of +write-mode into its hook + Conform README.org to template and expand it + Try to guess langtool-language-tool-jar + Update init.example.el entry + Remove redundant variables + Add +write-text-scale & +text-line-spacing variables
This commit is contained in:
parent
896ca67076
commit
3080b68c84
5 changed files with 178 additions and 76 deletions
|
@ -134,7 +134,9 @@
|
|||
;irc ; how neckbeards socialize
|
||||
;rss ; emacs as an RSS reader
|
||||
;twitter ; twitter client https://twitter.com/vnought
|
||||
;; (write +synosaurus +wordnut +langtool) ; emacs as a word processor (latex + org + markdown)
|
||||
;(write ; emacs as a word processor (latex + org + markdown)
|
||||
; +wordnut ; wordnet (wn) search
|
||||
; +langtool) ; a proofreader (grammar/style check) for Emacs
|
||||
|
||||
;; Private modules are where you place your personal configuration files.
|
||||
;; By default, they are not tracked. There is one module included here,
|
||||
|
|
|
@ -1,39 +1,113 @@
|
|||
* +langtool
|
||||
:PROPERTIES:
|
||||
:ID: AE6DA5B3-6859-47D9-A483-972D42F0E11B
|
||||
:END:
|
||||
Support for languagetool
|
||||
#+TITLE: :app write
|
||||
|
||||
For installation of languagetool, please checkout https://languagetool.org/. Noted that you need Java to run languagetool.
|
||||
Adds word processing tools and the ~+write-mode~ minor mode, which converts
|
||||
Emacs into a more comfortable writing environment.
|
||||
|
||||
MacOS users can install languagetool using ~brew~:
|
||||
#+BEGIN_SRC bash
|
||||
brew install languagetool
|
||||
#+END_SRC
|
||||
* Table of Contents :TOC:
|
||||
- [[Features][Features]]
|
||||
- [[~M-x +write-mode~][~M-x +write-mode~]]
|
||||
- [[Language Tool ~+langtool~][Language Tool ~+langtool~]]
|
||||
- [[Wordnut ~+wordnut~][Wordnut ~+wordnut~]]
|
||||
- [[Synosaurus][Synosaurus]]
|
||||
- [[Prerequisites][Prerequisites]]
|
||||
- [[Language Tool][Language Tool]]
|
||||
- [[Wordnut][Wordnut]]
|
||||
- [[Configuration][Configuration]]
|
||||
- [[mixed-pitch-mode][mixed-pitch-mode]]
|
||||
- [[Appendix][Appendix]]
|
||||
- [[Minor modes][Minor modes]]
|
||||
- [[Commands][Commands]]
|
||||
|
||||
After installation, you need to find out the path of the ~jar~ file and set it as ~+langtool-jar-path~.
|
||||
* Features
|
||||
This module provides two module flags:
|
||||
|
||||
* +wordnut
|
||||
:PROPERTIES:
|
||||
:ID: 005E9DD8-DE23-4A69-B423-8950B5E23059
|
||||
:END:
|
||||
This use ~wordnut~ package to provide a dictionary in Emacs.
|
||||
Commands avaliable:
|
||||
- ~+langtool~ Enables language tool integration.
|
||||
- ~+wordnut~ Enables wordnet integration.
|
||||
|
||||
** ~M-x +write-mode~
|
||||
Write mode makes Emacs a more comfortable writing environment by:
|
||||
|
||||
- Centering the buffer (with ~visual-fill-column-mode~), ala distraction-free
|
||||
mode from other text editors.
|
||||
- Soft-wrapping long text lines with ~visual-line-mode~.
|
||||
- Enabling ~mixed-pitch-mode~, allowing fixed-width and variable-pitch fonts to
|
||||
co-exist in one buffer. For example, a monospace font for SRC blocks and Arial
|
||||
for everything else.
|
||||
- In org-mode:
|
||||
- Turns on ~org-indent-mode~
|
||||
- Turns on ~+org-pretty-mode~
|
||||
|
||||
** Language Tool ~+langtool~
|
||||
[[https://www.languagetool.org/][Language Tool]] is a polyglot proofreader service that checks for grammar and
|
||||
stylistic issues in your writing. This requires Java 1.8+.
|
||||
|
||||
#+begin_quote
|
||||
This requires Java 1.8+
|
||||
#+end_quote
|
||||
|
||||
*** Commands
|
||||
- ~langtool-check~
|
||||
- ~langtool-correct-buffer~
|
||||
|
||||
** Wordnut ~+wordnut~
|
||||
Wordnut provides a searchable dictionary frontend for Emacs. This requires
|
||||
~wordnet~, which should be available in your OS's package manager.
|
||||
|
||||
*** Commands
|
||||
- ~wordnut-search~
|
||||
- ~wordnut-lookup-curent-word~
|
||||
|
||||
* +synosaurus
|
||||
:PROPERTIES:
|
||||
:ID: 005E9DD8-DE23-4A69-B423-8950B5E23059
|
||||
:END:
|
||||
This use ~synosaurus~ package to provide a dictionary in Emacs.
|
||||
Commands avaliable:
|
||||
- ~synosaurus-mode~
|
||||
** Synosaurus
|
||||
Synosaurus provides a service for looking up synonyms. It requires an internet
|
||||
connection.
|
||||
|
||||
*** Commands
|
||||
- ~synosaurus-lookup~
|
||||
- ~synosaurus-choose-and-replace~
|
||||
|
||||
* mixed-pitch
|
||||
:PROPERTIES:
|
||||
:ID: 417B004D-2E33-4071-894F-0792CB22B3D5
|
||||
:END:
|
||||
This package enable fixed-width font and variable-pitch font coexist in the same buffer": you can use ~Fira code~ for code blocks in org mode file where use ~Ariel~ for main content (if you want...).
|
||||
* Prerequisites
|
||||
** Language Tool
|
||||
Either download and deploy it from https://languagetool.org/ or install it
|
||||
through your OS package manager:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
# MacOS/Homebrew users:
|
||||
brew install languagetool
|
||||
|
||||
# Arch Linux users:
|
||||
sudo pacman -S languagetool
|
||||
#+END_SRC
|
||||
|
||||
This module tries to guess the location of languagetool-commandline.jar. If you
|
||||
get a warning that Doom =couldn't find languagetool-commandline.jar=, you will
|
||||
need to find langaugetool-commandline.jar and set ~langtool-language-tool-jar~
|
||||
to its path.
|
||||
|
||||
** Wordnut
|
||||
This requires =wordnet= to be installed, which should be available through your
|
||||
OS package manager:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
# MacOS/Homebrew users:
|
||||
brew install wordnet
|
||||
|
||||
# Arch Linux users:
|
||||
sudo pacaur -S wordnet # on the AUR
|
||||
#+END_SRC
|
||||
|
||||
* Configuration
|
||||
** mixed-pitch-mode
|
||||
To configure which faces are displayed with fixed-pitch fonts in
|
||||
~mixed-pitch-mode~, look into ~mixed-pitch-fixed-pitch-faces~.
|
||||
|
||||
* Appendix
|
||||
** Minor modes
|
||||
- ~+write-mode~
|
||||
- ~mixed-pitch-mode~
|
||||
** Commands
|
||||
- ~langtool-check~
|
||||
- ~langtool-correct-buffer~
|
||||
- ~synosaurus-choose-and-replace~
|
||||
- ~synosaurus-lookup~
|
||||
- ~wordnut-lookup-curent-word~
|
||||
- ~wordnut-search~
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
|
||||
;;;###autoload
|
||||
(define-minor-mode +write-mode
|
||||
"TODO"
|
||||
"Turns Emacs into a more comfortable writing environment and word processor."
|
||||
:init-value nil
|
||||
:keymap nil
|
||||
(let ((arg (if +write-mode +1 -1))
|
||||
(iarg (if +write-mode -1 +1)))
|
||||
(text-scale-set (if +write-mode 2 0))
|
||||
(doom/toggle-line-numbers iarg)
|
||||
(setq-local visual-fill-column-center-text +write-mode)
|
||||
(visual-fill-column-mode arg)
|
||||
(visual-line-mode arg)
|
||||
(when (eq major-mode 'org-mode)
|
||||
(mixed-pitch-mode arg)
|
||||
(+org-pretty-mode arg))
|
||||
(setq line-spacing (if +write-mode 4))))
|
||||
(setq-local visual-fill-column-center-text t)
|
||||
(when +write-text-scale
|
||||
(text-scale-set (if +write-mode 2 0)))
|
||||
(when +write-line-spacing
|
||||
(setq-local line-spacing +write-line-spacing)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +write|init-org-mode ()
|
||||
"Initializes `org-mode' specific settings for `+write-mode'."
|
||||
(when (eq major-mode 'org-mode)
|
||||
(let ((arg (if +write-mode +1 -1)))
|
||||
(+org-pretty-mode arg)
|
||||
(org-indent-mode (if +write-mode -1 +1)))))
|
||||
|
|
|
@ -1,12 +1,25 @@
|
|||
;;; app/write/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +write-text-scale nil
|
||||
"What to scale the text up to in `+write-mode'. Uses `text-scale-set'.")
|
||||
|
||||
(defvar +write-line-spacing nil
|
||||
"What to set `line-spacing' in `+write-mode'.")
|
||||
|
||||
(add-hook! '+write-mode-hook
|
||||
#'(flyspell-mode
|
||||
visual-fill-column-mode
|
||||
visual-line-mode
|
||||
mixed-pitch-mode
|
||||
doom|enable-line-numbers
|
||||
+write|init-org-mode))
|
||||
|
||||
|
||||
;;
|
||||
;; Plugins
|
||||
;;
|
||||
|
||||
(when (featurep! +langtool)
|
||||
(defvar +langtool-default-lang "en-US"
|
||||
"default language for langtool")
|
||||
(defvar +langtool-mother-tongue nil
|
||||
"mother tongue of user")
|
||||
(defvar +langtool-jar-path "/usr/local/Cellar/languagetool/4.0/libexec/languagetool-commandline.jar"
|
||||
"TODO")
|
||||
(def-package! langtool
|
||||
:commands (langtool-check
|
||||
langtool-check-done
|
||||
|
@ -14,22 +27,34 @@
|
|||
langtool-show-message-at-point
|
||||
langtool-correct-buffer)
|
||||
:init
|
||||
(setq langtool-default-language +langtool-default-lang
|
||||
langtool-mother-tongue +langtool-mother-tongue
|
||||
langtool-language-tool-jar +langtool-jar-path)))
|
||||
(setq langtool-default-language "en-US")
|
||||
:config
|
||||
(unless langtool-language-tool-jar
|
||||
(setq langtool-language-tool-jar
|
||||
(cond (IS-MAC
|
||||
"/usr/local/Cellar/languagetool/4.0/libexec/languagetool-commandline.jar")
|
||||
(IS-LINUX
|
||||
"/usr/share/java/languagetool/languagetool-commandline.jar")))
|
||||
(unless (file-exists-p langtool-language-tool-jar)
|
||||
(warn "langtool: couldn't find languagetool-commandline.jar")))))
|
||||
|
||||
|
||||
(when (featurep! +wordnut)
|
||||
(def-package! wordnut
|
||||
:commands (wordnut-search
|
||||
wordnut-lookup-current-word)))
|
||||
(when (featurep! +synosaurus)
|
||||
|
||||
|
||||
(def-package! synosaurus
|
||||
:commands (synosaurus-mode
|
||||
synosaurus-lookup
|
||||
synosaurus-choose-and-replace)
|
||||
:init
|
||||
(require 'synosaurus-wordnet)
|
||||
:config
|
||||
(setq synosaurus-choose-method 'default)))
|
||||
(setq synosaurus-choose-method 'default))
|
||||
|
||||
(def-package! synosaurus-wordnet
|
||||
:commands synosaurus-backend-wordnet)
|
||||
|
||||
|
||||
(def-package! mixed-pitch
|
||||
:config
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; app/write/packages.el
|
||||
|
||||
(package! synosaurus)
|
||||
(package! mixed-pitch)
|
||||
|
||||
(when (featurep! +langtool)
|
||||
(package! langtool))
|
||||
(when (featurep! +wordnut)
|
||||
(package! wordnut))
|
||||
(when (featurep! +synosaurus)
|
||||
(package! synosaurus))
|
||||
|
||||
(package! mixed-pitch)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue