initial commit
[emacs-init.git] / nxhtml / util / ocr-user.el
1 ;;; ocr-user.el --- Input looong OCR number more safely
2 ;;
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2008-06-18T23:00:25+0200 Wed
5 ;; Version:
6 ;; Last-Updated:
7 ;; URL:
8 ;; Keywords:
9 ;; Compatibility:
10 ;;
11 ;; Features that might be required by this library:
12 ;;
13 ;;   None
14 ;;
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;
17 ;;; Commentary:
18 ;;
19 ;; I just get mad at entering OCR numbers more than twenty digits long
20 ;; so I wrote this litte minor mode that colors up the digits three by
21 ;; tree.
22 ;;
23 ;; To use it do
24 ;;
25 ;;   M-x ocr-user-mode
26 ;;
27 ;; Crazy? Yeah, I get crazy by entering these digits. You would not
28 ;; like to meet me when I have done that!
29 ;;
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31 ;;
32 ;;; Change log:
33 ;;
34 ;;
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36 ;;
37 ;; This program is free software; you can redistribute it and/or
38 ;; modify it under the terms of the GNU General Public License as
39 ;; published by the Free Software Foundation; either version 2, or
40 ;; (at your option) any later version.
41 ;;
42 ;; This program is distributed in the hope that it will be useful,
43 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
44 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
45 ;; General Public License for more details.
46 ;;
47 ;; You should have received a copy of the GNU General Public License
48 ;; along with this program; see the file COPYING.  If not, write to
49 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
50 ;; Floor, Boston, MA 02110-1301, USA.
51 ;;
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
53 ;;
54 ;;; Code:
55
56 (defconst ocr-keywords
57   `((
58      ,(concat
59       ;;"\\<\\(?:"
60       "\\(?1:[0-9]\\{3\\}\\)"
61       "\\(?2:[0-9]\\{3\\}\\)?"
62       ;;"\\)+"
63       )
64      (0 (progn
65           (put-text-property (match-beginning 1) (match-end 1)
66                              'face '(:background "LightBlue1"))
67           (when (match-beginning 2)
68             (put-text-property (match-beginning 2) (match-end 2)
69                                'face '(:background "PaleGreen1"))))))))
70
71 ;; 23456
72 ;; 1234567890
73 ;; 346789238
74 ;;;###autoload
75 (define-minor-mode ocr-user-mode
76   "Color up digits three by three."
77   :group 'convenience
78   (if ocr-user-mode
79       (font-lock-add-keywords nil ocr-keywords)
80     (font-lock-remove-keywords nil ocr-keywords))
81   (font-lock-fontify-buffer))
82
83
84 (provide 'ocr-user)
85 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
86 ;;; ocr-user.el ends here