Permalink
Browse files

Merge branch 'safe-print' into dimitri-master

  • Loading branch information...
2 parents 97e4d5c + cb787b2 commit 507fc697e6e6aea1568de63956b521c04399ebc0 @DarwinAwardWinner DarwinAwardWinner committed Mar 30, 2012
Showing with 26 additions and 68 deletions.
  1. +13 −2 el-get-core.el
  2. +4 −4 el-get-custom.el
  3. +1 −1 el-get-list-packages.el
  4. +3 −56 el-get-status.el
  5. +1 −1 el-get.el
  6. +1 −1 recipes/wanderlust.rcp
  7. +2 −2 test/el-get-issue-656.el
  8. +1 −1 test/el-get-issue-672.el
View
@@ -24,6 +24,17 @@
(require 'bytecomp)
(require 'autoload)
+(defun el-get-print-to-string (object &optional pretty)
+ "Return string representation of lisp object.
+
+Unlike the Emacs builtin printing functions, this ignores
+`print-level' and `print-length', ensuring that as much as
+possible the returned string will be a complete representation of
+the original object."
+ (let (print-level print-length)
+ (funcall (if pretty #'pp-to-string #'prin1-to-string)
+ object)))
+
(defun el-get-verbose-message (format &rest arguments)
(when el-get-verbose (apply 'message format arguments)))
@@ -362,7 +373,7 @@ makes it easier to conditionally splice a command into the list.
(infile (when stdin (make-temp-file "el-get")))
(dummy (when infile
(with-temp-file infile
- (insert (prin1-to-string stdin)))))
+ (insert (el-get-print-to-string stdin)))))
(dummy (message "el-get is waiting for %S to complete" cname))
(status (apply startf program infile cbuf t args))
(message (plist-get c :message))
@@ -390,7 +401,7 @@ makes it easier to conditionally splice a command into the list.
(process-put proc :el-get-final-func final-func)
(process-put proc :el-get-start-process-list next)
(when stdin
- (process-send-string proc (prin1-to-string stdin))
+ (process-send-string proc (el-get-print-to-string stdin))
(process-send-eof proc))
(set-process-sentinel proc 'el-get-start-process-list-sentinel)
(when filter (set-process-filter proc filter)))))
View
@@ -368,14 +368,14 @@ this is the name to fetch in that system"
(if (symbolp e)
(cons
(list 'const
- (intern (substring (prin1-to-string e) 1)))
+ (intern (substring (el-get-print-to-string e) 1)))
r)
r))
el-get-methods
:initial-value nil)
(lambda (x y)
- (string< (prin1-to-string (cadr x))
- (prin1-to-string (cadr y)))))))
+ (string< (el-get-print-to-string (cadr x))
+ (el-get-print-to-string (cadr y)))))))
(group :inline t :format "Source URL: %v"
(const :format "" :url) (string :format "%v"))
@@ -436,7 +436,7 @@ this is the name to fetch in that system"
:inline t :tag "System-Specific Build Recipes"
(group :inline t
(symbol :value ,(concat ":build/"
- (prin1-to-string system-type))
+ (el-get-print-to-string system-type))
:format "Build Tag: %v%h"
:doc "Must be of the form `:build/<system-type>',
where `<system-type>' is the value of `system-type' on
@@ -130,7 +130,7 @@ matching REGEX with TYPE and ARGS as parameter."
(el-get-describe-princ-button (format " in `%s':\n" file)
"`\\([^`']+\\)"
'el-get-help-package-def package)))
- (prin1 def)))
+ (princ (el-get-print-to-string def))))
(defun el-get-describe (package)
"Generate a description for PACKAGE."
View
@@ -48,60 +48,6 @@
package-name
(intern (format ":%s" package-name))))
-(defun el-get-pp-status-alist-to-string (object)
- (with-temp-buffer
- (lisp-mode-variables nil)
- (set-syntax-table emacs-lisp-mode-syntax-table)
- (let ((print-escape-newlines pp-escape-newlines)
- (print-quoted t))
- (prin1 object (current-buffer)))
- (goto-char (point-min))
- ;; Each (apparently-infinite) loop constantly moves forward
- ;; through the element it is processing (via `down-list`,
- ;; `up-list`, and `forward-sexp` and finally throws a scan-error
- ;; when it reaches the end of the element, which breaks out of the
- ;; loop and is caught by `condition-case`.
- (condition-case err
- (progn
- ;; Descend into status list"
- (down-list 1)
- (while t
- ;; Descend into status entry for next package
- (down-list 1)
- (condition-case err
- (progn
- ;; Get to the beginning of the recipe
- (down-list 1)
- (up-list -1)
- ;; Kill the recipe
- (kill-sexp)
- ;; Reprint the recipe with newlines between
- ;; key-value pairs
- (insert "(")
- (let ((recipe (car (read-from-string (car kill-ring)))))
- (loop for (prop val) on recipe by 'cddr
- do (insert
- (format "%s %s\n"
- (prin1-to-string prop)
- (prin1-to-string val)))))
- (insert ")"))
- (scan-error nil))
- ;; Exit from status entry for this package
- (up-list 1)))
- (scan-error nil))
- (pp-buffer)
- (goto-char (point-min))
- ;; Make sure we didn't change the value. That would be bad.
- (if (equal object (read (current-buffer)))
- (buffer-string)
- ;; If the pretty-printing function *did* change the value, just
- ;; use the built-in pretty-printing instead. It's not as good,
- ;; but at least it's correct.
- (warn "The custom pretty-printer for the .status.el failed. The original value and pretty-printed-value are shown below. You can try to see where they differ and report a bug.\n---BEGIN ORIGINAL VALUE---\n%s\n---END ORIGINAL VALUE---\n\n---BEGIN PRETTY-PRINTED VALUE---\n%s\n---END PRETTY-PRINTED VALUE---\n"
- (pp-to-string object)
- (buffer-string))
- (pp-to-string object))))
-
(defun el-get-save-package-status (package status)
"Save given package status"
(let* ((package (el-get-as-symbol package))
@@ -115,9 +61,10 @@
(cons package (list 'status status 'recipe recipe))))
(lambda (p1 p2)
(string< (el-get-as-string (car p1))
- (el-get-as-string (car p2)))))))
+ (el-get-as-string (car p2))))))
+ print-level print-length)
(with-temp-file el-get-status-file
- (insert (el-get-pp-status-alist-to-string new-package-status-alist)))
+ (insert (el-get-print-to-string new-package-status-alist 'pretty)))
;; Return the new alist
new-package-status-alist))
View
@@ -842,7 +842,7 @@ itself.")
;; Filepath is dir/file
(let ((filepath (format "%s/%s" dir filename)))
(with-temp-file filepath
- (insert (prin1-to-string source))))))
+ (insert (el-get-print-to-string source))))))
;;;###autoload
(defun el-get-make-recipes (&optional dir)
@@ -12,7 +12,7 @@
(append
'("apel" "flim" "semi")
(when (el-get-package-exists-p "bbdb") (list "bbdb"))))
- "--eval" (prin1-to-string
+ "--eval" (el-get-print-to-string
'(progn (setq wl-install-utils t)
(setq wl-info-lang "en")
(setq wl-news-lang "en")))
@@ -13,15 +13,15 @@
`((:name a :type test :compile "." :features a :build
(("sh" "-c" ,(format "echo %s > a.el"
(shell-quote-argument
- (mapconcat #'pp-to-string
+ (mapconcat #'el-get-print-to-string
'((require 'b)
(provide 'a))
"\n")))))
:depends b)
(:name b :type test :compile "." :features nil :build
(("sh" "-c" ,(format "echo %s > b.el"
(shell-quote-argument
- (pp-to-string
+ (el-get-print-to-string
'(provide 'b)))))))))
;; Ensure both are uninstalled
@@ -13,7 +13,7 @@
;; Set up the status file with a removed package that has no current
;; recipe available.
(with-temp-buffer
- (insert (prin1-to-string
+ (insert (el-get-print-to-string
'(:nonexistent-package "removed")))
(write-file el-get-status-file))

0 comments on commit 507fc69

Please sign in to comment.