summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2017-02-23 14:31:23 +0300
committerAlex Kost <alezost@gmail.com>2017-02-27 17:43:45 +0300
commit5bc0bc3e9a15c4f1f0b34e41c192cc2888323f4a (patch)
treef20f15a1ce9a9b994b36d95774d059caf7b3bb80
parentelisp/ui-system-generation: Improve pretty printing (diff)
downloadguix-wigust-5bc0bc3e9a15c4f1f0b34e41c192cc2888323f4a.tar.gz
elisp/utils: Indent all sexps during pretty-printing
* elisp/guix-utils.el (guix-show-pretty-print-buffer): Use 'indent-pp-sexp' on each top-level sexp as 'pp-buffer' prettifies only a single sexp!
-rw-r--r--elisp/guix-utils.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/elisp/guix-utils.el b/elisp/guix-utils.el
index 0b63d06..767d992 100644
--- a/elisp/guix-utils.el
+++ b/elisp/guix-utils.el
@@ -194,7 +194,14 @@ Press '\\[revert-buffer]' to update this buffer.")))))
(defun guix-pretty-print-buffer (buffer-or-name)
"Pretty-print the contents of BUFFER-OR-NAME."
(with-current-buffer buffer-or-name
- (save-excursion (pp-buffer))
+ (goto-char (point-max))
+ (let (sexp-beg)
+ (while (setq sexp-beg (scan-sexps (point) -1))
+ (goto-char sexp-beg)
+ (delete-horizontal-space t)
+ (unless (= (point) (line-beginning-position))
+ (insert "\n"))
+ (indent-pp-sexp 'pp)))
(toggle-truncate-lines -1)))
(defun guix-pretty-print-file (file-name &optional mode)