]> code.delx.au - gnu-emacs-elpa/blob - packages/arbitools/arbitools.el
8c3041cbcb7e84da2cff387603dbb457973e0838
[gnu-emacs-elpa] / packages / arbitools / arbitools.el
1 ;;; arbitools.el --- Package for chess tournaments administration
2
3 ;; Copyright 2016 Free Software Foundation, Inc.
4
5 ;; Author: David Gonzalez Gandara <dggandara@member.fsf.org>
6 ;; Version: 0.51
7
8 ;; This program is free software: you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12 ;;
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; REQUIRES:
24 ;; ---------------------------
25 ;;
26 ;;
27 ;; USAGE:
28 ;; ---------------------------
29 ;; arbitools.el is an interface for the pythong package "arbitools",
30 ;; designed to manage chess tournament reports. If you don't install the
31 ;; python package you can still have the syntax colouring.
32 ;;
33 ;; FEATURES:
34 ;; ----------------------------
35 ;; - Syntax colouring for the official trf FIDE files. This facilitates
36 ;; manual edition of the files.
37 ;;
38 ;; - Updating the players ratings. By means of the function arbitools-update
39 ;;
40 ;; - Adding players to an existing file. By arbitools-add
41 ;;
42 ;; - Getting standings and report files from a tournament file. By
43 ;; arbitools-standings.
44 ;;
45 ;; You will find more information in www.ourenxadrez.org/arbitools.htm
46
47 ;;; Code:
48
49 (defun arbitools-update (elolist)
50 "Update the players ratings."
51 (interactive "selolist:")
52 ;; FIXME: What if `list' is "foo; bar"?
53 (call-process "arbitools-run.py" nil nil nil "update" buffer-file-name "-l" elolist))
54
55 (defun arbitools-add (addfile)
56 "Add players to an existing file."
57 (interactive "faddfile: ")
58 ;; FIXME: What if `addlist' is "foo; bar"?
59 (call-process "arbitools-add.py" nil nil nil "-a" addfile "-i" buffer-file-name))
60
61 (defun arbitools-standings ()
62 "Get standings and report files from a tournament file."
63 (interactive)
64 ;; (shell-command (concat (expand-file-name "arbitools-standings.py") " -i " buffer-file-name))) ;this is to use the actual path
65 (call-process "arbitools-standings.py" nil nil nil "-i" buffer-file-name))
66
67 (defun arbitools-it3 ()
68 "Get the IT3 tournament report."
69 (interactive)
70 (call-process "arbitools-run.py" nil nil nil "it3" buffer-file-name))
71
72 (defun arbitools-fedarating ()
73 "Get the FEDA rating admin file."
74 (interactive)
75 (shell-command (concat "arbitools-run.py fedarating" buffer-file-name))
76
77 (defvar arbitools-mode-map
78 (let ((map (make-sparse-keymap)))
79 (define-key map (kbd "C-c i") 'coffee-compile-buffer)
80 map)
81 "Keymap for Arbitools major mode.")
82
83
84 (easy-menu-define arbitools-mode-menu arbitools-mode-map
85 "Menu for Arbitools mode"
86 '("Arbitools"
87 ["Get It3" arbitools-it3]
88 "---"
89 ))
90
91
92 (defvar arbitools-highlights
93 '(("^001" . font-lock-function-name-face) ; name of the tournament
94 ("^012.*" . font-lock-comment-face)
95 ("\\(^022\\|^032\\|^042\\|^052\\|^062\\|^072\\|^082\\|^092\\|^102\\|^112\\|^122\\).*" . font-lock-constant-face)
96 ("^132.*" . font-lock-warning-face) ;dates
97 ("^013" . font-lock-warning-face) ;teams
98 ("\\(^013.\\{1\\}\\)\\(.\\{31\\}\\)" 2 font-lock-comment-face) ;; teams
99 ;; (" [0-9]\\{6,\\} " . font-lock-variable-name-face) ;FIDE ID
100 ("\\(^001.\\{11\\}\\)\\(.\\{32\\}\\)" 2 font-lock-string-face) ;; Name of the player (by position)
101 ("\\(^001.\\{55\\}\\)\\(.\\{10\\}\\)" 2 font-lock-function-name-face) ;; FIDE ID
102 ("\\(^001.\\{88\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face) ;; round 1 opponent
103 ;; ("\\(^132.\\{88\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face) ;; round 1 date line
104 ("\\(^001.\\{93\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face) ;; round 1 colour
105 ("\\(^001.\\{95\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face) ;; round 1 result
106 ;; rest of rounds
107 ("\\(^001.\\{98\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
108 ;; ("\\(^132.\\{98\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
109 ("\\(^001.\\{103\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
110 ("\\(^001.\\{105\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
111 ("\\(^001.\\{108\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
112 ;; ("\\(^132.\\{108\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
113 ("\\(^001.\\{113\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
114 ("\\(^001.\\{115\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
115 ("\\(^001.\\{118\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
116 ;; ("\\(^132.\\{118\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
117 ("\\(^001.\\{123\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
118 ("\\(^001.\\{125\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
119 ("\\(^001.\\{128\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
120 ;; ("\\(^132.\\{128\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
121 ("\\(^001.\\{133\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
122 ("\\(^001.\\{135\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
123 ("\\(^001.\\{138\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
124 ;; ("\\(^132.\\{138\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
125 ("\\(^001.\\{143\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
126 ("\\(^001.\\{145\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
127 ("\\(^001.\\{148\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
128 ;; ("\\(^132.\\{148\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
129 ("\\(^001.\\{153\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
130 ("\\(^001.\\{155\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
131 ("\\(^001.\\{158\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
132 ;; ("\\(^132.\\{158\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
133 ("\\(^001.\\{163\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
134 ("\\(^001.\\{165\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
135 ("\\(^001.\\{168\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
136 ;; ("\\(^132.\\{168\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
137 ("\\(^001.\\{173\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
138 ("\\(^001.\\{175\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
139 ("\\(^001.\\{178\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
140 ;; ("\\(^132.\\{178\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
141 ("\\(^001.\\{183\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
142 ("\\(^001.\\{185\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
143 ("\\(^001.\\{188\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
144 ;; ("\\(^132.\\{188\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
145 ("\\(^001.\\{193\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
146 ("\\(^001.\\{195\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)
147 ("\\(^001.\\{198\\}\\)\\(.\\{4\\}\\)" 2 font-lock-comment-face)
148 ;; ("\\(^132.\\{198\\}\\)\\(.\\{8\\}\\)" 2 font-lock-string-face)
149 ("\\(^001.\\{203\\}\\)\\(.\\{1\\}\\)" 2 font-lock-string-face)
150 ("\\(^001.\\{205\\}\\)\\(.\\{1\\}\\)" 2 font-lock-function-name-face)))
151
152 ;;;###autoload
153 (define-derived-mode arbitools-mode
154 fundamental-mode
155 "Arbitools"
156 "Major mode for Chess Tournament Management."
157 ;(setq font-lock-defaults '(arbitools-highlights))
158 (use-local-map arbitools-mode-map)
159 (set (make-local-variable 'font-lock-defaults) '(arbitools-highlights)))
160
161 ;;;###autoload
162 (add-to-list 'auto-mode-alist '("\\.trf?\\'" . arbitools-mode))
163
164 (provide 'arbitools)
165
166 ;;; arbitools.el ends here