all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Spiers <emacs@adamspiers.org>
To: 14187@debbugs.gnu.org
Subject: bug#14187: [PATCH] Pretty-print long values in custom variables
Date: Thu, 11 Apr 2013 20:13:29 +0100	[thread overview]
Message-ID: <1365707609-20004-1-git-send-email-emacs@adamspiers.org> (raw)
In-Reply-To: <20130411190713.GA16559@pacific.linksys.moosehall>

* 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






  reply	other threads:[~2013-04-11 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 15:51 custom-save-variables: pretty-printing long values Adam Spiers
2013-04-11 16:15 ` Stefan Monnier
2013-04-11 19:07   ` Adam Spiers
2013-04-11 19:13     ` Adam Spiers [this message]
2013-04-12  1:55       ` bug#14187: [PATCH] Pretty-print long values in custom variables Stefan Monnier
2013-05-08  6:59         ` Glenn Morris

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=1365707609-20004-1-git-send-email-emacs@adamspiers.org \
    --to=emacs@adamspiers.org \
    --cc=14187@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.