emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextLint: Check your scientific writing from Emacs


From: Seweryn Kokot
Subject: Re: TextLint: Check your scientific writing from Emacs
Date: Fri, 9 Sep 2011 11:22:10 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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)
----------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]