[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#14187: [PATCH] Pretty-print long values in custom variables
From: |
Adam Spiers |
Subject: |
bug#14187: [PATCH] Pretty-print long values in custom variables |
Date: |
Thu, 11 Apr 2013 20:13:29 +0100 |
* 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
- bug#14187: [PATCH] Pretty-print long values in custom variables,
Adam Spiers <=