-
Notifications
You must be signed in to change notification settings - Fork 4
/
paw-goldendict.el
32 lines (27 loc) · 1.22 KB
/
paw-goldendict.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
;;; paw-goldendict.el -*- lexical-binding: t; -*-
(defcustom paw-goldendict-program "goldendict"
"Executable used to access the goldendict."
:type 'file)
;;;###autoload
(defun paw-goldendict-search-details (&optional word en)
"Search word with goldendict."
(interactive)
(let ((word (or word
(pcase major-mode
('pdf-view-mode
(car (pdf-view-active-region-text)))
('eaf-mode
(eaf-execute-app-cmd 'eaf-py-proxy-copy_text)
(sleep-for 0.01) ;; TODO small delay to wait for the clipboard
(eaf-call-sync "execute_function" eaf--buffer-id "get_clipboard_text"))
(_ (if (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(thing-at-point 'word t)))) )))
;; (message word)
(start-process "goldendict" "*goldendict*" "goldendict" word)))
(defun paw-goldendict-process-filter (proc string)
"Accumulates the strings received from the goldendict process."
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
(insert string))))
(provide 'paw-goldendict)