LoginSignup
2
2

More than 5 years have passed since last update.

Emacsで、node.jsのrequire()にカーソルがあるとき、定義元へ飛ぶ (ffap)

Last updated at Posted at 2012-11-03

node.jsには、require.resolve という、ライブラリのパスを返す関数があるので、
Emacsから使うと便利。

Emacsに標準で入っているffap.el は、カーソル位置の文字からファイルを探して開くためのAPIを提供していて、簡単に設定できる。

(defun ffap-nodejs (name)
  (shell-command-to-string
   (format "node -e 'try { require(\"util\").print(require.resolve(\"%s\")) } catch(e) {}'"
           name)))

(add-to-list 'ffap-alist '(js3-mode . ffap-nodejs))
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2