syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.7k stars 4.9k forks source link

Can't move around ansi-term as if it's a typical buffer. #10956

Closed giuscri closed 4 years ago

giuscri commented 6 years ago

Description :octocat:

Can't move around ansi-term as if it's a typical buffer.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: After pressing ESC, being in Normal again, pressing k doesn't allow me to go up one line in the buffer.

Expected behaviour: :heart: :smile: After pressing ESC, being in Normal again, pressing hjkl should allow me to move around in the buffer.

System Info :computer:

Miciah commented 6 years ago

10844 might fix this.

OkIdeal0 commented 6 years ago

The fix in #10844 should work now. I actually found it more convenient to set the buffer to read-only while in normal state, since the editing commands in normal state don't do anything useful. My config now looks like this:

(defun config//term-normal-state ()
  "Enable `term-line-mode' when in normal state in `term-mode' buffer
 and make the buffer read only."
  (term-line-mode)
  (read-only-mode 1))

(defun config//term-insert-state ()
  "Enable `term-char-mode' when in insert state in a `term-mode' buffer."
  (when (get-buffer-process (current-buffer))
    (read-only-mode -1)
    (term-char-mode)
    ))

(defun config//term-evil-bindings ()
  "Enable term support for vim and hybrid editing styles."
  (add-hook 'evil-hybrid-state-entry-hook 'config//term-insert-state nil t)
  (add-hook 'evil-insert-state-entry-hook 'config//term-insert-state nil t)
  (add-hook 'evil-hybrid-state-exit-hook 'config//term-normal-state nil t)
  (add-hook 'evil-insert-state-exit-hook 'config//term-normal-state nil t))

(setq term-char-mode-point-at-process-mark t)
(add-hook 'term-mode-hook 'config//term-evil-bindings)

This is still far from perfect. Ideally, the bindings in normal state should work as in shell-mode or other comint modes, where you can edit the input line while leaving the prompt intact. But this is not so easy since term-mode does not derive from comint-mode.

giuscri commented 6 years ago

ping

maxstreese commented 5 years ago

Any updates on this? :(

lukeorland commented 5 years ago

This fixed the problem for me: https://github.com/syl20bnr/spacemacs/issues/10779#issuecomment-427712967

summary: An Emacs 26.1 change causes this behavior, which can be fixed via a user-config setting.

duianto commented 5 years ago

The following PR is now on the develop branch: shell: allow evil normal-mode movement in terminal buffer #12591

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!