FFAP and Ruby in Emacs

If you want to use FFAP (find-file-at-point) in ruby-mode you can add this to your .emacs

(defvar ruby-program-name "ruby")
(defun ruby-module-path(module)
    (shell-command-to-string
     (concat
      ruby-program-name " -e "
      "\"ret='()';$LOAD_PATH.each{|p| "
      "x=p+'/'+ARGV[0].gsub('.rb', '')+'.rb';"
      "ret=File.expand_path(x)"
      "if(File.exist?(x))};printf ret\" "
      module)))
 
(eval-after-load "ffap"
  '(push '(ruby-mode . ruby-module-path) ffap-alist))

When you do ffap (i bind it to C-x f) near a require ‘PP’ for example it will find it in your ruby path.

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Comments »

 
  • Phil says:

    That looks great; thanks!

  • Hubs of FFAP and Ruby in Emacs…

    hubs about Emacs to If you want to use FFAP (find-file-at-point) in ruby-mode you can add this to your .emacs. (defvar ruby-program-name “ruby”) (defun ruby-module-path(module) (shell-command-to-string (concat ruby-program-name ” -e ” “\”ret=’…

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>