Last active
June 15, 2016 13:43
-
-
Save karronoli/455f8d9c41b840826959dc454d3a176a to your computer and use it in GitHub Desktop.
textlint I/F by redpen-paragraph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq compilation-error-screen-columns nil) | |
(setq redpen-commands | |
'("textlint -f json --rule no-mix-dearu-desumasu --rule max-ten --rule spellcheck-tech-word %s" | |
"textlint -f json --rule no-mix-dearu-desumasu --rule max-ten --rule spellcheck-tech-word %s")) | |
(defun redpen-paragraph-list-errors (json) | |
(cl-assert (vectorp json)) | |
;; Split window as well as usual compilation-mode. | |
(switch-to-buffer-other-window (current-buffer)) | |
(set-buffer redpen-paragraph-compilation-buffer-name) | |
(mapc | |
(lambda (message) | |
(let ((sentence "-") | |
;; Emacs displays from the 1st line. | |
(start-line | |
(max | |
(+ (car redpen-paragraph-beginning-position) | |
(plist-get message :line)) | |
1)) | |
;; Add cursor offset to RedPen offset only in the 1st line | |
(start-offset | |
(+ (plist-get message :column) | |
(if (eq 1 (plist-get message :line)) | |
(cdr redpen-paragraph-beginning-position) 0)))) | |
(insert (format | |
redpen-paragraph-input-pattern | |
(plist-get message :type) | |
start-line start-offset start-line start-offset | |
(plist-get message :message))) | |
(insert "\n"))) | |
(plist-get (elt json 0) :messages)) | |
;; According to `redpen-paragraph-input-regexp', | |
;; Parse `redpen-paragraph-input-pattern' in `compilation-mode'. | |
(compilation-mode) | |
(goto-char (point-min))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment