From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: list-print-separator (was: entry separator for printing hashtables) Date: Thu, 21 Apr 2011 18:17:37 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87vcy7mbxq.fsf@lifelogs.com> References: <8762qr8x23.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1303427885 6424 80.91.229.12 (21 Apr 2011 23:18:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 21 Apr 2011 23:18:05 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 22 01:18:02 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QD38I-00029x-SQ for ged-emacs-devel@m.gmane.org; Fri, 22 Apr 2011 01:17:59 +0200 Original-Received: from localhost ([::1]:44134 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QD38I-0008U3-Ar for ged-emacs-devel@m.gmane.org; Thu, 21 Apr 2011 19:17:58 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:34953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QD38E-0008Tw-SG for emacs-devel@gnu.org; Thu, 21 Apr 2011 19:17:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QD38D-0000mH-QW for emacs-devel@gnu.org; Thu, 21 Apr 2011 19:17:54 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:56871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QD38D-0000m1-FK for emacs-devel@gnu.org; Thu, 21 Apr 2011 19:17:53 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QD388-00023Q-Fi for emacs-devel@gnu.org; Fri, 22 Apr 2011 01:17:48 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Apr 2011 01:17:48 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Apr 2011 01:17:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 72 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:Amd8W1p0oHSjHq8B6FLYOrVj5L4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138631 Archived-At: --=-=-= Content-Type: text/plain On Wed, 06 Apr 2011 05:59:48 -0500 Ted Zlatanov wrote: TZ> Since hashtables can get pretty big, it would be nice to have a TZ> separator between entries when they are printed. Could that be provided TZ> at the top level, e.g. TZ> (let ((hash-table-print-separator "\\\n")) TZ> (format "%S" my-hash-table)) TZ> or in some other way? It would make large hashtable dumps like the ones TZ> from the new registry.el and gnus-registry.el much easier to read and TZ> debug. In the old gnus-registry.el I had special code to break up TZ> alists like that but it was slow so I'd rather ask Emacs to do it for TZ> me at the C level. The attached patch introduces `list-print-separator' to be used for list and hashtable entries. It's printed unescaped. It could be a function too, to be called with the print level. For me it's sufficient as a simple object to be printed. Let me know what you think... Thanks Ted --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=list-print-separator.patch === modified file 'src/print.c' --- src/print.c 2011-04-14 07:09:45 +0000 +++ src/print.c 2011-04-21 23:12:46 +0000 @@ -1658,6 +1658,10 @@ print_object (XCAR (obj), printcharfun, escapeflag); + /* Separate entries with list-print-separator. */ + if (!NILP (Vlist_print_separator)) + print_object (Vlist_print_separator, printcharfun, 0); + obj = XCDR (obj); if (!(i & 1)) halftail = XCDR (halftail); @@ -1849,6 +1853,9 @@ print_object (HASH_KEY (h, i), printcharfun, escapeflag); PRINTCHAR (' '); print_object (HASH_VALUE (h, i), printcharfun, escapeflag); + /* Separate entries with list-print-separator. */ + if (!NILP (Vlist_print_separator)) + print_object (Vlist_print_separator, printcharfun, 0); } if (size < real_size) @@ -2108,6 +2115,11 @@ A value of nil means no limit. See also `eval-expression-print-level'. */); Vprint_level = Qnil; + DEFVAR_LISP ("list-print-separator", Vlist_print_separator, + doc: /* When non-nil, printed unescaped to separate list entries. +Used for hashtable entries as well. */); + Vlist_print_separator = Qnil; + DEFVAR_BOOL ("print-escape-newlines", print_escape_newlines, doc: /* Non-nil means print newlines in strings as `\\n'. Also print formfeeds as `\\f'. */); --=-=-=--