Skip to content

Commit

Permalink
refactor: go-translate
Browse files Browse the repository at this point in the history
  • Loading branch information
seagle0128 committed Aug 17, 2024
1 parent 4e555a4 commit a3cb8a3
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions lisp/init-dict.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
(use-package fanyi
:bind (("C-c d f" . fanyi-dwim)
("C-c d d" . fanyi-dwim2)
("C-c d h" . fanyi-from-history))
:custom (fanyi-providers '(fanyi-haici-provider
fanyi-youdao-thesaurus-provider
fanyi-etymon-provider
fanyi-longman-provider)))
("C-c d h" . fanyi-from-history)))

(when emacs/>=28p
(use-package go-translate
Expand Down Expand Up @@ -71,7 +67,9 @@
`((default . ,(gt-translator
:taker (list (gt-taker :pick nil :if 'selection)
(gt-taker :text 'paragraph :if '(Info-mode help-mode helpful-mode devdocs-mode))
(gt-taker :text 'buffer :pick 'fresh-word :if 'read-only)
(gt-taker :text 'buffer :pick 'fresh-word
:if (lambda (translatror)
(and (not (derived-mode-p 'fanyi-mode)) buffer-read-only)))
(gt-taker :text 'word))
:engines (if (display-graphic-p)
(list (gt-bing-engine :if 'not-word)
Expand All @@ -80,17 +78,18 @@
(gt-youdao-dict-engine :if 'word)
(gt-youdao-suggest-engine :if 'word)
(gt-google-engine :if 'word)))
:render (list (gt-posframe-pop-render :if (lambda (translator)
(and (display-graphic-p)
(not (derived-mode-p 'Info-mode 'help-mode 'helpful-mode 'devdocs-mode))
(not (member (buffer-name) '("COMMIT_EDITMSG")))))
:frame-params (list :accept-focus nil
:width 70
:height 15
:left-fringe 16
:right-fringe 16
:border-width 1
:border-color gt-pin-posframe-bdcolor))
:render (list (gt-posframe-pop-render
:if (lambda (translator)
(and (display-graphic-p)
(not (derived-mode-p 'Info-mode 'help-mode 'helpful-mode 'devdocs-mode))
(not (member (buffer-name) '("COMMIT_EDITMSG")))))
:frame-params (list :accept-focus nil
:width 70
:height 15
:left-fringe 16
:right-fringe 16
:border-width 1
:border-color gt-pin-posframe-bdcolor))
(gt-overlay-render :if 'read-only)
(gt-insert-render :if (lambda (translator) (member (buffer-name) '("COMMIT_EDITMSG"))))
(gt-buffer-render))))
Expand Down

0 comments on commit a3cb8a3

Please sign in to comment.