lorniu / go-translate

Translator on Emacs. Supports multiple engines such as Google, Bing, deepL, ChatGPT, StarDict, Youdao and so on.
GNU General Public License v3.0
283 stars 38 forks source link

The key q do not work In *Go Translate* buffer #6

Closed sincebyte closed 4 years ago

sincebyte commented 4 years ago

In Go Translate buffer the key q do not work! Other key neighter

lorniu commented 4 years ago

In the Go-Translate buffer, type C-h k q to see what command q bound to.

It is possible that some of your settings override the local-map in the buffer.

sincebyte commented 4 years ago

C-h k q the result is blew: evil-record-macro is an interactive and compiled function defined in evil-commands.el. Signature (evil-record-macro REGISTER)

Note: On macbook key q is ok,but on ubuntu the key q do not work

lorniu commented 4 years ago

It seems that evil overwrites the local-map. I don't used evil, but you can choose to disable it in the Go-translate buffer.

For example:

(add-hook 'go-translate-after-render-hook
          (defun your-hook-that-disable-evil-mode-in-go-translate-buffer (&rest _)
            (turn-off-evil-mode -1)))
sincebyte commented 4 years ago

Is there a configuration compatible with evil?

lorniu commented 4 years ago

Not yet. The keybinds in Go-Translate may conflict with Evil, you'd better customize the keys yourself according to the needs.

sincebyte commented 4 years ago

got it.

vsuharnikov commented 2 years ago

It seems go-translate-after-render-hook was changed in v2 to gts-after-buffer-render-hook / gts-after-buffer-multiple-render-hook.

If there is a newbie like me who is looking for an up-to-date example of configuration for doom-emacs, here is:

;; go-translate: https://github.com/lorniu/go-translate
(after! go-translate
  (setq gts-translate-list '(("en" "ru")))
  (setq gts-default-translator
        (gts-translator
         :picker (gts-prompt-picker)
         :engines (list (gts-google-engine))
         :render (gts-buffer-render)))
  ;; disable the evil mode to allow plugin keybindings: https://github.com/lorniu/go-translate/issues/6#issuecomment-700038291
  (add-hook 'gts-after-buffer-render-hook ;; use 'gts-after-buffer-multiple-render-hook instead if you have multiple engines
            (defun your-hook-that-disable-evil-mode-in-go-translate-buffer (&rest _)
              (turn-off-evil-mode -1)))
  (map! :leader :desc "Translate" :n "b T" #'gts-do-translate)
  )
sincebyte commented 1 year ago

with doom this config is better

(map! :after go-translate
      :map evil-normal-state-map
      "q" nil)

(after! go-translate
 (setq gts-translate-list '(("en" "zh")))
 (setq gts-default-translator
 (gts-translator
 :picker  (gts-prompt-picker)
 :engines (list (gts-google-engine))
 :render  (gts-buffer-render)))
 :map gts-buffer-local-map "q" #'+popup/quit-window)