hylang / hy-mode

Hy mode for Emacs
GNU General Public License v3.0
191 stars 47 forks source link

(hy-shell-eval-current-form) takes me to the *Hy* buffer #87

Open lispercat opened 4 years ago

lispercat commented 4 years ago

Maybe it's a feature, but every time I press C-M-x it takes me to the Hy buffer so I have to need to go back to my source file. Not sure if it's the intended behavior, just feels rather odd. Is there a way to configure to stay in the source unless I explicitly want to go to Hy?

ekaschalk commented 4 years ago

You could always wrap it in a save-excursion or save-window-excursion.

lispercat commented 4 years ago

Thanks, Eric save-window-excursion does the trick

On Tue, Dec 24, 2019 at 3:23 PM Eric Kaschalk notifications@github.com wrote:

You could always wrap it in a save-excursion or save-window-excursion.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hylang/hy-mode/issues/87?email_source=notifications&email_token=AACCZB4HLBVEZXS4VP47HHTQ2JVS5A5CNFSM4J6U2Y22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTS5XY#issuecomment-568798943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACCZBY4DLYJFLFOAMG5UGDQ2JVS5ANCNFSM4J6U2Y2Q .

TatriX commented 4 years ago

It would be amazing to have a defcustom to tweak this behavior.

noobymcnoob commented 4 years ago

Behavior similar to eval-last-sexp as default would be awesome.

TatriX commented 4 years ago

Behavior similar to eval-last-sexp as default would be awesome.

You can try something like this:

(use-package hy-mode
  :bind (:map hy-mode-map ("C-c C-c" . my-hy-eval-last-sexp))
  :config
  ;; Don't echo python code back
  (setq hy-shell--interpreter-args '("--repl-output-fn" "hy.contrib.hy-repr.hy-repr"))

  (defun my-hy-eval-last-sexp ()
    (interactive)
    (save-window-excursion
      (hy-shell--send (hy--last-sexp-string)))))