ã横éã«ãããããã«æ¸ããäºæ ã§ãEmacsã§JavaScriptã½ã¼ã¹ã³ã¼ããèªãç°å¢ãå°ãæ´ããããã¨ã
次ã®2ã¤ã®ãã¼ã«ãå°å ¥ãã¦ã¿ãããã£ã¨ã
- js2-modeï¼ http://code.google.com/p/js2-mode/
- ã¨ã°ãºã¼ãã©ã³ãï¼EXUBERANTï¼Ctagsï¼ http://ctags.sourceforge.net/
å 容ï¼
- ããè¯ãEmacs JavaScriptã¢ã¼ã -- js2-mode
- å¼·çãªã¿ã°ãã¡ã¤ã«ä½æãã¼ã« -- ã¨ã°ãºã¼ãã©ã³ãCtags
- ã¨ã°ãºã¼ãã©ã³ãCtagsã調ã¹ã¦ã¿ã
- Emacsã§JavaScriptã½ã¼ã¹ãèªã
âããè¯ãEmacs JavaScriptã¢ã¼ã -- js2-mode
以åï¼2006å¹´7æï¼ãã²ãã½ãããã®è¨äºã§ããecmascript-mode.el ï¼ javascript.el ã¿ããã ãã¨æ¸ãã¦ãã£ãã®ã§ãåãjavascript.elã使ã£ã¦ããã®ã§ãããJavaScriptã®æ§æ解æãããã¾ãç²¾å¯ã§ãªãã¦ã¤ãã¤ããä¾ãã°ã/"[^"\\\n\r]*"/g
ã¨ããæ£è¦è¡¨ç¾ãåºç¾ããã¨ãæå¾ã®ããã«ã¯ã©ã¼ããæååã®ã¯ãã¾ãã¨èªèãã¦ãã¾ãã®ã§ãããã
js2-modeã«åãæ¿ãã¾ãããï¼
- js2-modeãã¼ã ãã¼ã¸ã®Featured Downloadsãããjs2-20080616a.elï¼ä»æ¥ã®æç¹ã®ææ°ãã¼ã¸ã§ã³ï¼ããã¦ã³ãã¼ãã
- js2-20080616a.elããjs2.elã¨ãã¦ãEmacsï¼åã¯Meadow3ï¼ã®site-lisp/ã®ä¸ã«ã³ãã¼ã
- site-lisp/ãDiredã§éãã¦ã M-x byte-compile-file RET js2.el RET ã§ã³ã³ãã¤ã«ãjs2.elcãåºæ¥ã¦ããã®ã確èªã
- ~/.emacsãç·¨éï¼ããä¸ï¼ã
;; js2-mode
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
ããã§ãï¼javascript.elããã¤ã©ã¤ãã£ã³ã°ã«å¤±æãã¦ããï¼prototype-1.6.0.2.jsãè¦ãã¨ãã¡ããã¨æ§æ解æã§ãã¦ã¾ããã¨ããã©ããã«ä¸ç·ãç¾ãã¾ãããããã¯js2.elããã¤ãã¤ããããªãã®ãã¨å¤æããã¨ããã®ããã§ãã
it highlights syntax errors and underlines warnings
js2ã¯ãæ§æã¨ã©ã¼ããã¤ã©ã¤ã表示ããè¦åãä¸ç·è¡¨ç¤ºãã¾ãã
âå¼·çãªã¿ã°ãã¡ã¤ã«ä½æãã¼ã« -- ã¨ã°ãºã¼ãã©ã³ãCtags
ã½ã¼ã¹ã³ã¼ãä¸ã«åºç¾ããé¢æ°ã大åå¤æ°ã®å®ç¾©ãå¹æçã«åç §ããã«ã¯ã¿ã°ã¸ã£ã³ãã便å©ãEmacsã®ã¿ã°ã¸ã£ã³ãã«ã¤ãã¦ã¯ãä¾ãã°æ¬¡ã®èª¬æãåç §ãã¦ãã ããã
Emacsã«ã¯ãetagsã¨ããã¿ã°ãã¡ã¤ã«ä½æãã¼ã«ãä»å±ãã¦ã¾ãããæ©è½çã«ã¤ãã¤ããç¹ã«JavaScriptã«å¯¾ãã¦ã¯ãã¾ãæ©è½ãã¾ãããã¨ã°ãºã¼ãã©ã³ãCtagsã«ç½®ãæãã¾ãããã
http://ctags.sourceforge.net/ ãã ctags-5.7.tar.gz ã ec57w32.zip ããã¦ã³ãã¼ãã§ãã¾ãããæ¥æ¬èªå¯¾å¿ç㯠http://hp.vector.co.jp/authors/VA025040/ctags/ctags_j.html ããå ¥æã§ãã¾ããæ¥æ¬èªå¯¾å¿çã§ã¯ã--jcode=[ascii|sjis|euc|utf8] ã¨ãããªãã·ã§ã³ã使ãã¾ããæ¥æ¬èªå¯¾å¿Win32ãã¤ããªã¯ ec57j1w32bin.zip ï¼ctags5.7J1 2007/09/10ï¼ããªããhttp://hp.vector.co.jp/authors/VA025040/ctags/ ã«ã¯ãã¨ã°ãºã¼ãã©ã³ãCtagsã®æ¥æ¬èªæ å ±ãè²ã ããã¾ãã
æ¢åã®ctags, etagsãã¨ã°ãºã¼ãã©ã³ãCtagsã§ç½®ãæãã¦ãã¾ã£ã¦åé¡ããã¾ãããã¨ã°ãºã¼ãã©ã³ãã®ctagsã³ãã³ãããã·ã³ããªãã¯ãªã³ã¯ããã¼ããªã³ã¯ããã¡ã¤ã«ã³ãã¼ãªã©ã§etagsã¨ããååã«ãã¦ããã°etagsã¨ãã¦åä½ãã¾ãï¼-e ãªãã·ã§ã³ã§ãOKï¼ãèµ·åããã³ãã³ãã®å®ä½ãä½ã§ãããä¸å®ã«ãªã£ããã--version ãªãã·ã§ã³ã§ç¢ºèªãã¾ãããã
ã¨ã°ãºã¼ãã©ã³ãCtagsã®åä½ã¯ãã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ä»¥å¤ã«ç°å¢å¤æ°CTAGSã¨è¨å®ãã¡ã¤ã«ã§å¶å¾¡ã§ãã¾ãã--verbose ãªãã·ã§ã³ã§ç¢ºèªãã¦ã¿ãã¨ã次ã®é åºã§è¨å®ãèªãããã§ãã
- /ctags.cnf ï¼Windowsçã®ã¿ï¼
- /etc/ctags.conf
- /usr/local/etc/ctags.conf
- ~/.ctags
- ~/ctags.cnf ï¼Windowsçã®ã¿ï¼
- ./.ctags
- ./ctags.cnf ï¼Windowsçã®ã¿ï¼
- $CTAGS
Windowsã«ããã ~/ ã¯ãç°å¢å¤æ°HOMEããå¤æãã¾ãã
ã¡ãªã¿ã«ã¨ã°ãºã¼ãã©ã³ãã£ã¦ååã®ç±æ¥ã¯ãã¨ã°ãºã¼ãã©ã³ãCtagsã®FAQã«ããã¨ï¼
exuberantã¨ããåèªã®æå³ã®1ã¤ãã究極ã«è±å¯ã«é ããããã§ãExuberant Ctagsã§çæããtagãã¡ã¤ã«ã¨ä»ã®ctagsã§çæãããã®ã¨ãè¦æ¯ã¹ã¦ã¿ãã°ããã®ååãããã«ãµãããããããããã¯ãã§ãã
âã¨ã°ãºã¼ãã©ã³ãCtagsã調ã¹ã¦ã¿ã
次ã®ãããªJavaScriptã®ãµã³ãã«ãä½ã£ã¦ã¿ã¾ããã
/* sample.js */var g = 1;
function f1() {
return 0;
}var f2 = function() {
return 0;
};var foo = {};
foo.f3 = function() {
return 0;
};var bar = {
C: 10, // constant
f4: function() {
return 0;
},
hello: "Hello"
};function Baz(n) {
this.n = n;
}
Baz.prototype.f5 = function() {
return this.n;
};
次ã®ã³ãã³ãã§TAGSãã¡ã¤ã«ãä½ãã¾ãã
ctags -e sample.js
ã§ããTAGSãã¡ã¤ã«ããå¤æããã«ã次ã®å¤æ°ï¼é¢æ°ã¯èªèã§ãã¦ããããã§ãã
var g
function f1()
var f2 = function()
foo.f3 = function()
function Baz(n)
Baz.prototype.f5 = function()
æ®å¿µãªãããbar.f4() ãèªèããã¦ãªãã以åã®secondlifeããã®è¨äºãåèã«ã次ã®å 容ãæ¸ãã ~/.ctagsï¼Windowsãªã ~/ctags.cnf ã§ãããï¼ãä½ãã¾ãã
--regex-javascript=/^[ \t]*(['"]?)([A-Za-z0-9_.]+)\1[ \t]*[:=][ \t]*function[ \t]*\(/\2/I,inner/i
確ãã«ããã§ãfuncName: funcion(...){...}
ã¹ã¿ã¤ã«ã®é¢æ°ãèªèããããã§ãã
âEmacsã§JavaScriptã½ã¼ã¹ãèªã
TAGSãã¡ã¤ã«ãçæããã«ã¯ãã½ã¼ã¹ãã¡ã¤ã«ã®ããããã£ã¬ã¯ããªã§æ¬¡ã³ãã³ããå®è¡ããã®ãããããã§ãã
ctags --verbose -e --recurse --languages=javascript > ctags.log
--recurseãªãã·ã§ã³ã¯ããã£ã¬ã¯ããªãå帰çã«ãã©ã£ã¦ãã¡ã¤ã«ãæ¢ãã¾ããä½è¨ãªãã¡ã¤ã«ã¯èªã¾ãªãããã«--languages=javascriptãªãã·ã§ã³ãä»ãã¾ããã念ã®ããã--verboseãªãã·ã§ã³ãå é ã«ä»ããã¡ãã»ã¼ã¸åºåããã¡ã¤ã«ã«åãã¾ããctags.logã«å¦çã®çµéãè¨é²ããã¾ããï¼ctagsã®æåã«æ £ãã¦ãã¾ãã°ã--verboseãåºåã®ãªãã¤ã¬ã¯ãã¯ä¸è¦ã§ããï¼
ç®çã®JavaScriptãã¡ã¤ã«ãEmacsã«ãã¼ãããé¢æ°å®ç¾©ãªã©ãåç §ãããã¨ãã«æ¬¡ã®ãã¼ã³ã³ããã¼ã·ã§ã³ï¼ã³ãã³ãï¼ã使ãã¾ãã
- M-. (find-tag) ï¼ ã¿ã°ï¼ååï¼ã®å®ç¾©ç®æãæ¢ãï¼ã¿ã°ã¸ã£ã³ãï¼ã
- M-* (pop-tag-mark) ï¼ åã«M-.ãå®è¡ããå ´æã«æ»ãã
- C-u M-. ï¼ æ¬¡ã®å®ç¾©ç®æãæ¢ãã
- C-u - M-. ï¼ åã«è¦ã¤ãã£ãå®ç¾©ç®æã«æ»ãã
- C-x 4 . (find-tag-other-window) ï¼ã¿ã°ï¼ååï¼ã®å®ç¾©ç®æãæ¢ãå¥ã¦ã£ã³ãã¦ã«è¡¨ç¤ºããã
- C-x 5 . (find-tag-other-frame) ï¼ã¿ã°ï¼ååï¼ã®å®ç¾©ç®æãæ¢ãå¥ãã¬ã¼ã ã«è¡¨ç¤ºããã
C-u ã¯ã³ãã³ãfind-tagã«å¼æ°0ãä¸ããC-u - ã¯find-tagã«å¼æ°-1ãä¸ããããªãã£ãã¯ã¹ã»ãã¼ã§ãããã¡ãã£ã¨ãã¼ãæ¼ãã«ããã®ãé£ç¹ã§ãï¼ã©ããã¦ãã¤ã¤ãªããå½è©²ã³ãã³ããã©ãããã¦å¥ãªãã¼ã«ãã¤ã³ããç´ãã¾ãããï¼ã
Emacsã®ã¿ã°é¢é£æä½ã«é¢ãã¦ã¯åè¿°ã®ãã¿ã°ã¸ã£ã³ãã§é¢æ°ã®å®ç¾©ã«ã¸ã£ã³ããããã詳ããã¯ããªã³ã©ã¤ã³ãGNU Emacsããã¥ã¢ã«ãã®ã20.13 ã¿ã°ãã¼ãã«ããåç §ãã¦ãã ããã