-
-
Save tmaeda/1047385 to your computer and use it in GitHub Desktop.
View Source for Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Toss this in your ~/.irbrc file for a convenient way | |
# to peruse Ruby source code in Emacs.app. This | |
# only works in Ruby 1.9! | |
# | |
# Use it in irb like so: | |
# | |
# >> require 'active_record' | |
# >> ActiveRecord::Base.source_for_method(:create) | |
class Object | |
def source_for_method(method) | |
location = self.method(method).source_location | |
`/Applications/Emacs.app/Contents/MacOS/bin/emacsclient +#{location[1]} #{location[0]}` if location | |
location | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment