Skip to content

Commit

Permalink
add proselint layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mkcode committed Mar 7, 2016
1 parent 895455d commit 27199b4
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
52 changes: 52 additions & 0 deletions layers/proselint/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#+TITLE: proselint layer
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../css/readtheorg.css" />

#+CAPTION: logo

# The maximum height of the logo should be 200 pixels.
[[img/proselint.png]]

* Table of Contents :TOC_4_org:noexport:
- [[Description][Description]]
- [[Install][Install]]
- [[Key bindings][Key bindings]]

* Description

This layer hooks [[https://github.com/amperser/proselint][proselint]] into flycheck to making typing go good, obviously.

While flycheck-proselint is enabled (via the toggle or the config var), it
will take precedence and be the ONLY functioning flycheck checker. Toggling
it off will return the normal flycheck functioning to the buffer.

It is possible to manually change this behavior using the
`flycheck-add-next-checker` function.

* Install

Install the proselint executable. Make sure it is in your $PATH.

#+begin_src sh
pip install proselint
#+end_src

Add the following to your =~/.spacemacs=

#+begin_src emacs-lisp
(setq-default dotspacemacs-configuration-layers '(proselint))
#+end_src

You may have proselint available but not started immediately by setting the
`enable-proselint-feedback` variable to `nil`.

#+begin_src emacs-lisp
(setq-default dotspacemacs-configuration-layers '(proselint :variables
enable-proselint-feedback nil))
#+end_src

* Key bindings

| Key Binding | Description |

This comment has been minimized.

Copy link
@JAremko

JAremko Mar 8, 2016

The table layout is broken on GitHub. Probably because it has a gap - | should be --|

|--------------+--------------------------------------------------- |
| ~<SPC> t P~ | Toggles the proselint flycheck feedback on and off |

15 changes: 15 additions & 0 deletions layers/proselint/config.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
;;; packages.el --- proselint layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Chris Ewald <chrisewald@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defvar enable-proselint-feedback t
"Non-nil if proselint feedback should be started automatically.")

;; (length flycheck-checkers)
45 changes: 45 additions & 0 deletions layers/proselint/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
;;; packages.el --- proselint layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Chris Ewald <chrisewald@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defconst proselint-packages
'(flycheck))

(defun proselint/post-init-flycheck ()

(defun flycheck-proselint-enabled-p ()
enable-proselint-feedback)

(flycheck-define-checker proselint
"A linter for prose."
:command ("proselint" source-inplace)
:error-patterns
((warning line-start (file-name) ":" line ":" column ": "
(id (one-or-more (not (any " "))))
(message (one-or-more not-newline)
(zero-or-more "\n" (any " ") (one-or-more not-newline)))
line-end))
:predicate flycheck-proselint-enabled-p)
;; :modes (text-mode markdown-mode gfm-mode))

(add-to-list 'flycheck-checkers 'proselint)

(spacemacs|add-toggle flycheck-proselint
:status enable-proselint-feedback
:on (progn
(setq enable-proselint-feedback t)
(flycheck-buffer))
:off (progn
(setq enable-proselint-feedback nil)
(flycheck-buffer))
:documentation "Better writing with proselint feedback."
:evil-leader "tP"))

;;; packages.el ends here

0 comments on commit 27199b4

Please sign in to comment.