From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Adam Spiers Newsgroups: gmane.emacs.bugs Subject: bug#14187: [PATCH] Pretty-print long values in custom variables Date: Thu, 11 Apr 2013 20:13:29 +0100 Message-ID: <1365707609-20004-1-git-send-email-emacs@adamspiers.org> References: <20130411190713.GA16559@pacific.linksys.moosehall> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1365707654 23397 80.91.229.3 (11 Apr 2013 19:14:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Apr 2013 19:14:14 +0000 (UTC) To: 14187@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 11 21:14:18 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UQMwr-0007uw-VE for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Apr 2013 21:14:18 +0200 Original-Received: from localhost ([::1]:46336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQMwr-0001KW-HR for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Apr 2013 15:14:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQMwn-0001Jk-2e for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:14:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQMwl-0003NM-TY for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:14:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQMwl-0003NF-Qn for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:14:11 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UQN0U-0001Ky-0L for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Adam Spiers Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Apr 2013 19:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14187 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13657078524987 (code B ref -1); Thu, 11 Apr 2013 19:18:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Apr 2013 19:17:32 +0000 Original-Received: from localhost ([127.0.0.1]:46079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UQMzy-0001II-Hg for submit@debbugs.gnu.org; Thu, 11 Apr 2013 15:17:32 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52784) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UQMzw-0001Ht-1J for submit@debbugs.gnu.org; Thu, 11 Apr 2013 15:17:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQMwC-0003FD-9c for submit@debbugs.gnu.org; Thu, 11 Apr 2013 15:13:37 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:54555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQMwC-0003F8-72 for submit@debbugs.gnu.org; Thu, 11 Apr 2013 15:13:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQMwB-0000Vc-2o for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:13:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQMw9-0003EY-MN for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:13:35 -0400 Original-Received: from coral.adamspiers.org ([85.119.82.20]:55617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQMw9-0003EH-HK for bug-gnu-emacs@gnu.org; Thu, 11 Apr 2013 15:13:33 -0400 Original-Received: from localhost (2.d.c.d.2.5.f.b.c.0.4.8.0.1.4.d.0.0.0.0.b.1.4.6.0.b.8.0.1.0.0.2.ip6.arpa [IPv6:2001:8b0:641b:0:d410:840c:bf52:dcd2]) by coral.adamspiers.org (Postfix) with ESMTPSA id 00E1858EB3 for ; Thu, 11 Apr 2013 20:13:29 +0100 (BST) X-Mailer: git-send-email 1.8.2.1.347.gbef22ca In-Reply-To: <20130411190713.GA16559@pacific.linksys.moosehall> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73343 Archived-At: * cus-edit.el (custom-save-variables): When a custom value is over 60 characters long, insert it using indent-pp-sexp so that the value is more legible through being split over multiple lines. This is particularly useful when `custom-file' is tracked by a version control system, since then the diffs become much more manageable. --- lisp/cus-edit.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index d19e2de..8a018cb 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -4529,7 +4529,15 @@ This function does not save the buffer." (princ " '(") (prin1 symbol) (princ " ") - (prin1 (car value)) + (let ((val (prin1-to-string (car value)))) + (if (< (length val) 60) + (insert val) + (newline-and-indent) + (let ((beginning-of-val (point))) + (insert val) + (save-excursion + (goto-char beginning-of-val) + (indent-pp-sexp 1))))) (when (or now requests comment) (princ " ") (prin1 now) -- 1.8.2.1.347.gbef22ca