Skip to content

Instantly share code, notes, and snippets.

@hadashiA
Created May 3, 2012 07:50
Show Gist options
  • Save hadashiA/2584114 to your computer and use it in GitHub Desktop.
Save hadashiA/2584114 to your computer and use it in GitHub Desktop.
anythingから、ローカルにあるrubygemsのソースを開く ref: http://qiita.com/items/7a832e99d18cc8e507fd
(defvar anything-c-sources-local-gem-file
'((name . "gems (local)")
(candidates-in-buffer)
(init . (lambda ()
(unless (anything-candidate-buffer)
(call-process-shell-command
"gem list" nil (anything-candidate-buffer 'global)
))))
(action . (lambda (gem-name)
(setq gem-name (replace-regexp-in-string "\s+(.+)$" "" gem-name))
(with-temp-buffer
(call-process "gem" nil t nil "which" gem-name)
(let ((path (buffer-substring-no-properties (point-min)
(- (point-max) 1))))
(if (file-exists-p path)
(find-file path)
(message "no such file or directory:\"%s\"" path))))
))))
(defun anything-local-gems ()
(interactive)
(anything-other-buffer
'(anything-c-sources-local-gem-file)
"*anything local gems*"
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment