[Prime-cvs] CVS update: suikyo/elisp/src

Back to archive index

Hiroyuki Komatsu komat****@users*****
2005年 1月 11日 (火) 04:19:59 JST


Index: suikyo/elisp/src/suikyo.el
diff -u suikyo/elisp/src/suikyo.el:1.2 suikyo/elisp/src/suikyo.el:1.3
--- suikyo/elisp/src/suikyo.el:1.2	Thu Jan  8 14:13:11 2004
+++ suikyo/elisp/src/suikyo.el	Tue Jan 11 04:19:59 2005
@@ -1,5 +1,5 @@
 ;;; suikyo.el --- Romaji-Hiragana conversion library for Emacs
-;; $Id: suikyo.el,v 1.2 2004/01/08 05:13:11 komatsu Exp $
+;; $Id: suikyo.el,v 1.3 2005/01/10 19:19:59 komatsu Exp $
 ;;
 ;; Copyright (C) 2002 Hiroyuki Komatsu <komat****@taiya*****>
 ;;     All rights reserved.
@@ -71,10 +71,9 @@
 
 (defun suikyo-table-loadfile (table filename &optional table-path)
   (or (string-match "^/" filename)
-      (setq filename
-	    (expand-file-name (concat (or table-path suikyo-table-path)
-				      "/" filename)))
-      )
+      (setq filename (expand-file-name
+		      (concat (or table-path suikyo-table-path)
+			      "/" filename))))
   (if (not (file-readable-p filename))
       table
     (save-excursion
@@ -84,7 +83,10 @@
       (insert-file filename)
       (beginning-of-buffer)
 
-      (let ((bol (point)) next-bol data comment-flag)
+      (let ((bol (point))
+	    next-bol
+	    data
+	    comment-flag)
 	(while (not (eobp))
 	  (forward-line 1)
 	  (setq next-bol (point))
@@ -92,17 +94,23 @@
 	  (setq bol next-bol)
 	  (and (string-match "^/\\*" line)
 	       (setq comment-flag t))
-	  (or comment-flag
-	      (string-match "^#\\|^[ \\t]*$" line)
-	      (apply 'suikyo-table-set table (suikyo-split-string line)))
-	  (and comment-flag
-	       (string-match "\\*/" line)
-	       (setq comment-flag nil))
-	  ))
-      table))
-  )
+	  (cond
+	   ((not (or comment-flag
+		     (string-match "^#\\|^[ \\t]*$" line)))
+	    (setq table (apply 'suikyo-table-modify
+			       table (suikyo-split-string line))))
+	   ((and comment-flag
+		 (string-match "\\*/" line))
+	    (setq comment-flag nil))
+	   )))
+      table)))
+
+(defun suikyo-table-modify (table conv-from &optional conv-to pendency)
+  (if conv-to
+      (suikyo-table-set table conv-from &optional conv-to pendency)
+    (suikyo-table-unset table conv-from)))
 
-(defun suikyo-table-set (table conv-from conv-to &optional pendency)
+(defun suikyo-table-set (table conv-from &optional conv-to pendency)
   (if (= (length conv-from) 1)
       ;; Terminal of recursive execution
       (setcar (nthcdr 1 (suikyo-table-set-internal table conv-from))
@@ -114,7 +122,8 @@
 	  (nconc sub-table (list (list nil))))
       (suikyo-table-set (nth 2 sub-table)
 			 (substring conv-from 1) conv-to pendency)
-      )))
+      ))
+  table)
 
 (defun suikyo-table-set-internal (table char)
   (or (assoc char table)
@@ -123,6 +132,32 @@
 	(car (last (nconc table (list (list char nil)))))
 	)))
 
+(defun suikyo-table-unset (table key)
+  "Delete the conversion of the KEY from the TABLE."
+  (let* ((head (substring key 0 1))
+	 (rest (substring key 1))
+	 (word-data (assoc head table)))
+    (if (= (length rest) 0)
+	(if (= (length (nth 2 word-data)) 0) ;; Checking the child tree.
+	    (mell-list-delete word-data table)
+	  (setcar (cdr word-data) nil))
+      (let ((new-subtable (suikyo-table-unset (nth 2 word-data) rest)))
+	(if new-subtable
+	    (setcdr (cdr word-data) new-subtable)
+	  (mell-list-delete word-data table))))
+    table))
+
+(defun mell-list-delete (key list)
+  "This deletes the KEY from the LIST.  The original list is also modified."
+  (let ((list-cdr (member key list)))
+    (cond
+     ((= (length list-cdr) 1)
+      (setcar (nthcdr (- (length list) 1) list) nil)
+      (setcdr (nthcdr (- (length list) 2) list) nil))
+     (list-cdr
+      (setcar list-cdr (nth 1 list-cdr))
+      (setcdr list-cdr (nthcdr 2 list-cdr))))))
+
 (defun suikyo-split-string (line)
   (mapcar 'suikyo-unescape
 	  (split-string line "\t")


Prime-cvs メーリングリストの案内
Back to archive index