Subject: 27.0.50; M-x timer-list fails for functions with multi-line string representations

From: Pip Cet <[email-masked]>
Date: Thu, 13 Jun 2019 07:17:17 +0000

The timer list fails to deal with functions that cl-prin1-to-string
represents in multiple lines, such as those containing newlines in
strings. (This happens for process sentinels, as well as for closures
with the right bound variables).

Evaluate in *scratch*:

(run-with-timer 0 1 (lambda () (message "tick\ntock")))

Then run M-x timer-list and attempt to cancel the new timer; doing so on
the first line of the representation fails, on the second line of the
representation the cancellation succeeds but leaves the timer list in a
broken state.

The attached one-liner patch fixes things.

* timer-list.el (list-timers): bind `print-escape-newlines' to avoid
  newlines in printed representation.
---
 lisp/emacs-lisp/timer-list.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el
index 55aa56b72e..adfc225022 100644
--- a/lisp/emacs-lisp/timer-list.el
+++ b/lisp/emacs-lisp/timer-list.el
@@ -59,7 +59,8 @@ list-timers
                           (format "%s" repeat))))
                       ;; Function.
                       (let ((cl-print-compiled 'static)
-                            (cl-print-compiled-button nil))
+                            (cl-print-compiled-button nil)
+                            (print-escape-newlines t))
                         (cl-prin1-to-string (aref timer 5)))))
       (put-text-property (line-beginning-position)
                          (1+ (line-beginning-position))
From 696bc181b55df2bac106a97fb5ec8cf902f80bcd Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Date: Thu, 13 Jun 2019 07:13:08 +0000
Subject: [PATCH] Escape newlines when printing functions in timer list.

* timer-list.el (list-timers): bind `print-escape-newlines' to avoid
  newlines in printed representation.
---
 lisp/emacs-lisp/timer-list.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el
index 55aa56b72e..adfc225022 100644
--- a/lisp/emacs-lisp/timer-list.el
+++ b/lisp/emacs-lisp/timer-list.el
@@ -59,7 +59,8 @@ list-timers
                           (format "%s" repeat))))
                       ;; Function.
                       (let ((cl-print-compiled 'static)
-                            (cl-print-compiled-button nil))
+                            (cl-print-compiled-button nil)
+                            (print-escape-newlines t))
                         (cl-prin1-to-string (aref timer 5)))))
       (put-text-property (line-beginning-position)
                          (1+ (line-beginning-position))
-- 
2.20.1