-
-
Save authorNari/2875bd46c958ac4c74b2 to your computer and use it in GitHub Desktop.
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
;;; myrurema.el --- myrurema for emacs | |
;; Copyright (C) 2010 Narihiro Nakamura | |
;; Author: Narihiro Nakamura <narihiro atmark gmail.com> | |
;; Version: 0.2 | |
;; Keywords: ruby | |
;; This program is free software; you can redistribute it and/or modify | |
;; it under the terms of the GNU General Public License as published by | |
;; the Free Software Foundation, either version 3 of the License, or | |
;; (at your option) any later version. | |
;; This program is distributed in the hope that it will be useful, | |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
;; GNU General Public License for more details. | |
;; You should have received a copy of the GNU General Public License | |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
;;; How use: | |
;; (1) myruremaをインストールしましょう。 | |
;; http://github.com/yhara/myrurema/blame/master/README.mkd | |
;; | |
;; (2) .emacs に以下を記述。 | |
;; | |
;; (require 'myrurema) | |
;; | |
;; (3) 以下のコマンドでruremaをemacsから引けます。 | |
;; M-x rurema | |
;; M-x rurema:at-point - カーソル位置の適当な文字列をもとにruremaを引く | |
;; | |
;; (4) 便利なkeyに割り当ててください。 | |
;; | |
;; (defun ruby-mode-hooks-myrurema () | |
;; (define-key ruby-mode-map (kbd "<C-f1>") 'rurema) | |
;; (define-key ruby-mode-map [f1] 'rurema:at-point) | |
;; ) | |
;; (add-hook 'ruby-mode-hook 'ruby-mode-hooks-myrurema) | |
(defvar rurema:command "rurema" | |
"rurema command" | |
) | |
(defun rurema:at-point (&optional item) | |
(interactive) | |
(setq item (if item item (thing-at-point 'sexp))) | |
(rurema:search item) | |
) | |
(defun rurema (&optional item) | |
(interactive) | |
(setq item (read-string "Search symbol: " item)) | |
(rurema:search item) | |
) | |
(defun rurema:search (&optional item) | |
(if item | |
(let ((buf (buffer-name))) | |
(unless (string= buf "*rurema*") | |
(switch-to-buffer-other-window "*rurema*")) | |
(setq buffer-read-only nil) | |
(kill-region (point-min) (point-max)) | |
(message (concat "Please wait...")) | |
(call-process rurema:command nil "*rurema*" t item) | |
(local-set-key [return] 'rurema:search-at-buffer) | |
(ansi-color-apply-on-region (point-min) (point-max)) | |
(setq buffer-read-only t) | |
(goto-char (point-min))))) | |
(defun rurema:search-at-buffer (&optional item) | |
(interactive) | |
(setq item (thing-at-point 'url)) | |
(if (string-match "http://" item) | |
(setq item (replace-match "" nil nil item))) | |
(rurema item) | |
) | |
(provide 'myrurema) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment