(require 'quail)

(eval-when-compile
  (defconst polish-letters
    '((?a . ?,B1(B) (?c . ?,Bf(B) (?e . ?,Bj(B) (?l . ?,B3(B) (?n . ?,Bq(B)
      (?o . ?,Bs(B) (?s . ?,B6(B) (?z . ?,B?(B) (?x . ?,B<(B)
      (?A . ?,B!(B) (?C . ?,BF(B) (?E . ?,BJ(B) (?L . ?,B#(B) (?N . ?,BQ(B)
      (?O . ?,BS(B) (?S . ?,B&(B) (?Z . ?,B/(B) (?X . ?,B,(B))))

(defmacro polish-define-quail-package (char)
  "Define a quail package for Polish with CHAR used as a prefix"
  (cons
   'quail-define-rules
   (cons
    (list (string char char) char)
    (cons
     (list (string char ? ) char)
     (mapcar 
      #'(lambda (entry)
          (list (string char (car entry)) (cdr entry)))
      polish-letters)))))

(quail-define-package
 "Polish-slash" "Polish" "P/" nil
 "Polish input method with prefix slash"
 nil t nil nil nil nil nil nil nil nil t)

(polish-define-quail-package ?/)

(quail-define-package
 "Polish-tilda" "Polish" "P~" nil
 "Polish input method with prefix tilda"
 nil t nil nil nil nil nil nil nil nil t)

(polish-define-quail-package ?~)
