2

Nano is displayed incorrectly in emacs when using term or ansi-term. This is what nano is supposed to look like (run in an ordinary terminal emulator):

enter image description here

This is nano as run from ansi-term:

enter image description here

In the above picture, you can see that the first line of commands is missing.

The same behavior appears in GUI and CLI mode, and running emacs with --no-init does not fix the problem.

Since I know the nano commands, this is only a minor nuisance, but it's pretty annoying. Is there any way I can fix this issue? I don't want to use the other terminal modes in emacs for various reasons.

  • Out of curiosity, why are you using a different editor from within your editor? – Dan Jun 1 '18 at 19:44
  • For writing git messages – Zorgoth Jun 1 '18 at 19:46
  • Just for fun, I tried using Vim inside of term/ansi-term about a year ago and found that it could not properly draw all of the aspects; e.g., a particular plugin that I was interested in (nerdtree). In a nutshell, someone motivated would need to spend time debugging and further improving upon term/ansi-term to achieve the results desired. – lawlist Jun 1 '18 at 21:26
  • 3
    Apologies if you already know this and still prefer to use nano for commit messages, but you can set your git editor to emacsclient. If you do, when you call git commit from an Emacs shell, the message will open instantly in the same emacs session. And there's also magit, for even more integration with Emacs. – Tyler Jun 1 '18 at 21:51
  • It works better for me -- I see both rows of commands, with the exception of the same curious blending of ^G Get Help and ^X Exit (which is displayed on the first row, with the area underneath being blank). – phils Jun 2 '18 at 1:34
5

It's an off by one error in term-handle-ansi-escape, I've posted a patch in Bug#31690.

--- c/lisp/term.el
+++ w/lisp/term.el
@@ -3386,11 +3386,10 @@ term-handle-ansi-escape
    ;; \E[B - cursor down (terminfo: cud)
    ((eq char ?B)
     (let ((tcr (term-current-row)))
-      (unless (= tcr (1- term-scroll-end))
+      (unless (>= tcr term-scroll-end)
    (term-down
-    (if (> (+ tcr term-terminal-parameter) term-scroll-end)
-        (- term-scroll-end 1 tcr)
-      (max 1 term-terminal-parameter)) t))))
+         (min (- term-scroll-end tcr) (max 1 term-terminal-parameter))
+         t))))
    ;; \E[C - cursor right (terminfo: cuf, cuf1)
    ((eq char ?C)
     (term-move-columns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.