Subject: bug#25506: 26.0.50; Buffer-menu-bury gets (void-variable tabulated-list--near-rows)

From: Tino Calancha <[email-masked]>
Date: Sun, 22 Jan 2017 14:28:20 +0900

Bob Rogers <[email-masked]> writes:

>    This has been happening for a while now in master, but not in the
> 25.1 release.  To reproduce:
>
>    1.  emacs -Q
>
>    2.  "C-x C-b" (which shows the buffer menu with *scratch* and
> *Messages* in a new window), and "C-x o" (which moves the cursor into
> this window in front of *scratch*).
>
>    3.  "b" to invoke Buffer-menu-bury.  The line with the *scratch*
> buffer should move below *Messages*; instead, it is erased and only
> partly redrawn in the new location, and the error message "Symbol s
> value as variable is void: tabulated-list--near-rows" is displayed.
Thank you very much for report this bug!
Such `tabulated-list--near-rows' must be bound before
a call to `tabulated-list-print-col', because the latter use the former
via `tabulated-list--col-local-max-widths'.
>    The patch below restores the expected behavior, but it's a kludge to
> require buff-menu.el to know so much about tabulated-list.el innards.
I agree with you.  The variable `tabulated-list--near-rows' is intended
just for internal use in tabulated-list.el.
I am going to apply the following patch:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From ade0652cc2a7103cd910accda8165ff8ee7c719f Mon Sep 17 00:00:00 2001
From: Tino Calancha <[email-masked]>
Date: Sun, 22 Jan 2017 14:23:45 +0900
Subject: [PATCH] Prevent to use tabulated-list--near-rows unbound

* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry):
Make sure 'tabulated-list--near-rows' is bound before use it (Bug#25506).
---
 lisp/emacs-lisp/tabulated-list.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index eadf79ffd4..b6b49b1bfa 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -412,8 +412,13 @@ tabulated-list-print-entry
 	(inhibit-read-only t))
     (if (> tabulated-list-padding 0)
 	(insert (make-string x ?\s)))
-    (dotimes (n ncols)
-      (setq x (tabulated-list-print-col n (aref cols n) x)))
+    (let ((tabulated-list--near-rows ; Bind it if not bound yet (Bug#25506).
+           (or (bound-and-true-p tabulated-list--near-rows)
+               (list (or (tabulated-list-get-entry (point-at-bol 0))
+                         cols)
+                     cols))))
+      (dotimes (n ncols)
+        (setq x (tabulated-list-print-col n (aref cols n) x))))
     (insert ?\n)
     ;; Ever so slightly faster than calling `put-text-property' twice.
     (add-text-properties
-- 
2.11.0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.6)
 of 2017-01-
Repository revision: ad29e145b16cf2966e3a9df884cbc234f1ae3e51