Subject: 26.1; error in `term-down' after window configuration change

From: Phil Sainty <[email-masked]>
Date: Wed, 18 Apr 2018 01:00:14 +1200

In a `term' buffer, seemingly after any window configuration change, the
process filter triggers an error due to `term-current-row' being nil
unexpectedly.

Recipe:

emacs -Q
M-x toggle-debug-on-error
M-x term
RET
RET #repeatedly -- all is fine at this point...
C-c 2
RET

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p 
nil)
   term-down(1 t)
   term-emulate-terminal(#<process terminal> "\015\033[K$ 
\015\n\032//home/phil\015\n")

That window config change could be C-c 2 or C-c 3 or, if already split, 
C-c 1;
it doesn't seem to matter.

With an uncompiled `term-down':

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p 
nil)
   =(nil 0)
   (and (= term-current-row 0) (< down 0))
   (if (and (= term-current-row 0) (< down 0)) ...)
   (let ((start-column (term-horizontal-column))) ...)
   term-down(1 t)
   term-emulate-terminal(#<process terminal> "\015\033[K$ 
\015\n\032//home/phil\015\n")

That test of (= term-current-row 0) occurs twice in the function.

Trivially, testing (bound-and-true-p term-current-row) beforehand in
both pieces of code circumvents the error and appears in practice to
resolve the issue, but I don't know whether that's the *right* fix.

-Phil

In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll 
bars)
  of 2018-04-15 built on shodan
Windowing system distributor 'The X.Org Foundation', version 
11.0.11804000
System Description:	Ubuntu 16.04.4 LTS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Debug on Error enabled globally
Entering debugger...
term-emulate-terminal: Wrong type argument: number-or-marker-p, nil

Configured using:
  'configure --prefix=/home/phil/emacs/26.1rc1/usr/local
  --with-x-toolkit=lucid --without-sound'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK DBUS GSETTINGS NOTIFY
GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 THREADS
LCMS2

Important settings:
   value of $LANG: en_NZ.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Debugger

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   buffer-read-only: t
   line-number-mode: t
   transient-mark-mode: (only . t)

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode
cl-print byte-opt gv bytecomp byte-compile cl-loaddefs cl-lib cconv
debug term disp-table easymenu ehelp ring cus-start cus-load elec-pair
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 108699 9507)
  (symbols 48 22248 1)
  (miscs 40 76 129)
  (strings 32 32773 1265)
  (string-bytes 1 829787)
  (vectors 16 14995)
  (vector-slots 8 503659 11454)
  (floats 8 61 115)
  (intervals 56 287 0)
  (buffers 992 13)
  (heap 1024 42349 1368))