Mercurial > hg > RemoteEditor > emacs
diff redit-client-sm.el @ 31:ccd1ad69a852 rep_camp_20071111
*** empty log message ***
author | gongo |
---|---|
date | Fri, 21 Dec 2007 13:30:50 +0900 |
parents | 9e43cec05dc5 |
children | c8bac1eb3c9b |
line wrap: on
line diff
--- a/redit-client-sm.el Sun Nov 11 03:02:50 2007 +0900 +++ b/redit-client-sm.el Fri Dec 21 13:30:50 2007 +0900 @@ -169,51 +169,60 @@ (defun redit-join-command () "Allow this Emacs process to be a remote-edit session manager for client processes." (interactive) - (if redit-client-process - (progn - (set-process-sentinel redit-client-process nil) - (condition-case () ;; - (delete-process redit-client-process) (error nil)))) - - (setq redit-client-process (open-network-stream - "redit-client" nil "localhost" 8766)) - - ;; called when the process changes state - (set-process-sentinel redit-client-process 'redit-client-sentinel) - - ;; called when the process receive packet - (set-process-filter redit-client-process 'redit-client-process-filter) - - ;; //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 じゃなくて バイナリで貰わないとずれる?可能性があるので - (set-process-coding-system redit-client-process 'binary 'binary) + (let (bufname) + (setq bufname (encode-coding-string + (buffer-name) + rep-string-encoding)) + (if redit-client-process + (progn + (set-process-sentinel redit-client-process nil) + (condition-case () ;; + (delete-process redit-client-process) (error nil)))) + + (setq redit-client-process (open-network-stream + "redit-client" nil "localhost" 8766)) - ;; プロセスが生きてるとき、 emacs を終了しようとすると - ;; 「processがうんたらで、本当に切ってもいいの y/n」 - ;; って聞かれる。nil てやっておくと聞かれない。 - ;; quit を入れるんなら t にして有効にすべきなんだろうか。 - ;; 今は nil で - (set-process-query-on-exit-flag redit-client-process nil) + ;; called when the process changes state + (set-process-sentinel redit-client-process 'redit-client-sentinel) + + ;; called when the process receive packet + (set-process-filter redit-client-process 'redit-client-process-filter) - ;; not necessary since Emacs 21.1 - ;; (make-local-hook 'before-change-functions) - ;; (make-local-hook 'after-change-functions) + ;; //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 じゃなくてずれる可能性があるので + (set-process-coding-system redit-client-process 'binary 'binary) + + ;; プロセスが生きてるとき、 emacs を終了しようとすると + ;; 「processがうんたらで、本当に切ってもいいの y/n」 + ;; って聞かれる。nil てやっておくと聞かれない。 + ;; quit を入れるんなら t にして有効にすべきなんだろうか。 + ;; 今は nil で + (set-process-query-on-exit-flag redit-client-process nil) - (if (string= "*scratch*" (buffer-name)) - ;; JOIN if buffer-name is "*scratch*" - (process-send-string redit-client-process - (concat - (redit-pack - redit-join-command - 0 0 0 0 0))) - ;; PUT if buffer-name is not "*scratch*" - (process-send-string redit-client-process - (concat - (redit-pack + ;; not necessary since Emacs 21.1 + ;; (make-local-hook 'before-change-functions) + ;; (make-local-hook 'after-change-functions) + + (if (string= "*scratch*" bufname) + ;; JOIN if buffer-name is "*scratch*" + (process-send-string + redit-client-process + (concat + (redit-pack + redit-join-command + 0 0 0 0 0))) + ;; PUT if buffer-name is not "*scratch*" + (process-send-string + redit-client-process + (concat + (redit-pack redit-put-command - 0 0 0 0 (string-bytes (encode-coding-string (buffer-name) rep-string-encoding))) (buffer-name))))) - + 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." @@ -224,19 +233,24 @@ ;; 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 -;; (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.") -;; ) -;; ) +(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* の時に呼び出されるので @@ -554,7 +568,7 @@ (endl (real-count-lines end)) ;; end の行番号 (currline)) ;; currline = nil - (message "before-change-function") + ;; (message "before-change-function") ;; 前回の編集した行と今回の編集した行が ;; 違っていたら前回の編集をサーバへ送る @@ -579,7 +593,7 @@ (endl (real-count-lines end)) (currline)) - (message "after-change-function") + ;; (message "after-change-function") ;; 挿入処理で起こる。 ;; (ex. 改行, C-y などのペースト, ...)