all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: 36187@debbugs.gnu.org
Subject: bug#36187: 27.0.50; M-x timer-list fails for functions with multi-line string representations
Date: Thu, 13 Jun 2019 07:17:17 +0000	[thread overview]
Message-ID: <CAOqdjBc=pb4vXT_h06FCN-3=SGVUKNabyU5MfEB8bmSEmctwJQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

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))

[-- Attachment #2: 0001-Escape-newlines-when-printing-functions-in-timer-lis.patch --]
[-- Type: text/x-patch, Size: 1133 bytes --]

From 696bc181b55df2bac106a97fb5ec8cf902f80bcd Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
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


             reply	other threads:[~2019-06-13  7:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13  7:17 Pip Cet [this message]
2019-06-13 12:11 ` bug#36187: 27.0.50; M-x timer-list fails for functions with multi-line string representations Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOqdjBc=pb4vXT_h06FCN-3=SGVUKNabyU5MfEB8bmSEmctwJQ@mail.gmail.com' \
    --to=pipcet@gmail.com \
    --cc=36187@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.