26da79d7a68667b529f51fa7073f67a097a97069
[iankelling.org] / iank-mod.el
1 ;; Copyright (C) 2016 Ian Kelling
2
3 ;; This program is free software: you can redistribute it and/or modify
4 ;; it under the terms of the GNU General Public License as published by
5 ;; the Free Software Foundation, either version 3 of the License, or
6 ;; (at your option) any later version.
7
8 ;; This program is distributed in the hope that it will be useful,
9 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ;; GNU General Public License for more details.
12
13 ;; You should have received a copy of the GNU General Public License
14 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 (defun iankmod-start ()
17 (interactive)
18 (shell-command "/a/h/get-comments" "*messages*")
19 (find-file "/tmp/hcomments")
20 (iankmod 1))
21 (defun iankmod-save ()
22 (interactive)
23 (shell-command "/a/h/set-comments" "*messages*"))
24
25
26 (defun iankmod-set-state (state)
27 (beginning-of-line)
28 (re-search-forward "|" nil t)
29 (re-search-forward "[^|]*" nil t)
30 (replace-match state)
31 (forward-line))
32
33 (defun iankmod-pick ()
34 (interactive)
35 (iankmod-set-state "picked"))
36
37 (defun iankmod-ban ()
38 (interactive)
39 (iankmod-set-state "banned"))
40
41 (defun iankmod-moderate ()
42 (interactive)
43 (iankmod-set-state "moderated"))
44
45 (define-minor-mode iankmod
46 "Moderation of comments for iankelling.org"
47 :keymap (let ((map (make-sparse-keymap)))
48 (define-key map (kbd "p") 'iankmod-pick)
49 (define-key map (kbd "b") 'iankmod-ban)
50 (define-key map (kbd "m") 'iankmod-moderate)
51 (define-key map (kbd "x") 'iankmod-save)
52 map))