mirror of
https://github.com/correl/melpa.git
synced 2024-11-14 19:19:32 +00:00
Factor out code for writing pretty-printed sexps to disk
This commit is contained in:
parent
97dc2430b1
commit
69d4ad65c2
1 changed files with 18 additions and 29 deletions
|
@ -154,28 +154,23 @@ In turn, this function uses the :fetcher option in the config to choose a
|
||||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)"))))
|
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)"))))
|
||||||
|
|
||||||
|
|
||||||
|
(defun package-build-dump (data file)
|
||||||
|
"Write `DATA' to `FILE' as a pretty-printed Lisp sexp."
|
||||||
|
(write-region (concat (pp-to-string data) "\n") nil file nil nil nil nil))
|
||||||
|
|
||||||
(defun package-build-pkg-file (pkg-file pkg-info)
|
(defun package-build-pkg-file (pkg-file pkg-info)
|
||||||
"build the pkg file"
|
"build the pkg file"
|
||||||
(let ((pkg-list
|
(package-build-dump
|
||||||
(list 'define-package
|
`(define-package
|
||||||
(aref pkg-info 0)
|
,(aref pkg-info 0)
|
||||||
(aref pkg-info 3)
|
,(aref pkg-info 3)
|
||||||
(aref pkg-info 2)
|
,(aref pkg-info 2)
|
||||||
(list 'quote (mapcar
|
,@(mapcar
|
||||||
(lambda (elt)
|
(lambda (elt)
|
||||||
(list (car elt)
|
(list (car elt)
|
||||||
(package-version-join (cadr elt))))
|
(package-version-join (cadr elt))))
|
||||||
(aref pkg-info 1))))))
|
(aref pkg-info 1)))
|
||||||
|
pkg-file))
|
||||||
(write-region
|
|
||||||
(concat
|
|
||||||
(pp-to-string
|
|
||||||
pkg-list
|
|
||||||
)
|
|
||||||
"\n")
|
|
||||||
nil
|
|
||||||
pkg-file
|
|
||||||
nil nil nil nil)))
|
|
||||||
|
|
||||||
(defun package-read-from-file (file-name)
|
(defun package-read-from-file (file-name)
|
||||||
"Read and return the lisp data stored in `FILENAME', or nil if no such file exists."
|
"Read and return the lisp data stored in `FILENAME', or nil if no such file exists."
|
||||||
|
@ -350,17 +345,11 @@ In turn, this function uses the :fetcher option in the config to choose a
|
||||||
(expand-file-name "archive-contents" package-build-archive-dir)))
|
(expand-file-name "archive-contents" package-build-archive-dir)))
|
||||||
"List of already-built packages, in the standard package.el format.")
|
"List of already-built packages, in the standard package.el format.")
|
||||||
|
|
||||||
|
|
||||||
(defun package-build-dump-archive-contents ()
|
(defun package-build-dump-archive-contents ()
|
||||||
"dump the archive contents back to the file"
|
"dump the archive contents back to the file"
|
||||||
(write-region
|
(package-build-dump (cons 1 package-build-archive-alist)
|
||||||
(concat
|
(expand-file-name "archive-contents"
|
||||||
(pp-to-string
|
package-build-archive-dir)))
|
||||||
(cons 1 package-build-archive-alist))
|
|
||||||
"\n")
|
|
||||||
nil
|
|
||||||
(expand-file-name "archive-contents" package-build-archive-dir)
|
|
||||||
nil nil nil nil))
|
|
||||||
|
|
||||||
(defun package-build-add-to-archive-contents (pkg-info type)
|
(defun package-build-add-to-archive-contents (pkg-info type)
|
||||||
"add an archive to the package-build-archive-contents"
|
"add an archive to the package-build-archive-contents"
|
||||||
|
|
Loading…
Reference in a new issue