Function: ctlau-converter

ctlau-converter is a byte-compiled function defined in titdic-cnv.el.gz.

Signature

(ctlau-converter DICBUF DESCRIPTION)

Source Code

;; Defined in /usr/src/emacs/lisp/international/titdic-cnv.el.gz
;; Generate the code for a Quail package in the current buffer from a
;; CTLau or CTLau-b5 dictionary in the buffer DICBUF.  The input
;; method name of the Quail package is NAME, and the title string is
;; TITLE.  DESCRIPTION is the string shown by describe-input-method.

(defun ctlau-converter (dicbuf description)
  (goto-char (point-max))
  (insert (format "%S\n" description))
  (insert "  '((\"\C-?\" . quail-delete-last-char)
   (\".\" . quail-next-translation)
   (\">\" . quail-next-translation)
   (\",\" . quail-prev-translation)
   (\"<\" . quail-prev-translation))
  nil nil nil nil)\n\n")
  (insert "(quail-define-rules\n")
  (let (dicbuf-start dicbuf-end key-start (pos (point)))
    ;; Find the dictionary, which starts below a horizontal rule and
    ;; ends at the second to last line in the HTML file.
    (with-current-buffer dicbuf
      (goto-char (point-min))
      (re-search-forward "^#<hr>")
      (forward-line 1)
      (setq dicbuf-start (point))
      (goto-char (point-max))
      (re-search-backward "^<hr>")
      (setq dicbuf-end (point)))
    (insert-buffer-substring-no-properties dicbuf dicbuf-start dicbuf-end)
    ;; CTLau-b5.html contains characters (0xa1 0xbc) which show up as
    ;; hollow boxes when the original characters in CTLau.html from
    ;; which the file is converted have no Big5 equivalent.  Go
    ;; through and delete them.
    (goto-char pos)
    (while (search-forward "□" nil t)
      (delete-char -1))
    ;; Uppercase keys in dictionary need to be downcased.  Backslashes
    ;; at the beginning of keys need to be turned into double
    ;; backslashes.
    (goto-char pos)
    (while (not (eobp))
      (insert "(\"")
      (if (char-equal (following-char) ?\\)
	  (insert "\\"))
      (setq key-start (point))
      (skip-chars-forward "\\\\A-Z")
      (downcase-region key-start (point))
      (insert "\" \"")
      (delete-char 1)
      (end-of-line)
      (while (= (preceding-char) ?\r)
	(delete-char -1))
      (insert "\")")
      (forward-line 1)))
  (insert ")\n"))