カーソルのあたりのモジュールのソースコードを開く
ffapが便利そげなので使ってみた。
ソースコード中に
use Data::Dumper; use FindBin;
とかあるときに、「Dumper」や「FindBin」のあたりにカーソルをもっていってC-xC-fするとそのモジュールのファイルが開ける。
こんな感じ。似たようなffap-*-pathが何個もあってださいけどそっと目をつむる。
;;; ffap ===================================================================
(ffap-bindings)
;; perl
(add-to-list 'ffap-alist '(cperl-mode . my-cperl-ffap-locate))
(setq ffap-perl-inc-dirs
(apply 'append
(mapcar (function ffap-all-subdirs)
(split-string (shell-command-to-string
"perl -e 'pop @INC; print join(q/ /,@INC);'")))))
(defun my-cperl-ffap-locate(name)
"Return cperl module for ffap"
(let* ((r (replace-regexp-in-string ":" "/" (file-name-sans-extension name)))
(e (replace-regexp-in-string "//" "/" r))
(x (ffap-locate-file e '(".pm" ".pl" ".xs") ffap-perl-inc-dirs)))
x))
;; ruby
(if (executable-find "ruby")
(progn
(add-to-list 'ffap-alist '(ruby-mode . my-ruby-ffap-locate))
(setq ffap-ruby-path
(apply 'append
'(".")
(mapcar (function ffap-all-subdirs)
(split-string (shell-command-to-string
"ruby -e 'print ($LOAD_PATH-[\".\"]).join(\" \");'")))))
(defun my-ruby-ffap-locate (name)
(if (string-match "\\.rb\\'" name)
(ffap-locate-file name t ffap-ruby-path)
(ffap-locate-file name '(".rb") ffap-ruby-path)))
))
;; php
(if (executable-find "php")
(progn
(add-to-list 'ffap-alist '(php-mode . my-php-ffap-locate))
(setq ffap-php-inc-dirs
(apply 'append
'(".")
(mapcar (function ffap-all-subdirs)
(split-string (shell-command-to-string
"php -r 'echo str_replace(\".:\", \"\", get_include_path());'") ":"))))
(defun my-php-ffap-locate (name)
(if (string-match "\\.php\\'" name)
(ffap-locate-file name t ffap-php-inc-dirs)
(ffap-locate-file name '(".php") ffap-php-inc_dirs)))
))