ãã®è¨äºã¯Emacs Advent Calendar 22æ¥ç®ã®è¨äºã§ããåæ¥ã¯Emacs Lispã§ã·ã§ã«ã³ãã³ããæ´»ç¨ããã§ããã
æè¿Mastering Emacsã¨ããæ¬ãèªã¿ã¾ãããEmacsã®æ¬ãè³¼å ¥ããã®ã¯ä¹ ãã¶ãã§ããããªãé¢ç½ãã£ãã§ããæ´æ¸ãªã®ã§èªãã®ã大å¤ã§ãããè¦å´ãã¦èªã価å¤ã¯ãã£ãã¨æãã¦ãã¾ãã
ããããªãã¨æãã®ãEmacsã®æ大ã®é åã®1ã¤ã§ãããã«ã¹ã¿ãã¤ãºãã«é¢ãã話ãã»ã¨ãã©ãªãã¨ãããã¨ã§ããåºç¤ã«ã»ãã®å°ãã ãã«ã¹ã¿ãã¤ãºã®æ¹æ³ãæ¸ãã¦ããã¾ãã(ããããããM-x customizeã®ä½¿ãæ¹ã ã£ãããã)ãEmacsã®æ´å²ãã¤ã³ã¹ãã¼ã«ãèµ·åãªãã·ã§ã³ããã«ãã®èªã¿æ¹ãã«ã¼ã½ã«ã®ç§»åãããã¹ãã®ç·¨éã»ã»ã¨ç¶ãã¾ããå 容ã®å¤§åã¯Emacsã®åºæ¬çãªæ©è½ãæ·±ãç¥ããã¨ã«ãã©ã¼ã«ã¹ããã¦ããã®ã§ããå®è·µVimã¨ããVimã®ä¸æ ¸ã¨ãªãã³ã³ã»ãããç´¹ä»ããç´ æ´ãããæ¬ãããã¾ããæ¬æ¸ã¯ãã®Emacsçã ã¨ãã£ã¦ãã¾ã£ã¦ãããããç¥ãã¾ããã
ä»åã¯Mastering Emacsã®ä¸ã§ãç¹ã«é¢ç½ãã£ãæ°å¼æ°ã®è©±ãç´¹ä»ãã¾ãã
ã¿ã¤ãæ°ãæ¸ãã
ããã¾ãããããã«æ¸ãã¦ãã£ããã¨ã®æå³ãå®å ¨ã«ã¯ãéãã¦ãã¾ãã(詳ããã¯ã³ã¡ã³ãã§ææãããéãã§ã)ãæã¡æ¶ãç·ã®é¨åã¯å®å ¨ã«ééããªã®ã§èªã¿é£ã°ãã¦ãã ããã»ã»ã
ãChapter 5 The Theory of Editingã(ãã£ãã¿ã¼5 ç·¨éã®ã»ãªãªã¼)ã§Linuxä½è
Linusããã®æåãªè¨èãå¼ç¨ããã¦ãã¾ããã
"An inï¬nite number of monkeys typing into GNU Emacs would never make a good program." - Linus Torvalds
ãç¡é§ãªãã¼ã¿ã¤ããEmacsã«æã¡è¾¼ãã§ããéãã¯è¯ãããã°ã©ã ãä½ããããã¨ã¯ãªãã ãã(æ訳)ããã£ã¨ã²ã©ããã¥ã¢ã³ã¹ã§è¨ã£ã¦ããæ°ããã¾ããã¾ããããªæå³ãããªããã¨ãEmacsã«ã¯ã¿ã¤ãæ°ãæ¸ããããã®æ©è½ãããããç¨æããã¦ããã®ã§ãã¾ã使ãããªãã¦ããã°ã©ã ã«éä¸ãã¾ãããã¨ãããã¨ã ã¨(ååãã«)ç解ãã¾ããã
Emacsã«ã¯ã¿ã¤ãæ°ãæ¸ããããã®æ©è½ãããããç¨æããã¦ããã®ã§ãã¾ã使ãã¾ãããã
ä½è ã®Mickey PetersenããMarking is unnecessaryã(ãã¼ãã³ã°ã¯ä¸è¦ã§ã)ã¨è¨ã£ã¦ãã¾ããç´æ¥ããã¹ããåãåãæ¹æ³ãããå ´åã¯ãã¡ãã使ã£ãæ¹ã ãã¼ã¯âé¸æâkill ããã2æçåã§ããã¨ãããã¨ã§ããã
è¦ã¯ã§ããã ãã¿ã¤ãæ°ãå°ãªãç®çã®ç·¨éãéæããæ¹ãè¯ããããã¦ã¯Emacsã¯ãããã§ããããã«è¨è¨ããã¦ãããã¨è¨ã£ã¦ããã®ã ã¨æãã¾ãã
æ°å¼æ°ã¨çµã¿åããã¦ããã«æ¸ãã
以ä¸ã®ãããªç¶æ³ã§foo, barãåé¤ãããã¨ãèãã¾ãã(ãâ¡ãã¯ã«ã¼ã½ã«ä½ç½®ã§ãã) é常ã¯è¡é ã«æ»ã£ã¦(C-a)ãè¡åé¤(C-k)ãç¹°ãè¿ããããè¡å
¨ä½åé¤(C-S-<backspace>
)ã3åæ¼ããããªäººãå¤ãã¨æãã¾ãã
def foo fooâ¡ bar baz end
ãããã3è¡æ¶ãããã®ã¯èªæãªã®ã§æ°å¼æ°ã使ãã¾ãã C-3 C-S-<backspace>
ã§ãã
def foo â¡ baz end
ç¶ãã¦æ¸ç±å ã®ä¾ãå¼ç¨ãã¾ããã«ã¼ã½ã«æåã®æååãåé¤ãããã¨èãã¦ãã¾ãã
s = make_upper_case("hello, world!"â¡)
é常ã¯æååã®å
é ã«ã«ã¼ã½ã«ãåããã¦åé¤ã¨èãã¾ããããããã¤ãã¹ã®æ°å¼æ°ã使ãã¨1ã³ãã³ãã§åé¤ã§ããã®ã§ããC-M-- C-M-k
ã§å¾ãæ¹åã«Så¼åé¤ã§ãã
s = make_upper_case(â¡)
â» Så¼ã¯Emacsãç¨æãã¦ããæ§æåä½ã§ã大æµã®ã¡ã¸ã£ã¼ã¢ã¼ãã§ã¯æ¬å¼§ãæååãåèªã®ä¸¦ã³ãªã©ãã¾ã¨ãã¦1ã³ãã³ãã§å¦çãããã¨ãã§ãã¾ã
ä»ã«ãother-windowã®éã¹ã¯ãã¼ã«ããã¤ãã¹æ°å¼æ°ã§è¡ãã¨ããä¾ãç´¹ä»ããã¦ãã¾ãããé常ã¹ã¯ãã¼ã«ãC-M-v
ã«ãªãéã¹ã¯ãã¼ã«ãC-M-- C-M-v
ã«ãªãã¾ããéã¹ã¯ãã¼ã«ã«ã¯C-M-S-v
ã¨ãããã¼ãã¤ã³ããå°ç¨ã«å²ãå½ã¦ããã¦ããã®ã§ãããC-M-v
ã¨C-M-S-v
ã交äºã«ç¹°ãè¿ããããC-M-v
ã¨C-M-- C-M-v
ãç¹°ãè¿ããæ¹ãä¸æè°ã¨ãã³ããããã®ã§ã(ãã²å®éã«ãã£ã¦è¦ã¦ãã ãã)ã
æ°å¼æ°ã¯C-, M-, C-M- å ¨ã¦ã«å²ãå½ã¦ããã¦ãã
å®ã¯æ°å¼æ°ã¯Emacsã®ä¸ã«å¤§éã«å²ãå½ã¦ããã¦ãã¾ãã
ãªãã¨33種é¡ã®ãã¼ãã¤ã³ã
ã«å²ãå½ã¦ããã¦ãã¾ããæ°å¼æ°ã¨ãã¦35ã渡ãããæã¯
C-3
C-5
(æ°å¼æ°35)M-3
M-5
(æ°å¼æ°35)C-M-3
M-5
(æ°å¼æ°35)
ã©ãã35ã渡ãã¾ãããªããã®ãããªé ç½®ã«ãªã£ã¦ããã®ã§ããããï¼
ããã¯ãã©ã®ã¢ãã£ãã¡ã¤ã¢(Modifier, C-,M-,C-Mãªã©ã®ä»ã®ãã¼ã¨çµã¿åããã¦ä½¿ããã¼ã®ãã¨ã§ã)ã使ãã³ãã³ãã§ãåããã³ãã§æ°å¼æ°ãå ¥åãããããªã®ã§ããä¾ãã°C-1..9,0,-ã®ã¿ã«æ°å¼æ°ã®è¨å®ã渡ããã¦ããããC-fãC-kã¨ãã£ãC-ããå§ã¾ãã³ãã³ãã¯ãã³ãããå ¥åã§ãã¾ãããM-fãC-M-kã¨ãã£ãã³ãã³ãã«æ°å¼æ°ã渡ãæã«å¤§ãããã³ããçãã¾ãã
C-3
C-5
C-f
(Good)C-3
C-5
M-f
(CããMã«ã¢ãã£ãã¤ã¢ãåãæ¿ããå¿ è¦ããã)C-3
C-5
C-M-k
(CããC-Mã«ã¢ãã£ãã¤ã¢ãåãæ¿ããå¿ è¦ããã)
ããã§ã¯æé¦ãç²ãã¦ãã¾ãã¾ããããã§Emacsã«ã¯C-,M-,C-M-å ¨ã¦ã«æ°å¼æ°ãè¨å®ããã¦ããã®ã§ãã
C-3
C-5
C-f
(Good)M-3
M-5
M-f
(Good)C-M-3
C-M-5
C-M-k
(Good)
å®è¡ãããã³ãã³ãã¨åãã¢ãã£ãã¡ã¤ã¢ã®æ°å¼æ°ã使ããã¨ã§ãã³ãããæ°å¼æ°ãå ¥åãããã¨ãã§ãã¾ããã
ã¾ã¨ã: ãã³ãã®è¯ãã³ãã³ãå ¥åãæèããã
æ¸ç±ã®ä¸ã§ã tempo(ãã³ã) ã¨ããè¨èãä½åº¦ãåºã¦ãã¾ããã¿ã¤ãæ°ã®å°ãªãããã³ãã®è¯ãç·¨éãè¡ããã¨ã§ã³ã¼ããã®ãã®ã«éä¸ã§ããæéãå¢ãã¦ããã¾ãã
ãã®ãããªãã¤ã¬ã¯ããªç·¨éæ¹æ³ã¯Vimã®å°å£²ç¹è¨±ã ã¨ãã£ã¨æã£ã¦ãã¾ããããããC-(è¿è·é¢),M-(ä¸è·é¢),C-M-(é è·é¢)ã«å²ãå½ã¦ãããæ§æåä½ã®ç·¨éã³ãã³ãã¨ãæ°å¼æ°ãè² ã®å¼æ°ãçµã¿åããããã¨ã§Emacsã§ãååã«ãã¤ã¬ã¯ããªç·¨éãã§ããã®ã ã¨æ°ãä»ãããã¾ãããMastering Emacsã«æè¬ãã¦ãã¾ãããããã§10年以ä¸ããã¦ä¸æ¸ããã¦ãã¾ã£ããã¼ãã¤ã³ããå¤ãã¦ããã©ã«ãã«æ»ãã¦ããã³ããããç¶ãã¦ãã¾ãã»ã»ã
Mastering Emacsã«ã¯ä»ã«ãå¾¹åºçãªãã«ãã®ä½¿ãæ¹ãä»ã¾ã§ç¥ããªãã£ãããããã®(æ¨æºæ·»ä»ããã)便å©ã³ãã³ããªã©ãããããç´¹ä»ããã¦ãã¾ãããã²ããããã®äººã«èªãã§ããã£ã¦ãã®æåãã¿ãªããã¨å ±æãããã§ã(ããã¦ãã²ã¨ãæ¥æ¬èªã§èªã¿ãã)ãå 容ã«ã¤ãã¦èå³ã®ãããã¨ããããã¾ããã@ongaeshiã¾ã§ãæ°è»½ã«ã©ãããããã§ã¯ã