- 2009-03-05 (Thu) 1:39
- emacs
dired
dired stands for DIRectory EDit. (Not sure how it’s pronounced.) It is very useful bundled application. When you do C-x C-f then just hit enter. You’ll see something like ls but with cursor on it. You can do a lot of stuff by this, but mainly, you’ll do open files, just choosing file with cursor, and hit enter. You can also delete by press d for marking. And then press x to execute it. I’m sure there’s a lot more to do, but that’s what I do so far.
If you’re a Mac person, and If you using Display ANSI colors on Terminal.app, and if you use black background theme, such as Pro, you hardly see color of Blue. You can try TerminalColoreopard. Yoshimasa Niwa made a SIBML extension for choosing ANSI color. This ANSI color setting can be only for for one user. Cannot be like theming, but I don’t change theme everyday, so that works fine for me.
js2-mode
In emacs, there are Major mode and Minor mode. Major mode work like a Perspective in Eclipse IDE. It gives certain kind of framework to work on a given issue. There are ecmascript-mode.el, javascript.el and js2.el. I use js2.el for now.
In order to make js2.el work, emacs needs to know which directory autoload search for. It’s like a path setting in your shell. How do you know which directories your emacs search for? Type C-h v load-path. It will return your emacs’ search path. I found a nice article about load-path on emacs wiki. I wanna load everything in ~/.emacs.d is represented as follows.
(progn (cd "~") (normal-top-level-add-to-load-path '(".emacs.d")))
And download js2.el, put it into my ~/.emacs.d/. Open js2.el, then do M-x byte-compile-file. You’ll get js2.elc, which is pre-compiled version. Then add following lines in .emacs.el
;; js2-mode
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
now whenever you open *.js, you’ll use Js2 Major mode.
ctags
Tag is not like delicious tag. It’s more like search index.
I use exuberant ctags. Just compile and install (./configure ;; make;; sudo make install). And disable original ctags (sudo chmod a-x /usr/bin/ctags).
Outside of emacs, go to top directory of your source file. Try ctags -e --recurse --languages=javascript. Then you’ll get TAGS file in the same directory.
You can do
M-x visit-tags-table and choose TAGS file first. But if you don’t choose TAGS file and try to do tag jump by M-., you’ll be asked which file emacs should read anyway.
- Newer: Emacs Again (4): Learning GNU Emacs Chap 1
- Older: JavaScript: The Good Parts Talk available on Google Tech Talks
Comments:0
Trackbacks:1
- Trackback URL for this entry
- http://blog.nydd.org/2009/03/emacs-again-3-dired-js2-mode-and-ctags/trackback/
- Listed below are links to weblogs that reference
- Emacs Again (3): dired, js2-mode and ctags from Vantage Point of Queens
- pingback from Interesting Emacs Links - 2009 Week 11 « A Curious Programmer 09-03-15 (Sun) 12:50
-
[...] beatak has a couple of useful beginner tips on his blog. I’ve added his code for versioned auto-save to my own start-up and he also has some notes an generating a tagfile generating a tagfile. [...]