changeset 34:c8bac1eb3c9b

delete some obsolete function (before comment).
author gongo
date Sat, 22 Dec 2007 12:30:40 +0900
parents ed70d3c76f7b
children 8991e2263f83
files ChangeLog redit-client-sm.el
diffstat 2 files changed, 176 insertions(+), 281 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Dec 21 18:18:25 2007 +0900
+++ b/ChangeLog	Sat Dec 22 12:30:40 2007 +0900
@@ -1,5 +1,22 @@
 2007-12-21  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
 
+	* thinking: hash の扱い(解答)
+	解答っつーか・・・
+
+	(gethash '(buffer-name) hash)
+
+	じゃなくて
+
+	(gethash (buffer-name) hash)
+
+	だよ。' 要らなかったね!!これでおk。
+
+	あと、キーとして (buffer-name) か (current-buffer) が使える。
+	バッファの名前か、もしくはバッファのオブジェクト?か。
+	名前も、ファイル名@ホスト名だから(だっけ?)、
+	一意に決まるので重複しないし。オブジェクトもしかり。
+	ま、ループ回して速い方を選ぶとするか。
+	
 	* thinking: hash の扱い
 	join or put command からの流れ
 	
--- a/redit-client-sm.el	Fri Dec 21 18:18:25 2007 +0900
+++ b/redit-client-sm.el	Sat Dec 22 12:30:40 2007 +0900
@@ -6,9 +6,22 @@
 ;;  :group 'redit
 ;;  :type 'string)
 
-;; 륳ޥɤ
-;; 2 + 2 + 9 + data
-;; command_number + buffer_number + line_number + data
+;; REP Command
+;;
+;;  32 bits    32       32       32      32       32      textsiz
+;; o-------o--------o--------o-------o--------o---------o-------...
+;; +-------+--------+--------+-------+--------+---------+------+
+;; | cmd   | session| editor | seqid | lineno | textsiz | text |
+;; |       | id     | id     |       |        |         |      |
+;; +-------+--------+--------+-------+--------+---------+------+
+;; o-------header section (network order)---------------o-------...
+;;
+;; textsiz:
+;;    This size is number of bytes for character string encoded with UTF8.
+;;    
+;; text:
+;;    This size is variable length (textsiz).
+;;
 
 (eval-when-compile (require 'cl))
 
@@ -49,10 +62,10 @@
 (defvar redit-max-string-length 1004
   "Read-Write max length of string.")
 
-;; REP Ѥʸ
+;; REP が使用する文字コード
 (defvar rep-string-encoding 'utf-8)
 
-(defvar redit-open-command           "1")
+(defvar redit-open-command           1)
 (defvar redit-open-ack               2)
 (defvar redit-read-command           3)
 (defvar redit-read-ack               4)
@@ -86,19 +99,16 @@
 (defvar redit-quit-ack-command       54)
 
 ;; Queue struct
-;; (defstruct Queue (front nil) (rear nil))
-;; (setq redit-client-command-queue (make-Queue))
-;; (setq redit-client-receive-queue (make-Queue))
-;; (setq redit-client-send-queue (make-Queue))
+;;(defstruct Queue (front nil) (rear nil))
+;;(setq redit-client-command-queue (make-Queue))
+;;(setq redit-client-receive-queue (make-Queue))
+;;(setq redit-client-send-queue (make-Queue))
 
 ;; line translated queue
-;; (setq after-CQ (make-Queue))
-;; (setq after-RQ (make-Queue))
+;;(setq after-CQ (make-Queue))
+;;(setq after-RQ (make-Queue))
 
 
-;; Fix Me
-;; Ŭ˺äƤޤäΤǡ
-;; ޥɤǧƤޤ
 (defun redit-pack-int-loop (num count)
   (if (> count 0)
       (concat
@@ -125,46 +135,6 @@
   (redit-unpack-int-loop pkt (* pos 4) 4))
 
 
-;; ȤäƤ롩
-;; redit-join-command λŻäƤäݤΤǥ
-;; (defun redit-client-start (host)
-;;   "Allow this Emacs process to be a remote-edit client for client processes."
-;;   (interactive "P")
-;;   (if redit-client-process
-;;       (progn
-;; 	(set-process-sentinel redit-client-process nil)
-;; 	(condition-case () ;; 顼ȥץä
-;; 	    (delete-process redit-client-process) (error nil))))
-;;   (if (setq host (read-string "Hostname: ")) ;; minibufferǥۥ̾Ϥ
-;;       (let ((process-connection-type nil))
-;; 	;; 饤ȥץ(redit-client)Υץ򥹥Ȥ롣
-;; 	;; Ȥ host Ϳ
-;; 	(setq redit-client-process
-;; 	      (start-process "reditclient" nil redit-client-program host))
-;; 
-;; 	;; redit-client-process ξ֤Ѳ redit-client-sentinel Ƥ
-;; 	(set-process-sentinel redit-client-process 'redit-client-sentinel)
-;; 	;; redit-client-process ΥǡϤ redit-client-process-filter
-;; 	;; 𤹤
-;; 	(set-process-filter redit-client-process 'redit-client-process-filter)
-;; 	;; redit-client-process Ϥ 8-bit codes Ǽ谷
-;; 	;;(set-process-coding-system redit-client-process
-;; 	;;'raw-text 'raw-text)
-;; 	(set-process-coding-system redit-client-process
-;; 				   rep-string-encoding rep-string-encoding)
-;; 	;; emacs λ redit-client-process ⽪λ
-;; 	(set-process-query-on-exit-flag redit-client-process nil)
-;; 
-;; 	;; եåѿ before-change-functions, after-change-functions
-;; 	;; Хåեˤ
-;; 	;; not necessary since Emacs 21.1
-;; 	;; (make-local-hook 'before-change-functions)
-;; 	;; (make-local-hook 'after-change-functions)
-;; 	
-;; 	(message "Remote edit client started."))   (error "redit-client connection refused.")))
-;; 
-;; (redit-join-command ())
-
 
 (defun redit-join-command ()
   "Allow this Emacs process to be a remote-edit session manager for client processes."
@@ -190,15 +160,15 @@
     
     ;; //Code of the process input/output buffer is rep-string-encoding
     ;; //(set-process-coding-system redit-client-process rep-string-encoding rep-string-encoding)
-    ;; ǡϥХʥʤȤʤ
-    ;; utf-8 ʤƤǽΤ
+    ;; 送受信するデータはバイナリで貰わないといけない。
+    ;; utf-8 じゃなくてずれる可能性があるので
     (set-process-coding-system redit-client-process 'binary 'binary)
     
-    ;; ץƤȤ emacs λ褦Ȥ
-    ;; process󤿤ǡڤäƤ⤤ y/n
-    ;; äʹ롣nil ƤäƤʹʤ
-    ;; quit ʤ t ˤͭˤ٤ʤ
-    ;;  nil 
+    ;; プロセスが生きてるとき、 emacs を終了しようとすると
+    ;; 「processがうんたらで、本当に切ってもいいの y/n」
+    ;; って聞かれる。nil てやっておくと聞かれない。
+    ;; quit を入れるんなら t にして有効にすべきなんだろうか。
+    ;; 今は nil で
     (set-process-query-on-exit-flag redit-client-process nil)
     
     ;; not necessary since Emacs 21.1
@@ -222,73 +192,6 @@
 	 0 0 0 0 (string-bytes bufname))
 	(buffer-name)))
       )))
-  
-;; 'get' is obsolete command
-;; (defun redit-get-command ()
-;;   "get. alias redit-join-command and redit-select-command."
-;;   (interactive)
-;;   (redit-join-command)
-;;   (redit-select-command ()))
-
-;; select : select session
-;; 桼Ϥäơselectޥɤ̿ץϤ
-;; (redit-select-command ()
-(defun redit-select-command (session-name)
-  "select session"
-  (interactive "P")
-  (if (setq session-name (read-string "session name:"))
-      (progn 
-	(setq redit-client-session-id (string-to-number session-name))
-	(process-send-string 
-	 redit-client-process
-	 (redit-pack
-	  redit-select-command redit-client-session-id redit-client-editor-id
-	  (gen-seqno) 0 0))
-	
-	;;(concat (format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-select-command) redit-client-session-id redit-client-editor-id (gen-seqno) 0 0) session-name "\n"))
-	)
-    (error "invalid session name.")
-    )
-)
-
-
-;; put-command ϡjoin-command 
-;; ե򳫤Ƥʤ *scratch* λ˸ƤӽФΤ
-;; ɬפ̵
-;;(defun redit-put-command (session-name)
-;;  "put session"
-;;  (interactive "P")
-;;  (if (setq session-name (read-string "put session name:")) 
-;;      (process-send-string 
-;;       redit-client-process
-;;       (concat
-;;	(redit-pack
-;;	 (string-to-number redit-put-command) 0 0 0 0
-;;	 (string-bytes (encode-coding-string session-name rep-string-encoding)))
-;;	session-name
-;;	)
-;;       )
-;;    (error "invalid session name.")
-;;    ))
-
-;; 'register' is obsolete command
-;; (defun redit-register-command (session-name)
-;;   "register"
-;;   (interactive "P")
-;;   (if (setq session-name (read-string "session name:")) 
-;;       (process-send-string 
-;;        redit-client-process
-;;        (concat (format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-register-command) redit-client-session-id redit-client-editor-id (gen-seqno) 0 0) session-name "\n"))
-;;     (error "invalid session name.")
-;;     )
-;;   )
-;; 
-
-;; 'deregister' is obsolete command
-;;(defun redit-deregister-command ()
-;;  "deregister"
-;;  (interactive)
-;; )
 
 (defun redit-quit-command ()
   "quit"
@@ -300,17 +203,17 @@
   (if redit-client-process
       (if (setq file (read-string "Filename: "))
 	  (progn
-	    ;; redit-client-process  input ʸ
+	    ;; redit-client-process の input に文字列を送信する
 	    (process-send-string
 	     redit-client-process
-	     ;; redit-open-command (01)  file Ϣ뤵
+	     ;; redit-open-command (01) と file を連結させる
 	     (concat redit-open-command file))
-	    ;; redit-client-process Ϥޤǥ롼
+	    ;; redit-client-process から出力を得るまでループ
 	    (while (eq nil (accept-process-output redit-client-process)))))
     (error "redit-client is not running.")))
 
-;; redit-client-process readޥɤȥХåեֹ桢ֹꡢ
-;; ФνϤ
+;; redit-client-process にreadコマンドとバッファ番号、行番号を送り、
+;; サーバからの出力を得る
 (defun redit-client-read-line (linenum)
   (if redit-client-process
       (save-excursion
@@ -322,87 +225,71 @@
 		     (accept-process-output redit-client-process)))))
     (error "redit-client is not running.")))
 
