Emacs Ruby Mode
Emacs Ruby-Mode
±è¿ë¿í(CN)
ÀÌ ¹®¼´Â Emacs¿¡¼ Ruby ÇÁ·Î±×·¡¹ÖÀ» Æí¸®ÇÏ°Ô Çϱâ À§ÇØ È¯°æ ¼³Á¤ÇÏ´Â ¹æ¹ý°ú °£´ÜÇÑ »ç¿ë¹ýÀ» ´Ù·ç°í ÀÖ´Ù.
1. Emacs Ruby ExtensionÀÇ ¼³Ä¡ ¶Emacs ¿¡µðÅÍ¿Í Emacs Ruby Extension(EmacsRubyExtension.zip (39.53 KB) )ÀÌ ÇÊ¿äÇÏ´Ù. (µ¿ºÀµÈ ¾ÐÃàÆÄÀÏ¿¡´Â ¼³Ä¡¿¡ ºÒÇÊ¿äÇÑ ÆÄÀÏÀ» etc·Î À̵¿ÇÏ¿´´Ù.)
Ruby ¾ð¾î´Â ÇʼöÀûÀ¸·Î ¼³Ä¡ÇÒ ÇÊ¿ä´Â ¾øÀ¸³ª ¼³Ä¡ÇÏÁö ¾ÊÀ¸¸é Ruby ÇÁ·Î±×·¡¹ÖÀº ºÒ°¡´ÉÇÏ´Ù.
1.1. ¼³Ä¡ °æ·Î ã±â ¶Emacs Ruby ExtensionÀ» ¼³Ä¡ÇÒ °æ·Î¸¦ ã¾Æ¾ß ÇÑ´Ù.
[PNG image (13.62 KB)] À§ÀÇ È¸éÀº Emacs¸¦ ½ÇÇà½ÃÅ°¸é óÀ½ ³ª¿À´Â ȸéÀÌ´Ù. ÇÏ´Ü¿¡ *scratch*¶ó°í Ç¥½ÃµÇ¾î Àִµ¥ *scratch* ¹öÆÛ¶ó´Â ÀǹÌÀÌ´Ù. Emacs´Â ÇϳªÀÇ ÆíÁý ´ÜÀ§¸¦ ¹öÆÛ¶ó°í ºÎ¸¥´Ù. Emacs´Â load-Path º¯¼ö¿¡ µî·ÏµÈ ÁÖ¼Ò¿¡¼ È®Àå ÆÄÀÏÀ» Àоî¿Â´Ù. Emacs Ruby ExtensionÀÇ ¼³Ä¡¸¦ À§ÇØ Load-Path¸¦ »ìÆ캸ÀÚ.
load-path[*]
[1]°¡ Ä¿¼¶ó¸é ±× À§Ä¡¿¡¼ Ctrl Å°¿Í X¸¦ ´©¸£°í (ÀÌÇÏ C-X) Ctrl Å°¿Í E¸¦ ´©¸¥´Ù. (ÀÌÇÏ C-E) ÀÌÁ¦ºÎÅÍ C-X, C-E¿Í °°Àº ÇüÅ·Π°£·«È÷ ºÎ¸¦ °ÍÀÌ´Ù. ½ÇÇà °á°ú´Â ¾Æ·¡¿Í °°ÀÌ È¸é ÇÏ´Ü¿¡ Ç¥½ÃµÈ´Ù.
[PNG image (17.88 KB)] ¿î¿µÃ¼Á¦³ª ¼¼Æÿ¡ µû¶ó Á¶±Ý¾¿ ´Ù¸£°Ô ³ªÅ¸³ª´Âµ¥ ÀÌ ¹®¼¿¡¼´Â "c:/Program Files/Emacs/emacs/site-lisp"¿¡ ¼³Ä¡ÇÒ °ÍÀÌ´Ù. ¾î¶² Æú´õ³ª ¼³Ä¡Çصµ »ó°ü¾øÁö¸¸ load-path º¯¼ö¿¡ Æ÷ÇÔµÈ °æ·ÎÀ̾î¾ß ÇÑ´Ù.
´Ù¸¥ °æ·Î¿¡ ¼³Ä¡¸¦ ¿øÇÏ´Â µ¶ÀÚ´Â EmacsInstallScript¸¦ ÂüÁ¶Ç϶ó.
ȸé ÇÏ´Ü¿¡ Ç¥½ÃµÇ¾î load-path º¯¼öÀÇ ³»¿ëÀ» »ìÆ캸±â Èûµé´Ù¸é C-X, B, *m, TAB, ENTER¸¦ ´·¯¼ ÀÚ¼¼ÇÏ°Ô È®ÀÎÇØ º¼ ¼ö ÀÖ´Ù. (´Ù½Ã *scratch* ¹öÆÛ·Î À̵¿Çϱâ À§Çؼ C-X, B, *s, TAB, ENTER¸¦ »ç¿ëÇÑ´Ù.)
1.2. Emacs Ruby Extension ÆÄÀÏ º¹»çÇϱ⠶ÇØ´ç Æú´õ¿¡ Emacs Ruby Extension ÆÄÀϵéÀ» º¹»çÇÑ´Ù. ÀÌ ¹®¼¿¡¼± "c:/Program Files/Emacs/emacs/site-lisp"¿¡ º¹Á¦Çϴµ¥ ÇØ´ç ÆÄÀÏÀÇ ÆÄÀϸíÀº ´ÙÀ½°ú °°´Ù.
inf-fuby.elc
rubydb.el rubydb.elc ruby-electric.el ruby-electric.elc ruby-mode.el ruby-mode.elc 1.3. ȯ°æ ¼³Á¤Çϱ⠶ȯ°æ ¼³Á¤Çϱâ À§Çؼ´Â .emacs ÆÄÀÏÀ» ¼öÁ¤ÇØ¾ß ÇÑ´Ù. C+X, C+F¸¦ ´·¯ "ÆÄÀÏ ºÒ·¯¿À±â"¸¦ ÇÏÀÚ.
Find file: C:\Documents and Settings\¿ì¸®Áý/[*]
Find file: C:\Documents and Settings\¿ì¸®Áý/~/
Find file: ~/
Find file: ~/.emacs
(require 'ruby-mode)
(require 'rubydb) (require 'inf-ruby) (require 'ruby-electric) (setq auto-mode-alist (cons '("\.rb$" . ruby-mode) auto-mode-alist)) (Á¦ÀÏ µÚ¿¡ Ãß°¡ÇÏ´Â °ÍÀÌ ¹«³ÇÒ °ÍÀÌ´Ù.) Ãß°¡°¡ ¿Ï·á µÇ¾ú´Ù¸é C-X, C-S·Î ÀúÀåÇ϶ó.
Emacs¸¦ ´Ù½Ã ½ÇÇàÇÏ°í´Â ¿¡·¯°¡ ³ªÁö ¾Ê±æ ±â¿øÇÏÀÚ.
2. ruby-modeÀÇ »ç¿ë ¶ruby-mode·Î ÀüȯÀº µÎ°¡Áö ¹æ¹ýÀ¸·Î ÇÒ ¼ö ÀÖ´Ù.
2.1. Hello Man ¶ÇϳªÀÇ ÇÁ·Î±×·¥À» ¸¸µé¸é¼ ruby-mode¸¦ Á÷Á¢ »ç¿ëÇØ º¸ÀÚ.
C-X, C-F¸¦ ÀÔ·ÂÇÏÀÚ.
Find file: c:/Documents and Settings/¿ì¸®Áý/Application Data/[*]
Find file: c:/Documents and Settings/¿ì¸®Áý/Application Data//
Find file: /
[PNG image (10.99 KB)] helloMan.rb¶ó´Â ÆÄÀÏ¸í ¿·¿¡ (Ruby)¶ó´Â ±ÛÀÚ°¡ º¸ÀδÙ. ÇöÀç ruby-mode·Î ÀÛµ¿ÇÏ°í ÀÖ´Ù´Â °ÍÀÌ´Ù.
M-;¸¦ ÀÔ·ÂÇÏÀÚ. (À§¿¡ ¼³¸íÇßµí MÀº ALT Å°³ª ESC¸¦ ÀǹÌÇÑ´Ù. ALT¿Í ;¸¦ µ¿½Ã¿¡ ´©¸£¸é µÈ´Ù.) ÀÌ ¸í·ÉÀº ÁÖ¼®À» ÀÔ·ÂÇÏ´Â ¸í·É¾î´Ù.
# ÀÌÈÄ¿¡ ¾Æ·¡ÀÇ ³»¿ëÀ» ÀÔ·ÂÇÏÀÚ. (¾ûÅ͸® ÁÖ¼®À̶ó´Â °ÍÀº ½Å°æ¾²Áö ¸»ÀÚ.)
# Ruby mode: Major mode for edting ruby scripts. TAB properly idents subexpressions of mult-line class, module, def, if, while, for, do, and case statements, taking nesting into account
[PNG image (13.34 KB)] ÀÚµ¿À¸·Î ÁÖ¼®ÀÇ ÇüÅ°¡ ¿©·¯ ÁÙ·Î Á¤¸®µÇ¾î ÀÖ´Ù. ÇÁ·Î±×·¥ ¾Õ ºÎºÐ¿¡ ±ä ÁÖ¼®À» ´Ù´Â °æ¿ì¿¡ ÀÌ·± ¹æ¹ýÀ¸·Î ÁÖ¼®À» ´Þ ¼ö ÀÖ´Ù. ÀÌÁ¦ ±â´Ù·Á¿Ô´ø HelloMan Ŭ·¡½º¸¦ ÀÛ¼ºÇغ¸ÀÚ.
# Ruby mode: Major mode for edting ruby scripts. TAB properly idents subexpressions of mult-line class, module, def, if, while, for, do, and case statements, taking nesting into account
class HelloMan def sayHello ³î¶ó°Å³ª ´çȲÇÒ ÇÊ¿ä¾ø´Ù. Ä¿¼¸¦ ¿Å±âÁö ¸»°í TABÀ» ´©¸£ÀÚ.
Emacs¿¡¼ TABÀº ÇØ´ç ¶óÀÎÀ» ÀÚµ¿À¸·Î µé¿©¾²±â ÇÏ´Â ¸í·É¾îÀÌ´Ù. (´Ù¸¥ ¿¡µðÅÍ¿¡¼ÀÇ TABÀÌ 4-8ÄÀ» ¶ç¿ì´Â ¹®ÀÚ¸¦ »ðÀÔÇÏ´Â °Í°ú´Â Â÷ÀÌ°¡ ÀÖ´Ù.)
class HelloMan
def sayHello ¸Å ¶óÀÎ TABÀ» ´·¯ Á¤·ÄÇÏ´Â °ÍÀº ¾Æ¹«·¡µµ ±ÍÂú´Ù. C-J¸¦ ´©¸£ÀÚ. Àͼ÷ÇÑ µé¿©¾²±â°¡ µÉ°ÍÀÌ´Ù.
C-J´Â ±× ÇàÀ» ÀÚµ¿À¸·Î µé¿©¾²±â ÇÑÈÄ ´ÙÀ½ ÇàÀ¸·Î ¹Ù²Ù°í ´ÙÀ½ ÇàÀÇ µé¿©¾²±â¸¦ ÇØÁÖ´Â ¸í·É¾î´Ù.
¾î·Á¿ö º¸À̸é ÇÑ°¡Áö¸¸ ±â¾ïÇÏÀÚ. ÀÌÁ¦ºÎÅÍ´Â ¿£ÅÍ ´ë½Å¿¡ C-J¸¦ ´©¸£ÀÚ.
class HelloMan
def sayHello "Helo, guy. I love RUBY." ÇÔ¼ö¿Í Ŭ·¡½º¸¦ ´Ù ´ÝÀÚ. ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÇ϶ó.
C-J, C-C, C-E, C-J, C-C, C-E
JCEJCE
[PNG image (14.58 KB)] C-C, C-E´Â end¸¦ ÀÔ·ÂÇÏ´Â ¸í·É¾îÀÌ´Ù. ruby´Â end°¡ ÀÚÁÖ ¾²ÀÌ´Ï ÄÜÆ®·ÑÀ» ´©¸¥ ä·Î JCE¸¦ ´©¸£´Â Å×Å©´ÐÀº ÀÚÁÖ ÀÌ¿ëÇÒ ¼ö ÀÖ´Ù.
To Do ´Ù¸¥ ¸ðµåÀÇ »ç¿ë¹ý°ú ¼³Á¤¹ýÀ» Ãß°¡ÇÏÀÚ -- CN 2006-02-04 13:53:18
|
Far duller than a serpent's tooth it is to spend a quiet youth. |