bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39805: 28.0.50; scan-sexps (scan_lists) incorrectly parsing circular


From: Noam Postavsky
Subject: bug#39805: 28.0.50; scan-sexps (scan_lists) incorrectly parsing circular list
Date: Thu, 27 Feb 2020 21:34:07 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

retitle 39805 describe-variable fails to print some circular list values
# describe-variable only fails starting from 26.1
notfound 39805 25.3
found 39805 26.1
tags 39805 + patch
quit

For the record, the pp-buffer call in the original report fails in Emacs
25 (and earlier, I assume), but the describe-variable case only fails
starting from 26.1, specifically commit 2c18969c81.

[1: 2c18969c81]: 2017-03-02 02:08:32 -0500
  * lisp/help-fns.el (describe-variable): Use cl-print for the value
  
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=2c18969c810f338d73beda592ee5af7103132e97

Here is the patch intended for emacs-27:

>From 3b0b1b17c59341b12a502c0ea87c6125cc445494 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Thu, 27 Feb 2020 21:09:59 -0500
Subject: [PATCH] Fix describe-variable on values with circular syntax
 (Bug#39805)

* lisp/help-fns.el (describe-variable): Set syntax tables before
calling pp-buffer.
---
 lisp/help-fns.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 0e2ae6b3c3..1be8e0ab08 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1000,6 +1000,8 @@ describe-variable
                    (terpri)
                     (let ((buf (current-buffer)))
                       (with-temp-buffer
+                        (lisp-mode-variables nil)
+                        (set-syntax-table emacs-lisp-mode-syntax-table)
                         (insert print-rep)
                         (pp-buffer)
                         (let ((pp-buffer (current-buffer)))
-- 
2.11.0

No Wayman <iarchivedmywholelife@gmail.com> writes:

> In the meantime, I'd like to be able to offer the users of my package
> a solution if they hit this bug.  This seems to work for me, but I
> haven't written much, and am a bit leery of, elisp advice.  Would you
> consider this an appropriate workaround?:

Mostly yes, but IMO it's kind of over-engineered.  I would do just:

    (defun workaround/describe-variable-print-bug (original-function &rest args)
      "Put temp buffer in emacs-lisp-mode before `pp-buffer'.
    https://debbugs.gnu.org/39805#8";
      (advice-add #'pp-buffer :before #'emacs-lisp-mode)
      (unwind-protect
          (apply original-function args)
        (advice-remove #'pp-buffer #'emacs-lisp-mode)))

    (when (= emacs-major-version 26) ;; Work around Bug#39805.
      (advice-add #'describe-variable :around
                  #'workaround/describe-variable-print-bug))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]