From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Seweryn Newsgroups: gmane.emacs.devel Subject: Re: "Apparently circular structure being printed" Date: Tue, 9 Nov 2010 07:49:43 +0000 (UTC) Message-ID: References: <87iq07wfus.fsf@sysu76.podval.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289289321 8406 80.91.229.12 (9 Nov 2010 07:55:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 9 Nov 2010 07:55:21 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 09 08:55:17 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PFj2x-0002VN-NP for ged-emacs-devel@m.gmane.org; Tue, 09 Nov 2010 08:55:16 +0100 Original-Received: from localhost ([127.0.0.1]:53205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFj2w-00062a-RJ for ged-emacs-devel@m.gmane.org; Tue, 09 Nov 2010 02:55:14 -0500 Original-Received: from [140.186.70.92] (port=46921 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFj2r-00062U-NW for emacs-devel@gnu.org; Tue, 09 Nov 2010 02:55:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFj2q-0004Dx-Cm for emacs-devel@gnu.org; Tue, 09 Nov 2010 02:55:09 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:53320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFj2q-0004Dk-0m for emacs-devel@gnu.org; Tue, 09 Nov 2010 02:55:08 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PFj2n-0002Qp-93 for emacs-devel@gnu.org; Tue, 09 Nov 2010 08:55:05 +0100 Original-Received: from 139.191.131.39 ([139.191.131.39]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Nov 2010 08:55:05 +0100 Original-Received: from sewkokot by 139.191.131.39 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Nov 2010 08:55:05 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 87 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 139.191.131.39 (Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:132472 Archived-At: Sam Steingold gnu.org> writes: > > GNU Emacs 24.0.50.4 (x86_64-unknown-linux-gnu, GTK+ Version 2.20.1) > of 2010-11-07 on sysu76 > '--with-x-toolkit=gtk' > > In an nXML buffer: > C-h v rng-compile-table RET > > I get an error in the *Messages* buffer: > > Entering debugger... > debugger-setup-buffer: Apparently circular structure being printed > > no *Backtrace* buffer is created. > my print-circle is t. > I get the same error with predictive package [1]. Here are steps to reproduce it: 1) Open an arbitrary text file.txt 2) M-x predictive-mode (my rpg-dictionary is loaded) 3) predictive-add-to-dict <- "Very longgggggg string" (I want to add the expression in qutes, of course without quotes) 4) predictive-save-dict (OK) 5) predictive-add-to-dict <- "Very veryyyyyy longggggggggggggg stringgggggggg" 6) I get the message in echo area: "Entering debugger... debugger-setup-buffer: Apparently circular structure being printed" 7) No *Backtrace* The Author of predictive package wrote me as follows: "This enabled me to reproduce the issue, and I remember now what it is that causes this. It has nothing to do with special characters (the predictive-mode dictionaries can store arbitrary strings). It's to do with the *length* of the string you're trying to store. Unfortunately, Emacs has an undocumented, hard-coded limit on the depth of a Lisp list structure, beyond which it considers the structure to be circular and refuses to print it, throwing the "Apparently circular structure" error. This limit only applies to printing such structures; Emacs will happily work with deeply nested structures in all other circumstances. But predictive-mode uses the Lisp printing functions to write the dictionaries to file, hence the error when saving. It's not unreasonable to impose a depth limit on printing, as it guards against hanging in a tight loop if you inadvertently ask Emacs to printing a circular list structure. However, it's unfortunate that this limit is hard-coded. Other similar Emacs limits can be changed by modifying a variable in Elisp, but not this one. The vast majority of Elisp code only uses very simple data structures, and the Emacs devs didn't have predictive-mode in mind when they arbitrarily chose the value for this print-depth limit, so it's set rather conservatively. The practical consequence is that standard Emacs will bork on saving dictionaries containing strings longer than about 45 characters. There is a patch included in the predictive package (print.c.diff) [2] which increases this limit by a factor of 5. (If you envisage storing even longer strings, you could increase this even further. The required modification should be obvious from the patch file.) But obviously this requires patching and compiling the Emacs source yourself, which is possible but maybe not so easy under Windows." Regards, Seweryn [1] http://www.emacswiki.org/emacs/PredictiveMode or http://www.dr-qubit.org/emacs.php#predictive [2] --- print.c 2008-10-24 11:18:33.000000000 +0100 +++ print.c.new 2008-10-24 11:19:27.000000000 +0100 @@ -88,7 +88,7 @@ int new_backquote_output; /* Detect most circularities to print finite output. */ -#define PRINT_CIRCLE 200 +#define PRINT_CIRCLE 1000 Lisp_Object being_printed[PRINT_CIRCLE]; /* When printing into a buffer, first we put the text in this