-
Notifications
You must be signed in to change notification settings - Fork 3
/
anything-myrurema.el
78 lines (60 loc) · 2.73 KB
/
anything-myrurema.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;;; anything-myrurema.el --- Anything Interface for myrurema
;; Copyright (C) 2012 mori-dev
;; Author: mori-dev <[email protected]>
;; 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/>.
;;; Installation:
;; install requires libraries:
;; `myrurema' https://rubygems.org/gems/myrurema
;; `anything.el' http://www.emacswiki.org/emacs/anything.el
;; `anything-config.el' http://www.emacswiki.org/emacs/anything-config.el
;; `anything-match-plugin.el' http://www.emacswiki.org/emacs/anything-match-plugin.el
;; `anything-myrurema.el' http://github.com/mori-dev/anything-myrurema (this file)
;;; Usage
;;
;; (require 'anything-myrurema)
;;
;; M-x anything-myrurema
;;; Code:
(require 'cl)
(require 'anything)
(require 'anything-config)
(defvar anything-myrurema-index-path "~/.emacs.d/myrurema.index")
(defvar anything-c-source-myrurema
`((name . "myrurema")
(candidates-file . ,anything-myrurema-index-path)
(candidate-number-limit . 100000)
(action . (("emacs でるりまを見る" . (lambda (c) (anything-myrurema-show-rurema c)))
("ブラウザでるりまサーチ" . (lambda (c) (anything-myrurema-rurema-search c)))))))
(defun anything-myrurema-get-docstring (s)
(cond
((executable-find "rurema")
(shell-command-to-string (format "rurema --no-ask %s" (shell-quote-argument s))))
(t
"can't find \"rurema\" command")))
(defun anything-myrurema-show-rurema (candidate)
(let ((docstring (anything-myrurema-get-docstring candidate))
(buf (get-buffer-create "*rurema-result*")))
(with-current-buffer buf
(erase-buffer)
(insert docstring)
(goto-char (point-min))
(delete-region (point) (save-excursion (end-of-line) (point)))
(delete-blank-lines))
(switch-to-buffer buf)))
(defun anything-myrurema-rurema-search (candidate)
(browse-url (format "http://rurema.clear-code.com/query:%s/" (url-hexify-string candidate))))
(defun anything-myrurema ()
"anything myrurema"
(interactive)
(anything-other-buffer 'anything-c-source-myrurema "*anything myrurema*"))
(provide 'anything-myrurema)