-;; linenumǻꤵ줿ԤԽ򥵡Ф
-;; redit-client-process  insert ޥɤ
-;;Хåեֹ桢ֹ桢ԤƤꡢ Ack 
+;; linenumで指定された行の編集をサーバへ送る
+;; redit-client-process に insert コマンドと
+;;バッファ番号、行番号、行の内容を送り、 Ack を受け取る
 (defun redit-client-insert-line (linenum isnewline)
   (if redit-client-process
       (save-excursion
-	(let ((beginp) (endp) (length))
-	  ;; insert lines on server buffer
-	  (setq beginp
-		(progn (goto-line linenum) (beginning-of-line) (point)))
-	  (setq endp
-		(progn (goto-line linenum) (end-of-line) (point)))
-	  ;; (setq length (- endp beginp))
-	  ;; rep-string-encoding ѴƤĹ
-	  (setq length (string-bytes (encode-coding-string (buffer-substring beginp endp) rep-string-encoding)))
-	  
-	  ;; ȡ󤬲äƤΤԤľϡ
-	  ;;  process-send-string 
-	  ;; Խ¸ˤȤɤ
-	  ;;(enqueue
-	  ;;redit-client-command-queue
-	  ;;(concat (format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-write-command) redit-client-session-id redit-client-editor-id (gen-seqno) linenum length)
-	  ;;(buffer-substring beginp endp)
-	  ;;(if (eq isnewline t) "\n")
-	  ;;"\n"))
-	  
-	  ;; redit-client-process 
-	  ;; command_num + buffer_num + line_num + string
-	  ;; ʸ
-
-	  (process-send-string
-	   redit-client-process
-	   (concat
-
-	    ;; obsolete send string
-	    ;;(format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-write-command) redit-client-session-id redit-client-editor-id (gen-seqno) linenum length)
-
-	    (redit-pack
-	     redit-insert-command
-	     redit-client-session-id
-	     redit-client-editor-id
-	     (gen-seqno) linenum length)
-	    
-	    ;; (buffer-substring beginp endp)
-	    ;; rep-string-encoding Ѵ
-	    (encode-coding-string (buffer-substring beginp endp) rep-string-encoding)
-	    (if (eq isnewline t) "\n")
-	    "\n"))
-	  (sleep-for 0.3)
-	  ))
+	(let ((beginp) (endp) (text) (length))
+	     ;; insert lines on server buffer
+	     (setq beginp
+		   (progn (goto-line linenum) (beginning-of-line) (point)))
+	     (setq endp
+		   (progn (goto-line linenum) (end-of-line) (point)))
+	     ;; rep-string-encoding に変換してから長さを求める
+	     (setq text
+		   (encode-coding-string
+		    (buffer-substring beginp endp) rep-string-encoding))
+	     (setq length (string-bytes text))
+    
+	     ;; トークンが回ってくるのを待つ場合は、
+	     ;; すぐに process-send-string せずに
+	     ;; 編集情報を保存するだけにとどめる
+	     ;;(enqueue
+	     ;;redit-client-command-queue
+	     ;;(concat (format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-write-command) redit-client-session-id redit-client-editor-id (gen-seqno) linenum length)
+	     ;;(buffer-substring beginp endp)
+	     ;;(if (eq isnewline t) "\n")
+	     ;;"\n"))
+	
+	     ;; redit-client-process へ
+	     ;; command_num + buffer_num + line_num + string
+	     ;; の文字列を送る
+    
+	     (process-send-string
+	      redit-client-process
+	      (concat (redit-pack redit-insert-command
+				  redit-client-session-id
+				  redit-client-editor-id
+				  (gen-seqno) linenum length)
+		      text
+		      (if (eq isnewline t) "\n")))
+	     ))
     (error "redit-client is not running.")))
 
-;; linenum ǻꤷԤκ̿ redit-client-process 
+;; linenum で指定した行の削除命令を redit-client-process に送信する
 (defun redit-client-delete-line (linenum)
   (if redit-client-process
       (save-restriction
 
-	;; ȡ󤬲äƤΤԤľϡ
-	;;  process-send-string 
-	;; Խ¸ˤȤɤ
+	;; トークンが回ってくるのを待つ場合は、
+	;; すぐに process-send-string せずに
+	;; 編集情報を保存するだけにとどめる
 	;;(enqueue redit-client-command-queue
 	;;(concat (format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-delete-line-command) redit-client-session-id redit-client-editor-id (gen-seqno) linenum 0) "\n"))
 	
 	;; insert lines on server buffer
 	(process-send-string
 	 redit-client-process
-
 	 (concat
-	  ;; obsolete send string
-	  ;; (format "%10d%10d%10d%10d%10d%10d" (string-to-number redit-delete-line-command) redit-client-session-id redit-client-editor-id (gen-seqno) linenum 0) "\n"))
-
-	  (redit-pack
-	   redit-delete-line-command
-	   redit-client-session-id
-	   redit-client-editor-id
-	   (gen-seqno) linenum 0)))
-	 (sleep-for 0.3)
-	)
+	  (redit-pack redit-delete-line-command
+		      redit-client-session-id
+		      redit-client-editor-id
+		      (gen-seqno) linenum 0))))
     (error "redit-client is not running.")))
 
