Emacs 㧠IPC ã RPC (Emacs Advent Calendar jp: 2011)
Emacs Advent Calendar jp: 2011 : ATND 6æ¥ç®ã®è¨äºã®ã¯ãã§ããããæéãã§ãã¶ã£ã¦ãã¾ãããããããã£ã¦é
ããªã£ã¦ãã¾ãã¾ããã
çæ§ãä¹±ãã¦ãã¾ã£ã¦ãã¿ã¾ããã
ä»åã®è¨äºã§ã¯ãEmacsã§ã®IPC(Inter-Process Communication)ãRPC(Remote Procedure Call)ã®æ¹æ³ã«ã¤ãã¦ãèªåã®ç¥ã£ã¦ããç¯å²ã§ã¾ã¨ãã¦ã¿ã¾ããIPCã¯ãããã°ã©ã ã®éã§éä¿¡ããä»çµã¿ã§ããRPCã¯ãæ¢ã«èµ·åãã¦ããããã°ã©ã ã®ä¸é¨ï¼é¢æ°ããµãã«ã¼ãã³ï¼ãå¥ã®ããã°ã©ã ããå¼ã³åºãä»çµã¿ã§ããä¸è¬çã«IPCã®æ ã«RPCãå«ã¾ãã¾ãã
Emacsã«ã¯ã©ããªIPC/RPCã®å®ç¾æ¹æ³ãããã®ããå®éã®å¿ç¨ä¾ãªã©ã5åç¨åº¦ã§ç°¡åã«ã¾ã¨ãã¦ã¿ã¾ãã
Emacsã®æ¨æºIPCæ段
以ä¸ã®ãããªãã®ãããã¾ããï¼Emacs 23 以ä¸ã®å ´åï¼
- ãã¤ã
- ããã»ã¹ãèµ·åãã¦ãã¤ãã§éä¿¡
- ã½ã±ãã
- TCPã½ã±ãã, UDPã½ã±ãã, ãã¡ã¤ã³ã½ã±ãã
- D-Bus
- Linux Desktop ç°å¢åãã®éä¿¡ãããã³ã«
- D-Bus - Wikipedia
- ãã¡ã¤ã«èªã¿æ¸ã
- æä»å¶å¾¡ãå¿ è¦
- emacsclient
- èµ·åä¸ã®Emacsã¨Så¼ã§ã®ããã¨ã
ã²ã¨éãæã£ã¦ãã¦ã大ä½è²ã åºæ¥ã¾ãããD-Bus以å¤ã¯ãã©ãããã©ã¼ã ä¸ç«ã®äºãèãã¦ä½ããã¦ãã¾ãã
ããããªãããæ¬æ ¼çãªããã°ã©ãã³ã°ç°å¢ã¨ãã¦ã¯ç´°ããå¶å¾¡ãåºæ¥ããæããæãããããã¨ãå¤ãã§ããç¹ã«ãå ±æã©ã¤ãã©ãªã«ãªã³ã¯ãã¦ãé«æ©è½ã»é«ããã©ã¼ãã³ã¹ãªéä¿¡æ段ï¼DBç´æ¥ç¶ã¨ãmsgpackã¨ãï¼ã使ããã¨ãåºæ¥ã¾ããã
ãã®ãããä¸è¬çã«ã¯å¥ã®ä¸ç¶ããã°ã©ã ãä½æãã¦ããã¤ããªã©ã§éä¿¡ãã¦ããããæ©è½ãå®ç¾ããã¨ãããã¨ãå¤ãã§ãããã®ãããã®æ´å²ãç¶æ³ã«ã¤ãã¦ã¯ã id:m2ym ããã®ææ¸ http://cx4a.org/pub/emacs-is-dead.ja.html ã詳ããã§ãã*1
IPC/RPC ãããã
Emacsã§è¡ããã¦ãã IPC/RPC ã®æ段ã«ã¤ãã¦ç°¡åã«ç´¹ä»ãã¦ã¿ã¾ãã
ã³ãã³ãèµ·å
ããã°ã©ã ãèµ·åããçµæãæ¨æºåºåãªã©ããããã¹ãçã§åãåãæ¹å¼ã§ãã
åæçã«å¼ã¹ã°ç°¡åã«ä½¿ãã¾ãããå¤é¨ããã°ã©ã ã ãã§ãããã°ãã§ããã®ã§æ¥½ã§ãã
ä¸æ¹ã§ãå¤é¨ããã°ã©ã ãè¨å®ãOSãç°å¢ã«ä¾åãã¦åããªããã¨ãããã¾ããããä»ã®æ¹æ³ãããã¯ããã«åé¡è§£æ±ºã楽ã§ãã
- ä¾
- Wanderlust ãã bogofilter, bsfilter ãªã©
- æååããã¹ãã å¤å®
- GCCSense
- C/C++ãªã©ã®è£å®ãå®ç¾©ã¸ã£ã³ããªã©
- rsense
- flymake
- éåæã§å®è¡ãéä¿¡ã¯ãã¦ãªãã¦çµæãåãåãã ã
- ããã¯ã°ã©ã¦ã³ãã§ã³ã³ãã¤ã« â ã¨ã©ã¼è¡¨ç¤º
- ãã®ä»ã«ããããããã
- Wanderlust ãã bogofilter, bsfilter ãªã©
ãã¤ãã»ã½ã±ãã
ããã¯ã°ã©ã¦ã³ãã§å¤é¨ããã°ã©ã ãèµ·åãããã¤ããã½ã±ãããªã©ã§éä¿¡ããæ¹æ³ã§ãã
éåæããã°ã©ãã³ã°ã大å¤ã§ããã常ã«èµ·åãã¦ããããå¿çã®æ§è½ãè¯ããã¾ãå¤é¨ããã°ã©ã å´ãç¶æ
ãæã¤ãã¨ãã§ããã®ã§ãåºæ¥ããã¨ã大å¹
ã«å¢ãã¾ãã
- ãã¤ãã§éä¿¡
- migemo
- ãã¼ãå â æ£è¦è¡¨ç¾ã®å¤æ
- lookup / eblook
- åèª â è¾æ¸ã®æ¤ç´¢
- ispell
- ã¹ãã«ãã¹ã®ãã§ã㯠â ã¤ã³ã¿ã©ã¯ãã£ãã«ä¿®æ£
- ibus.el
- comint.el
- ã¤ã³ã¿ã©ã¯ãã£ãå ¥åã管ç
- èµ·åãããã·ã§ã«ã¨ããããã¡ã®å ¥åºåãä¸ç¶
- Pymacs
- Pythonã¨EmacsLispãééçã«ã¤ãªã
- éä¿¡ããªãã¸ã§ã¯ããããã·ãã·ãªã¢ã©ã¤ãº
- å¿ç¨ä¾å¤æ°
- el4r
- Rubyã¨EmacsLispãééçã«ã¤ãªã
- éä¿¡ããªãã¸ã§ã¯ããããã·ãã·ãªã¢ã©ã¤ãº
- migemo
- TCPã½ã±ããã§éä¿¡
- SLIME / Swank
- Lispéçºç°å¢
- ã³ã³ãã¤ã«ãè©ä¾¡ãå®ç¾©åç §ãªã©ãããã
- IPCã«ããRPCã¨ãã¦é«æ©è½ããææ¬è¨è¨ã»å®è£
- ãã¡ã¤ã³ã½ã±ããã使ãã?
- IIIMECF(ATOK)
- ã½ã±ããã§éåæéä¿¡
- ãã¼ã¤ãã³ã â æ¼¢åå¤æãUIæ´æ°ï¼éåæï¼
- SLIME / Swank
(2011/12/09 TCPã½ã±ããã®ã¨ããã«ãã¤ãéä¿¡ãæ··ãã£ã¦ããã®ãä¿®æ£)
D-Bus
D-Bus 㯠Linux Desktop ä¸ã§ã¯ããªãããã¡ã¯ãã«è¿ãIPCç°å¢ã«ãªã£ã¦ãã¾ãã
- D-Bus - Wikipedia (åæ²)
1対1ã®éä¿¡ã ãã§ã¯ãªããå¿ è¦ãªããã»ã¹ã«ã¤ãã³ãéç¥ããããããªãã¸ã§ã¯ãã®ã·ãªã¢ã©ã¤ãºããµã¼ãã¹ã®ã¤ã³ã¹ãã¯ã·ã§ã³ãªã©ãåºæ¥ããããIPCã¨ãã¦ã¯ããªãé«æ©è½ã§ãã
- åèæç®
skype.el ã§ã使ã£ã¦ãã¾ããããããç©æ¥µçã«å©ç¨ããã¢ããªã±ã¼ã·ã§ã³ã¯ã»ã¨ãã©ç¡ããæ£ç´ D-Bus ãEmacsã§ãµãã¼ãããå¿ è¦ã¯ãªãã£ãï¼ãã£ã¨ä»ã«ãããã¨ããã£ãï¼ï¼ã®ã§ã¯ãªããã¨ãæã£ã¦ãã¾ãã
emacsclient
èµ·åä¸ã®Emacsã«ãã¡ã¤ã«ããªã¼ãã³ããããããªç¨éãå§åçã§ãããSå¼ãéãè¾¼ãã§è©ä¾¡ããããåºæ¥ããããæ軽ãªRPCã¨ãã¦å©ç¨ã§ãã¾ãã
HTTP / Webãµã¼ãã¹
æè¿ã¯ã¤ã³ã¿ã¼ãããä¸ã®ãµã¼ãã¹ã¨éä¿¡ããæ©ä¼ãå¤ããªã£ã¦ãã¾ãããREST APIã«ç´æ¥ã¢ã¯ã»ã¹ããããXML-RPCãªã©ã§æ©è½ãæ軽ã«å¼ã³åºããã¨ãåºæ¥ã¾ãã
xml-rpc.el ã®ããã«ãæ¨æºã®urlããã±ã¼ã¸ã使ã£ã¦Emacsåç¬ã§éä¿¡ãããã¨ãåºæ¥ã¾ããããã³ãã¡ãããææããéããç´°ãããã°ãSSLã»ãããã·çµç±ã®éä¿¡ã§åé¡ãããã®ã§ãèªåå®è£ ããå ´å㯠curl, wget ã使ãæ¹ãå å®ã ã¨æãã¾ãã
Webãµã¼ãã¹ã¨éä¿¡ããå ´åã«åé¡ã«ãªãã®ã¯èªè¨¼ã§ããä¸è¬çã«ä»¥ä¸ã®æ¹æ³ãããã¾ãã
- OAuth
- Webã¢ããªåãã® OAuth ãå®è£ ããæ¹æ³ãã³ã¹ãé«ã
- Twitterã¯ã©ã¤ã¢ã³ãã¨ãã ã¨å¿
é
- oauthã©ã¤ãã©ãª : EmacsWiki: O Auth Library
- twittering-mode ã¯èªåå®è£
- API key
- HTTPã»ãã·ã§ã³ Cookie
- èªè¨¼APIããã¯ããã¼ãçºè¡ãã¦ããã£ã¦ã以éã®éä¿¡ã§ä½¿ã
- åè : セッションキーとして出力されるCookieをwgetで保存する: hogepiyo
- ããã¾ãè¦ããã¨ç¡ãããã¼ã¸ã¹ã¯ã¬ã¤ãã³ã°ï¼ ãªãã¡ã©ã¼ã¨ãCSRF対çã¯ï¼
- BASICèªè¨¼
- ã¦ã¼ã¶ã¼ã«èªè¨¼æ å ±ãå ¥ãã¦ããã
- ãã¹ã¯ã¼ããã¦ã¼ã¶ã¼æ å ±ã wget ãªã©ã«æ¸¡ãå¿ è¦ããã
ä»å¾ãWebãµã¼ãã¹ã¨ã®éä¿¡ã¯å¢ãã¦ããã¨æãã¾ãã®ã§ããã®è¾ºãã®ç°å¢ãæ´åããã¦ããã¨ä¾¿å©ã«ãªãããã§ãã
EPC ã«ç¶ã
ããã¾ã§ã®IPC/RPCã¯ããªããã£ããããï¼ãã¤ãã¨ãD-Busã¨ãï¼ããç¹å®ã®ç®çã®ããã®å°ç¨ã¹ã¿ãã¯ï¼pymacsã¨ãel4rã¨ãï¼ãªã®ã§ãå¥ã®ããã°ã©ã ãæ°è»½ã«å¼ã³åºãã¦ä½¿ãããããªãæ±ç¨ã®RPCã¹ã¿ãã¯ãããã¾ããã
ä¾ãã°ãEmacsã¯DBã«ç´æ¥æ¥ç¶ãããã¨ãåºæ¥ã¾ããããDBã«æ¥ç¶ãã¦èªç±ã«SQLãçºè¡ãã¦ãã¼ã¿ãããåãã§ããã¨ã大å¤å¤¢ãåºããã¾ããããã«ããããPythonãRubyãªã©ã®å°ç¨ã¹ã¿ãã¯ã§ã¯ãªããã¤ã³ã¿ãã§ã¼ã¹ã¯åºå®ã®ã¾ã¾ãèªåã®å¥½ããªè¨èªã§æ¡å¼µã§ããã¨å¤§å¤ç´ æµã§ãã
ã¨ãããã¨ã§ãç¾å¨ EPC(Emacs Procedure Call)ãªããã®ãã¤ãã£ã¦ãã¾ããYAPC Asia 2011ã®æã«デモしたãããªãEmacsããPerlãèªç±ã«å¼ãã§ããããæ¾é¡ãªãã¨ãå®ç¾ã§ããããã«ããäºå®ã§ãã
Emacs - Perl éã¯ã ãããåãã®ã§ããããããªã CPAN ã«ä¸ããåã« PrePAN ã§ã¬ãã¥ã¼ããé¡ããããã¨æã£ã¦ãã¾ãã
ãããã³ã«ã®è©³ç´°ãªã©ã®ããã¥ã¡ã³ããåºã¾ã次第ããç¥ããããäºå®ã§ãã
ããã
æ¬å½ã«ãã¿ã¾ãããAdvent Calendar ã¯å°ç²ãªãã¿ã§æ¯æ¥ç¶ãããã¨ãéè¦ã ã¨æãã¾ãããæ¥å¹´ãåå ããã¨ãã¯æ°ãã¤ãããã¨æãã¾ãã
ãã£ã±ã1æéããããããã¾ããã