Created
July 14, 2012 11:43
-
-
Save til/3110785 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# Calls a running emacs server to visit a file, and optionally move | |
# point to a line number when included after a colon, e.g. like the | |
# one from a ruby stacktrace: | |
# | |
# emacs-find-file foo/bar.rb:123 | |
abort "Usage: emacs-find-file <file>" unless ARGV[0] | |
file, line_number = ARGV[0].split(':') | |
find_file = "(find-file \"#{file}\")" | |
lisp = if line_number | |
"(with-current-buffer #{find_file} (goto-char (point-min)) (forward-line (1- #{line_number.to_i})))" | |
else | |
find_file | |
end | |
`emacsclient --no-wait --eval '#{lisp}' > /dev/null` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got a special place in my bash:
alias e='emacs-find-file'