2013年1月16日水曜日

[Emacs][Elisp]プロセス

プロセス実行
start-process

プロセスの状態を監視
フォーマット
set-process-sentinel process sentinel
process が Finished, exited abnormally など特定のイベント状態になった場合に sentinel で渡した命令を実行する
(defun ls-test ()
  (interactive)
  (defun msg-me (process event)
  (princ
    (format "Process: %s had the event [%s]" process event)))
    (set-process-sentinel
    (start-process "ls" "*ls*" "ls" "-a")
    'msg-me)
  )

(defun ls-test2 ()
  (interactive)
  (set-process-sentinel
    (start-process "ls" "*ls*" "ls" "-a")
    (lambda (process event)
    (princ
      (format "Process: %s had the event [%s]" process event)))
    )
  )

*ls*
.
..
COPYING
addpm.exe
cmdproxy.exe
ctags.exe
ddeclient.exe
digest-doc.exe
ebrowse.exe
emacs.exe
emacsclient.exe
emacsclientw.exe
etags.exe
hexl.exe
movemail.exe
runemacs.exe
sorted-doc.exe
*Messages*
Process: ls<1> had the event [finished
]

0 件のコメント:

コメントを投稿