unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Seweryn Kokot <sewkokot@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: TextLint: Check your scientific writing from Emacs
Date: Fri, 9 Sep 2011 11:22:10 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110909T131038-72@post.gmane.org> (raw)
In-Reply-To: CA+y5ggj0UJUnGj+dzEQtvyt8_FXx-GZPKc06faCWjGPi3j4YwQ@mail.gmail.com

Damien Cassou <damien.cassou <at> gmail.com> writes:

> 
> TextLint is a tool to check your scientific writing for common style
> errors from Emacs:
> 
> http://www.youtube.com/watch?v=CsG2DKgHanE
> 
> For additional information, please see
> http://www.emacswiki.org/emacs-en/TextLint
> 
> Feedback is highly appreciated
> 

I created a proof of concept for a subset of features found in TextLint using 
just emacs lisp. This way you don't need any external tools. It is based on 
searching predefined words or group of words in the current buffer with M-x my-
check-my-writing. This command gives another buffer *WritingCheck* where you 
can navigate through the issues using RET, TAB and SPC.

You need to populate my-writing-words-check variable to your wishes.

Regards,
Seweryn

----- in .emacs -----
(require 'my-writing-check-mode nil t)
(define-key my-writing-check-mode-map (kbd "RET") 'my-writing-check-goto-line)
(define-key my-writing-check-mode-map (kbd "TAB") 'my-writing-check-goto-line)
(define-key my-writing-check-mode-map (kbd "SPC") 'my-writing-check-see-
context)

(setq my-writing-words-check
      '(
;; add here more entries ("words to look for" "explanation what is wrong")
		("in the absence of" "without?")
		("exhibit" "show")
        ))


-------- my-writing-check-mode.el --------
(define-derived-mode my-writing-check-mode fundamental-mode "Writing Check"
"My writing grammar and style check mode")

(defvar my-writing-words-check nil 
"List of words, phrases to search and explanation of what is wrong.") 
(defvar my-writing-check-orig-buffer nil "Original buffer with text to check")
(defvar my-writing-check-check-buffer "*WritingCheck*" "Writing check buffer 
name")

(defun my-check-my-writing ()
  "Check my written text and suggest improvements or corrections"
  (interactive)
  (save-excursion
	(let (line-num)
	  (setq my-writing-check-orig-buffer (window-buffer))
	  (set-buffer (get-buffer-create my-writing-check-check-buffer))
	  (erase-buffer)
	  (set-buffer my-writing-check-orig-buffer)
	  (goto-char (point-min))
	  (loop for (my-words comment) in my-writing-words-check do
			(save-excursion 
			  (while (word-search-forward my-words nil t)
			  ;; (message "line:%s, used: \"%s\", better: \"%s\"" 
			  ;; (message "line:%s, \"%s\" --> \"%s\"" 
			  (setq line-num (line-number-at-pos))
			  (save-excursion 
				(set-buffer my-writing-check-check-buffer)
				(insert (format "%5s: \"%s\" --> \"%s\"\n" 
								line-num my-
words comment)))
			(set-buffer (get-buffer my-writing-check-orig-buffer))
			)))
	(pop-to-buffer my-writing-check-check-buffer)
	(goto-char (point-min))
	(my-writing-check-mode)
	)))

(defalias 'my-writing-check 'my-check-my-writing)

(defun my-writing-check-goto-line ()
  (interactive)
  (save-excursion
	(let (lbp linnum string1)
	  (setq lbp (line-beginning-position))
	  (message "%s %s %s" my-writing-check-orig-buffer my-writing-check-
check-buffer lbp)
	  (goto-char lbp)
	  (re-search-forward "[ ]*\\([0-9]+\\): \"\\(.*\\)\" -->" nil t)
	  (setq linnum (match-string 1))
	  (setq string1 (match-string 2))
	  (pop-to-buffer my-writing-check-orig-buffer)
	  (goto-line (string-to-number linnum))
	  )))

(defun my-writing-check-see-context ()
  (interactive)
  (save-excursion
	(let (lbp linnum string1)
	  (setq lbp (line-beginning-position))
	  (message "%s %s %s" my-writing-check-orig-buffer my-writing-check-
check-buffer lbp)
	  (goto-char lbp)
	  (re-search-forward "[ ]*\\([0-9]+\\): \"\\(.*\\)\" -->" nil t)
	  (setq linnum (match-string 1))
	  (setq string1 (match-string 2))
	  (pop-to-buffer my-writing-check-orig-buffer)
	  (goto-line (string-to-number linnum))
	  (pop-to-buffer my-writing-check-check-buffer)
	  )))

(provide 'my-writing-check-mode)
----------------------------------------------------------------------------





      parent reply	other threads:[~2011-09-09 11:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-08 10:48 TextLint: Check your scientific writing from Emacs Damien Cassou
2011-09-08 12:08 ` Antoine Levitt
2011-09-08 16:03   ` Lennart Borgman
2011-09-08 16:35     ` Damien Cassou
2011-09-08 17:22       ` Bastien
2011-09-08 18:16         ` Lluís
2011-09-08 19:57           ` Juri Linkov
2011-09-09  6:09   ` Damien Cassou
2011-09-09 11:22 ` Seweryn Kokot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20110909T131038-72@post.gmane.org \
    --to=sewkokot@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).