importing greclusters into git
[greclusters.git] / wl / wl-mode.el
blob64e80508d4e7c677232c1e4acfac81c8e170c728
1 ;;; wl-mode -- Major mode for studying GRE Word Lists
3 ;; Author: Sridhar Ratna <http://srid.nfshost.com/>
4 ;; Created:
5 ;; Keywords: GRE Word List major-mode
7 ;; Copyright (C) 2007 Sridhar Ratna
9 ;; This program is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU General Public License as
11 ;; published by the Free Software Foundation; either version 2 of
12 ;; the License, or (at your option) any later version.
14 ;; This program is distributed in the hope that it will be
15 ;; useful, but WITHOUT ANY WARRANTY; without even the implied
16 ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17 ;; PURPOSE. See the GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public
20 ;; License along with this program; if not, write to the Free
21 ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 ;; MA 02111-1307 USA
24 ;; TODO
25 ;; - documentation + sample word lists (barrons)
26 ;; - custom font faces
28 (defvar wl-mode-hook nil)
30 (defun wl-mark (ch)
31 (wl-unmark)
32 (beginning-of-line)
33 (subst-char-in-region (point) (+ 1 (point)) ? ch))
35 ; Difficult word; `being' learned
36 (defun wl-mark-star ()
37 (interactive)
38 (wl-mark ?*))
40 ; Difficult word; `able' to recall
41 (defun wl-mark-plus ()
42 (interactive)
43 (wl-mark ?+))
45 ; Easy word; always remembering
46 (defun wl-mark-dash ()
47 (interactive)
48 (wl-mark ?-))
50 (defun wl-unmark ()
51 (interactive)
52 (beginning-of-line)
53 (subst-char-in-region (point) (+ 1 (point)) ?* ? )
54 (subst-char-in-region (point) (+ 1 (point)) ?+ ? )
55 (subst-char-in-region (point) (+ 1 (point)) ?- ? ))
57 (defun wl-goto-random ()
58 (interactive)
59 (random t)
60 (goto-line (+ 1
61 (random (count-lines (point-min)
62 (point-max))))))
64 (defvar wl-mode-map
65 (let ((wl-mode-map (make-keymap)))
66 (define-key wl-mode-map "\C-c\C-u" 'wl-unmark)
67 (define-key wl-mode-map (kbd "<f4>") 'wl-mark-star)
68 (define-key wl-mode-map (kbd "C-<f4>") 'wl-mark-plus)
69 (define-key wl-mode-map "\C-c\C-r" 'wl-mark-dash)
70 (define-key wl-mode-map (kbd "<f5>") 'wl-goto-random)
71 wl-mode-map)
72 "Keymap for WL major mode")
74 ;(add-to-list 'auto-mode-alist '("\\.wl\\'" . wl-mode))
76 (defconst wl-font-lock-keywords-1
77 (list
78 '("^\\*.[a-z]+" . font-lock-keyword-face)
79 '("^-.[a-z]+" . font-lock-comment-face)
80 '("^+.[a-z]+" . font-lock-comment-face)
81 '("^..[a-z]+" . font-lock-constant-face))
82 "Highlighting for WL major mode")
84 (defvar wl-font-lock-keywords wl-font-lock-keywords-1
85 "Default highlighting expressions for WL mode")
88 (defun wl-mode ()
89 "Major mode for studying GRE Word Lists"
90 (interactive)
91 (kill-all-local-variables)
92 (use-local-map wl-mode-map)
93 (set (make-local-variable 'font-lock-defaults) '(wl-font-lock-keywords))
94 (global-hl-line-mode 1) ;; FIXME: this is not `local' to the buffer
95 (setq major-mode 'wl-mode)
96 (setq mode-name "Word List")
97 (run-hooks 'wl-mode-hook))
99 (provide 'wl-mode)