-;; redit-client-process closeޥɤ
+;; redit-client-process へcloseコマンドを送る
 (defun redit-client-close ()
   "Save File and exit Remote-edit client."
   (interactive)
@@ -419,7 +306,7 @@
        redit-client-editor-id
        (gen-seqno) 0 0) "\n"))))
 
-;; redit-client-process λ
+;; redit-client-process を終了させる
 (defun redit-client-kill ()
   "Stop Remote-Edit client process."
   (interactive)
@@ -430,18 +317,18 @@
   (kill-all-local-variables))
 
 ;; proc == redit-client-process
-;; string == redit-client-process  output
+;; string == redit-client-process からの output
 (defun redit-client-process-filter (proc string)
-  ;; Хåեʥեåꥹ before-change-functions 
-  ;; redit-client-before-change-function . after Ʊ
-  ;; proc νϤ hook ʤ褦
+  ;; バッファローカルなフックリスト before-change-functions から
+  ;; redit-client-before-change-function を取り除く. after も同じ
+  ;; proc からの出力に hook しないように
   (remove-hook 'before-change-functions
 	       'redit-client-before-change-function t)
   (remove-hook 'after-change-functions
 	       'redit-client-after-change-function t)
   
   (let ((command (rep-get-command-from-pkt string)))
-    ;; command ɤ̿ᤫȽǤб򤹤롣case ߤ
+    ;; command がどの命令かを判断し、対応した処理をする。case みたい
     (cond 
      ;; FIXME
      ((if (= command redit-open-ack)
@@ -471,34 +358,12 @@
      ;; from Session Manager
      ;; join ack (editor id)
      ((if (= command redit-join-ack-command)
-	  ;;(message "redit-client-exec-join")
 	  (redit-client-exec-join string)))
 
      ;; put ack (editor id)
      ((if (= command redit-put-ack-command)
 	  (redit-client-exec-put string)))
 
-     ;; select ack
-     ;; TODO : start editing
-     ;; obsolete
-     ;;((if (= command redit-select-ack-command)
-     ;;(redit-client-exec-select)))
-
-     ;; get
-     ;;((if (= command redit-get-command)
-     ;;(if (= redit-client-editor-id (rep-get-editor-id-from-pkt string))
-     ;;(redit-client-exec-get string))))
-
-     ;; register
-     ;;((if (= command redit-register-command)
-     ;;(if (= redit-client-editor-id (rep-get-editor-id-from-pkt string))
-     ;;(redit-client-exec-register string))))
-
-     ;; deregister
-     ;;((if (= command redit-deregister-command)
-     ;;(if (= redit-client-editor-id (rep-get-editor-id-from-pkt string))
-     ;;(redit-client-exec-deregister string))))
-
      ;; delete line
      ((if (= command redit-delete-line-command)
 	  (if (/= redit-client-editor-id (rep-get-editor-id-from-pkt string))
@@ -511,8 +376,8 @@
 	    'redit-client-after-change-function t t)
   )
 
-;; window-scroll-functions  hook 롣
-;; window 뤹٤˸ƤФ
+;; window-scroll-functions に hook される。
+;; window がスクロールする度に呼ばれる
 (defun redit-client-update-function (window window-start)
   (if (equal (window-buffer) redit-client-buffer)
       (save-excursion
@@ -546,7 +411,7 @@
 	(add-hook 'after-change-functions
 		  'redit-client-after-change-function t t))))
 
-;; currentp ΰ֤ιԿ֤
+;; currentp の位置の行数を返す
 (defun real-count-lines (currentp)
   (+ (count-lines (point-min) currentp)
      (if (= (save-excursion (goto-char currentp) (current-column))
@@ -560,34 +425,34 @@
       (setq exprs (cdr exprs)))
     (goto-char saved-point)))
 
-;; before-change-functions  hook 
-;; Хåեѹ뤿Ӥ˸ƤФ롣Хåեѹ˸ƤФ롣
-;; begin  end ˤѹѹʬλϤޤȽ point 
+;; before-change-functions に hook される
+;; バッファに変更があるたびに呼ばれる。バッファが変更される前に呼ばれる。
+;; begin と end には変更前の変更部分の始まりと終わりの point が入る
 (defun redit-client-before-change-function (begin end)
-  (let ((beginl (real-count-lines begin)) ;; begin ιֹ
-	(endl (real-count-lines end))	  ;; end ιֹ
+  (let ((beginl (real-count-lines begin)) ;; begin の行番号
+	(endl (real-count-lines end))	  ;; end の行番号
 	(currline))			  ;; currline = nil
 
     ;; (message "before-change-function")
 
-    ;; ԽԤȺԽԤ
-    ;; äƤԽ򥵡Ф
+    ;; 前回の編集した行と今回の編集した行が
+    ;; 違っていたら前回の編集をサーバへ送る
     (if (not (= beginl redit-client-previous-edited-line))
 	(redit-client-insert-line redit-client-previous-edited-line nil))
 
-    ;; ǵ롣
-    ;; (ex. BackSpaceˤԤΤΤκ, C-Space C-wʤɤΥå, ...)
+    ;; 削除処理で起こる。
+    ;; (ex. BackSpaceによる行そのものの削除, C-Space C-wなどのカット, ...)
     (if (< beginl endl)
 	(progn
 	  (setq currline endl)
-	  ;; endlbeginlޤǹԤκ̿Ф
+	  ;; endlからbeginlまで行の削除命令を出す
 	  (while (> currline beginl) 
 	    (redit-client-delete-line endl)
 	    (setq currline (- currline 1)))))))
 
-;; after-change-functions  hook 
-;; Хåեѹ뤿Ӥ˸ƤФ롣Хåեѹ줿˸ƤФ
-;; begin  end ˤѹѹʬλϤޤȽ point 
+;; after-change-functions に hook される
+;; バッファに変更があるたびに呼ばれる。バッファが変更された後に呼ばれる
+;; begin と end には変更後の変更部分の始まりと終わりの point が入る
 (defun redit-client-after-change-function (begin end length)
   (let ((beginl (real-count-lines begin))
 	(endl (real-count-lines end))
@@ -595,47 +460,47 @@
 
     ;; (message "after-change-function")
 
-    ;; ǵ롣
-    ;; (ex. , C-y ʤɤΥڡ, ...)
+    ;; 挿入処理で起こる。
+    ;; (ex. 改行, C-y などのペースト, ...)
     (if (< beginl endl)
 	(progn
 	  (setq currline beginl)
-	  ;; beginlendlޤ̿Ф
+	  ;; beginlからendlまで挿入命令を出す
 	  (while (<= currline endl)
 	    (progn (redit-client-insert-line currline nil)
 		   (setq currline (+ currline 1))))))
     (setq redit-client-previous-edited-line endl)))
 
-;; Ϳ줿 string (line_num + text_data) 
-;; ꤵ줿Ԥ text_data 
+;; 引き数で与えられた string (line_num + text_data) から
+;; 指定された行を削除し、そこに text_data を挿入する
 (defun redit-client-exec-insert-line (string)
-  (let ((linenum (rep-get-line-number-from-pkt string)) ;; ֹ
-	(text (rep-get-text-from-pkt string))) ;; ƥȥǡ
+  (let ((linenum (rep-get-line-number-from-pkt string)) ;; 行番号
+	(text (rep-get-text-from-pkt string))) ;; テキストデータ
     (if (< (real-count-lines (point-max)) linenum)
 	(progn
 	  (call-interactively 'end-of-buffer) (newline)))
     (goto-line linenum)
-    (delete-region (progn (beginning-of-line) (point)) ;; ԤƬ
-		   (progn (end-of-line) (point))) ;; ԤޤǺ
-    (insert text) ;; ƥȥǡ
+    (delete-region (progn (beginning-of-line) (point)) ;; 行の頭から
+		   (progn (end-of-line) (point))) ;; 行の末尾まで削除
+    (insert text) ;; テキストデータを挿入
     (message (concat "recv = " text ", line = " (number-to-string linenum)))
     ))
 
-;;  string (line_num + text_data) ǻꤵ줿Ԥ
+;; 引き数 string (line_num + text_data) で指定された行を削除する
 (defun redit-client-exec-delete-line (string)
   (let ((linenum (rep-get-line-number-from-pkt string)))
     (goto-line linenum)
-    ;; ƬޤǤΥƥȤ
+    ;; 行頭から末尾までのテキストを削除
     (delete-region (progn (beginning-of-line) (point))
 		   (progn (end-of-line) (point)))
-    ;; ꤵ줿ԼΤ
-    ;; ꤵ줿ֹ̤ιԤֹɽȤˤʤ
+    ;; 指定された行自体を削除
+    ;; 指定された行番号は別の行の番号を表すことになる
     (if (= (point) (point-max))
 	(delete-backward-char 1)
       (delete-char 1)))
   )
 
-;;  string (buf_num + line_num + text_data) 
+;; 引き数 string (buf_num + line_num + text_data) 
 (defun redit-client-exec-open-ack (string)
   (save-excursion
     (let ((bufnum (rep-get-editor-id-from-pkt string))
@@ -645,9 +510,9 @@
       (setq redit-client-buffer-name
 	    (rep-get-text-from-pkt string))
       (setq redit-client-buffer (get-buffer-create redit-client-buffer-name))
-      ;; ץȥХåեϢŤ
+      ;; プロセスとバッファを関連づける
       (set-process-buffer redit-client-process redit-client-buffer)
-      (switch-to-buffer redit-client-buffer) ;; windowΥХåեѹ
+      (switch-to-buffer redit-client-buffer) ;; windowのバッファを変更する
       (make-variable-buffer-local 'redit-client-previous-edited-line)
       (make-variable-buffer-local 'redit-client-after-edited-line)
       (make-variable-buffer-local 'redit-client-line-max-in-server)
@@ -666,24 +531,24 @@
       ;; not necessary since Emacs 21.1
       ;; (make-local-hook 'window-scroll-functions)
 
-      ;; window 뤹٤˸ƤФؿ
+      ;; window がスクロールする度に呼ばれる関数群
       (add-hook 'window-scroll-functions
 		'redit-client-update-function t t))))
 
-;; string (line_num + text_data) ǻꤵ줿Ԥ
-;; text_data 
+;; string (line_num + text_data) で指定された行に
+;; text_data を挿入する
 (defun redit-client-exec-read-ack (string)
   (save-excursion
     (let ((lines (rep-get-line-number-from-pkt string)))
-      ;; redit-client-buffer 򥫥ȥХåեˤ
+      ;; redit-client-buffer をカレントバッファにする
       (set-buffer redit-client-buffer)
       (goto-line lines)
-      (beginning-of-line) ;; ԤλϤذư
+      (beginning-of-line) ;; 行の始めへ移動
       ;;      (delete-region (progn (beginning-of-line) (point))
       ;; 		     (progn (end-of-line) (point)))
-      (insert (rep-get-text-from-pkt string))))) ;; ƥȥǡ
+      (insert (rep-get-text-from-pkt string))))) ;; テキストデータを挿入
 
-;; redit-client-line-max-in-server ˹ֹƤ()
+;; redit-client-line-max-in-server に行番号を入れてる(だけ)
 (defun redit-client-exec-insert-ack (string)
   (save-excursion
     (set-buffer redit-client-buffer)
@@ -696,7 +561,7 @@
     (let ((linenum (rep-get-line-number-from-pkt string)))
       (setq redit-client-line-max-in-server linenum))))
 
-;; ץȥХåեѿ
+;; プロセスとバッファ、ローカル変数を削除する
 (defun redit-client-exec-close-ack (string)
   (if redit-client-process
       (kill-process redit-client-process))
@@ -704,29 +569,29 @@
       (kill-buffer redit-client-buffer))
   (kill-all-local-variables))
 
-;; Ϳ줿 string  Editor ID
+;; 引き数で与えられた string から Editor IDを取得する
 (defun redit-client-exec-join (string)
   (setq redit-client-editor-id (rep-get-editor-id-from-pkt string))
   (message (concat "your editor id = " (number-to-string redit-client-editor-id) "\n")))
 
-;; //Ϳ줿 string  Session ID
-;; ͤǡ(put = եͭjoin) äƤȤˤʤä
-;; editor id ֤ȤˤʤäΤǡsid ȶ eid ⥻֤
+;; //引き数で与えられた string から Session IDを取得する
+;; 新仕様で、(put = ファイル有りjoin) ってことになって
+;; editor id を返すことになったので、sid と共に eid もセーブする
 (defun redit-client-exec-put (string)
   (setq redit-client-editor-id (rep-get-editor-id-from-pkt string))
   (setq redit-client-session-id (rep-get-session-id-from-pkt string))
   (message (concat "Your Editor ID = " (number-to-string redit-client-editor-id) "\n"))
   (message (concat "Session ID = " (number-to-string redit-client-session-id) "\n")))
 
-;; SessionID̾ȤХåե򳫤
+;; SessionIDを名前とした、新しいバッファを開く
 ;; FIXME
-;;   SessionIDǤϤʤSession Name˾ޤ?
-;;   Хåե򳫤塢SessiondzƤեȤɽ٤
+;;   SessionIDではなく、Session Nameが望ましい?
+;;   バッファを開いた後、Sessionで開いてるファイルの中身を表示するべき
 (defun redit-client-exec-select ()
   (switch-to-buffer (get-buffer-create
 		     (number-to-string redit-client-session-id))))
 
-;; ץξ֤򸫤ơбåɽ
+;; プロセスの状態を見て、対応したメッセージを表示
 (defun redit-client-sentinel (proc msg)
   (cond ((eq (process-status proc) 'exit)
 	 (message "Client subprocess exited"))
@@ -749,17 +614,30 @@
   (redit-unpack-int pkt 5))
 (defun rep-get-text-size-from-pkt (pkt)
   (redit-unpack-int pkt 6))
+
+;; コマンド後ろにあるテキストは
+;;   (substring packet 24)
+;; でとれるので、text-size は要らない、とうれしい。
+;; が、(通信テストまだなので)例えば連続してパケットが送られて来たとき
+;; そのパケットが繋がってしまうと駄目。
+;; もし、process-filter が、一つのパケットの処理が終わるまで
+;; 後続のパケットを止めててくれるならこれでいけるが。
+;; 念のため、受け取った text-size と比較して
+;; 同じならおk、だめならそのサイズ分だけ取る、って所か。
+;; 最初からサイズ分だけでいいんじゃね?と思ったりもするが。
 (defun rep-get-text-from-pkt (pkt)
-  (let ((size (rep-get-text-size-from-pkt pkt)))
-  (substring (decode-coding-string pkt 'euc-jp) 27 (+ 27 size))))
+  (let ((size) (text))
+    (setq size (rep-get-text-size-from-pkt pkt))
+    (setq text (substring pkt 24))
+    (if (= size (string-bytes text)) text)))
 
 ;; enqueue item in queue
 ;;  (defun enqueue (queue item)
 ;;    (let ((new-cell (list item)))
 ;;      (if (Queue-front queue)
-;;  	;; ǽ񤭴
+;;  	;; 最終セルを書き換える
 ;;  	(setf (cdr (Queue-rear queue)) new-cell)
-;;        ;; 塼϶ξ
+;;        ;; キューは空の状態
 ;;        (setf (Queue-front queue) new-cell))
 ;;      (setf (Queue-rear queue) new-cell)))
 
@@ -769,7 +647,7 @@
 ;;        (prog1
 ;;  	  (pop (Queue-front queue))
 ;;  	(unless (Queue-front queue)
-;;  	  ;; 塼϶ˤʤä
+;;  	  ;; キューは空になった
 ;;  	  (setf (Queue-rear queue) nil)))))
 
 ;; 
@@ -900,12 +778,12 @@
   "Print command queue."
   (interactive)
   ;;(message redit-client-command-queue))
-  (let ((queue redit-client-command-queue))
+  (let (queue)
+    (setq queue redit-client-command-queue)
     (while (Queue-front queue)
       (message (Queue-front queue))
       (setq queue (cdr (Queue-rear queue)))
-      )
-))
+      )))
 
 (defun redit-client-print-recive-queue ()
   "Print command queue."