-
Notifications
You must be signed in to change notification settings - Fork 1
/
bartuer-buddy.el
executable file
·55 lines (49 loc) · 1.86 KB
/
bartuer-buddy.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
(defun buddy-get (word)
"show definition of word from buddy system"
(let* ((buf (current-buffer))
(defination (concat "buddy-" word))
(process (apply 'start-process-shell-command
defination
(get-buffer-create defination)
"word-define"
(list word)))
)
(setq buddy-jump-back-buf buf)
(set-process-sentinel process (lambda (proc state)
(cond ((equal state "finished
")
(let ((defination-buf (process-buffer proc)))
(with-current-buffer defination-buf
(goto-char (point-min))
(pop-to-buffer defination-buf)
(pop-to-buffer buddy-jump-back-buf)
)
)
)
)
))
defination
))
(defun explain-current-in-brower ()
(interactive)
(let ((w (thing-at-point 'word))
)
(buddy-get w)
)
)
(defalias 'bd 'explain-current-in-brower)
(defcustom buddy-minor-mode-string " bd"
"String to display in mode line when buddy mode is enabled; nil for none."
:type '(choice string (const :tag "None" nil))
)
(define-minor-mode buddy-minor-mode
"Minor mode query word under cursor from buddy"
:lighter buddy-minor-mode-string
(cond
(buddy-minor-mode
(add-hook 'post-command-hook 'explain-current-in-brower nil t)
)
(t
(remove-hook 'post-command-hook 'explain-current-in-brower t)
)))
(provide 'bartuer-buddy)