check-strings.el 3.41 KB
Newer Older
David Byers's avatar
Ny fil  
David Byers committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
;;;;;
;;;;; $Id$
;;;;; Copyright (C) 1996  Lysator Academic Computer Association.
;;;;;
;;;;
;;;;  This file is used for checking swedish-strings.el and
;;;;  english-strings.el. Run using
;;;;
;;;;  emacs -batch -l check-strings.el -f lyskom-check-strings
;;;;
;;;;


(defvar swedish-strings)
(defvar swedish-missing-strings)
(defvar english-strings)
(defvar english-missing-strings)
(defvar swedish-commands)
(defvar swedish-missing-bindings)
(defvar english-commands)
(defvar english-missing-bindings)
(defvar swedish-bindings)
(defvar english-bindings)

(defvar keybindings nil)
(defvar keymaps nil)

(defun suppress-keymap (&rest args) nil)

(defmacro define-key (map key cmd)
  (` (progn (setq keymaps (cons (quote (, map)) keymaps))
            (x-define-key (, cmd)))))

(defun define-prefix-command (&rest args) nil)

(defun x-define-key (cmd)
  (if (not (assq cmd keybindings))
      (setq keybindings (cons (cons cmd nil) keybindings))))

(defun reset-keybindings ()
  (setq keybindings nil)
  (mapcar (function (lambda (x) (set x nil))) keymaps)
  (setq keymaps nil))

(defun do-check (var &optional missing)
  (do-check-strings (symbol-value (intern (concat "swedish-" 
                                                  (symbol-name var))))
                    "Swedish"
                    (symbol-value (intern (concat "english-" 
                                                  (symbol-name var))))
                    "English"
                    (if missing
                        (symbol-value
                         (intern
                          (concat "english-"
                                  (symbol-name missing))))))
  (do-check-strings (symbol-value (intern (concat "english-" 
                                                  (symbol-name var))))
                    "English"
                    (symbol-value (intern (concat "swedish-" 
                                                  (symbol-name var))))
                    "Swedish"
                    (if missing
                        (symbol-value (intern
                                       (concat "swedish-"
                                               (symbol-name missing)))))))



(defun lyskom-check-strings ()
  (load-file "vars.el")
  (load-file "swedish-strings.el")
  (setq swedish-strings lyskom-strings)
  (setq swedish-missing-strings lyskom-missing-strings)
  (setq swedish-commands lyskom-commands)
  (setq swedish-bindings keybindings)
  (setq swedish-missing-bindings lyskom-missing-bindings)
  (makunbound 'lyskom-strings)
  (makunbound 'lyskom-commands)
  (makunbound 'lyskom-missing-bindings)
  (makunbound 'lyskom-missing-strings)
  (reset-keybindings)
  (load-file "english-strings.el")
  (setq english-strings lyskom-strings)
  (setq english-missing-strings lyskom-missing-strings)
  (setq english-commands lyskom-commands)
  (setq english-bindings keybindings)
  (setq english-missing-bindings lyskom-missing-bindings)
  (message "Checking lyskom-strings")
  (do-check 'strings 'missing-strings)
  (message "Checking lyskom-commands")
  (do-check 'commands)
  (message "Checking keybindings")
  (do-check 'bindings 'missing-bindings)
)



(defun do-check-strings (l1 n1 l2 n2 &optional ignores)
  (while l1
    (if (and (not (assq (car (car l1)) l2))
             (not (memq (car (car l1)) ignores)))
        (message "%-25S present in %s, but not in %s"
                 (car (car l1))
                 n1
                 n2))
    (setq l1 (cdr l1))))