;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package -*- coding:iso-2022-7bit; -*-
-;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
+;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004,
+;; 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;; 2005, 2006, 2007
+;; National Institute of Advanced Industrial Science and Technology (AIST)
+;; Registration Number H14PRO021
;; Keywords: Quail, TIT, cxterm
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Return a value of the key in the current line.
(defsubst tit-read-key-value ()
- (if (looking-at "[^ \t\n]+")
+ (if (looking-at "[^ \t\r\n]+")
(car (read-from-string (concat "\"" (match-string 0) "\"")))))
;; Return an appropriate quail-package filename from FILENAME (TIT
(tit-keyprompt nil))
(princ ";; Quail package `")
- (princ package) (princ "' -*- coding:iso-2022-7bit; -*-\n")
+ (princ package)
+ (princ "' -*- coding:iso-2022-7bit; ")
+ (princ "byte-compile-disable-print-circle:t; -*-\n")
(princ ";; Generated by the command `titdic-convert'\n;;\tDate: ")
(princ (current-time-string))
(princ "\n;;\tOriginal TIT dictionary file: ")
Optional argument DIRNAME if specified is the directory name under which
the generated Quail package is saved."
(interactive "FTIT dictionary file: ")
- (let ((coding-system-for-write 'iso-2022-7bit))
+ (let ((coding-system-for-write 'iso-2022-7bit-unix))
(with-temp-file (tit-make-quail-package-file-name filename dirname)
- (set-buffer-file-coding-system 'iso-2022-7bit)
+ ;; Explicitly speficy eol format to `unix'.
+ (set-buffer-file-coding-system 'iso-2022-7bit-unix)
(let ((standard-output (current-buffer)))
(with-temp-buffer
(set-buffer-multibyte nil)
- (let ((coding-system-for-read 'no-conversion))
+ ;; Here we must use `raw-text' instead of `no-conversion' to
+ ;; enable auto-decoding of eol format (CRLF->LF).
+ (let ((coding-system-for-read 'raw-text))
(insert-file-contents (expand-file-name filename)))
;; Decode the buffer contents from the encoding specified by a
;;
;; You should have received a copy of the GNU General Public License along with
;; CCE; see the file COPYING. If not, write to the Free Software Foundation,
-;; 675 Mass Ave, Cambridge, MA 02139, USA.")
+;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
("chinese-ziranma" "\e$AWTH;\e(B"
"ziranma.cin" cn-gb-2312 "ZIRANMA.el"
;;
;; You should have received a copy of the GNU General Public License along with
;; CCE; see the file COPYING. If not, write to the Free Software Foundation,
-;; 675 Mass Ave, Cambridge, MA 02139, USA.")
+;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
("chinese-ctlau" "\e$AAuTA\e(B"
"CTLau.html" cn-gb-2312 "CTLau.el"
;; #
;; # You should have received a copy of the GNU General Public License
;; # along with this program; if not, write to the Free Software Foundation,
-;; # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
+;; # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
("chinese-ctlaub" "\e$(0N,Gn\e(B"
"CTLau-b5.html" big5 "CTLau-b5.el"
;; #
;; # You should have received a copy of the GNU General Public License
;; # along with this program; if not, write to the Free Software Foundation,
-;; # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
+;; # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
))
;; Generate a code of a Quail package in the current buffer from Tsang
(insert "(quail-define-rules\n")
(save-excursion
(set-buffer dicbuf)
+ ;; Handle double CR line ends, which result when checking out of
+ ;; CVS on MS-Windows.
+ (goto-char (point-min))
+ (while (re-search-forward "\r\r$" nil t)
+ (replace-match ""))
(goto-char (point-min))
(search-forward "A440")
(beginning-of-line)
(let ((pos (point)))
(insert-buffer-substring dicbuf)
(goto-char pos)
+ (re-search-forward "^[a-z]")
+ (beginning-of-line)
+ (delete-region pos (point))
(while (not (eobp))
(insert "(\"")
(skip-chars-forward "a-z")
name title dicfile coding quailfile converter copyright
dicbuf)
(while tail
- (when (or (string-match (nth 2 (car tail)) filename)
- ;; MS-DOS filesystem truncates file names to 8+3
- ;; limits, so "cangjie-table.cns" becomes
- ;; "cangjie-.cns", and the above string-match fails.
- ;; Give DOS users a chance...
- (and (fboundp 'msdos-long-file-names)
- (not (msdos-long-file-names))
- (string-match (dos-8+3-filename (nth 2 (car tail)))
- filename)))
- (setq slot (car tail)
- name (car slot)
+ (setq slot (car tail)
+ dicfile (nth 2 slot)
+ quailfile (nth 4 slot))
+ (when (and (or (string-match dicfile filename)
+ ;; MS-DOS filesystem truncates file names to 8+3
+ ;; limits, so "cangjie-table.cns" becomes
+ ;; "cangjie-.cns", and the above string-match
+ ;; fails. Give DOS users a chance...
+ (and (fboundp 'msdos-long-file-names)
+ (not (msdos-long-file-names))
+ (string-match (dos-8+3-filename dicfile) filename)))
+ (if (file-newer-than-file-p
+ filename (expand-file-name quailfile dirname))
+ t
+ (message "%s is up to date" quailfile)
+ nil))
+ (setq name (car slot)
title (nth 1 slot)
- dicfile (nth 2 slot)
coding (nth 3 slot)
- quailfile (nth 4 slot)
converter (nth 5 slot)
copyright (nth 6 slot))
(message "Converting %s to %s..." dicfile quailfile)
(with-temp-file (expand-file-name quailfile dirname)
- (set-buffer-file-coding-system 'iso-2022-7bit)
- (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; -*-\n")
+ ;; Explicitly speficy eol format to `unix'.
+ (set-buffer-file-coding-system 'iso-2022-7bit-unix)
+ (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; ")
+ (insert "byte-compile-disable-print-circle:t; -*-\n");
(insert ";; Generated by the command `miscdic-convert'\n")
(insert ";; Date: " (current-time-string) "\n")
(insert ";; Source dictionary file: " dicfile "\n")