mirror of
https://github.com/correl/melpa.git
synced 2024-11-26 03:00:09 +00:00
Cleanup long lines where it can be avoided (like it doc strings)
This commit is contained in:
parent
529e64426b
commit
760e37e385
1 changed files with 30 additions and 16 deletions
|
@ -79,7 +79,8 @@
|
||||||
(print (substring-no-properties str)))))
|
(print (substring-no-properties str)))))
|
||||||
|
|
||||||
(defun pb/string-match-all (regex str &optional group)
|
(defun pb/string-match-all (regex str &optional group)
|
||||||
"Find every match for `REGEX' within `STR', returning the full match string or group `GROUP'."
|
"Find every match for `REGEX' within `STR', returning the full
|
||||||
|
match string or group `GROUP'."
|
||||||
(let (result
|
(let (result
|
||||||
(pos 0)
|
(pos 0)
|
||||||
(group (or group 0)))
|
(group (or group 0)))
|
||||||
|
@ -89,12 +90,14 @@
|
||||||
result))
|
result))
|
||||||
|
|
||||||
(defun pb/find-parse-time (regex &optional bound)
|
(defun pb/find-parse-time (regex &optional bound)
|
||||||
"Find REGEX in current buffer and format as a proper time version, optionally looking only as far as BOUND."
|
"Find REGEX in current buffer and format as a proper time
|
||||||
|
version, optionally looking only as far as BOUND."
|
||||||
(pb/parse-time (progn (re-search-backward regex bound)
|
(pb/parse-time (progn (re-search-backward regex bound)
|
||||||
(match-string-no-properties 1))))
|
(match-string-no-properties 1))))
|
||||||
|
|
||||||
(defun pb/find-parse-time-latest (regex &optional bound)
|
(defun pb/find-parse-time-latest (regex &optional bound)
|
||||||
"Find the latest timestamp matching REGEX, optionally looking only as far as BOUND."
|
"Find the latest timestamp matching REGEX, optionally looking
|
||||||
|
only as far as BOUND."
|
||||||
(let* ((text (buffer-substring-no-properties
|
(let* ((text (buffer-substring-no-properties
|
||||||
(or bound (point-min)) (point)))
|
(or bound (point-min)) (point)))
|
||||||
(times (mapcar 'pb/parse-time (pb/string-match-all regex text 1))))
|
(times (mapcar 'pb/parse-time (pb/string-match-all regex text 1))))
|
||||||
|
@ -121,15 +124,17 @@ the same arguments."
|
||||||
name config cwd)))
|
name config cwd)))
|
||||||
|
|
||||||
(defvar pb/last-wiki-fetch-time 0
|
(defvar pb/last-wiki-fetch-time 0
|
||||||
"The time at which an emacswiki URL was last requested.
|
"The time at which an emacswiki URL was last requested. This is
|
||||||
This is used to avoid exceeding the rate limit of 1 request per 2
|
used to avoid exceeding the rate limit of 1 request per 2
|
||||||
seconds; the server cuts off after 10 requests in 20 seconds.")
|
seconds; the server cuts off after 10 requests in 20 seconds.")
|
||||||
|
|
||||||
(defvar pb/wiki-min-request-interval 2
|
(defvar pb/wiki-min-request-interval 2
|
||||||
"The shortest permissible interval between successive requests for Emacswiki URLs.")
|
"The shortest permissible interval between successive requests
|
||||||
|
for Emacswiki URLs.")
|
||||||
|
|
||||||
(defmacro pb/with-wiki-rate-limit (&rest body)
|
(defmacro pb/with-wiki-rate-limit (&rest body)
|
||||||
"Rate-limit BODY code passed to this macro to match EmacsWiki's rate limiting."
|
"Rate-limit BODY code passed to this macro to match EmacsWiki's
|
||||||
|
rate limiting."
|
||||||
(let ((now (gensym))
|
(let ((now (gensym))
|
||||||
(elapsed (gensym)))
|
(elapsed (gensym)))
|
||||||
`(let* ((,now (float-time))
|
`(let* ((,now (float-time))
|
||||||
|
@ -144,8 +149,10 @@ seconds; the server cuts off after 10 requests in 20 seconds.")
|
||||||
|
|
||||||
(defun pb/grab-wiki-file (filename)
|
(defun pb/grab-wiki-file (filename)
|
||||||
"Download FILENAME from emacswiki, returning its last-modified time."
|
"Download FILENAME from emacswiki, returning its last-modified time."
|
||||||
(let* ((download-url (format "http://www.emacswiki.org/emacs/download/%s" filename))
|
(let* ((download-url
|
||||||
(wiki-url (format "http://www.emacswiki.org/emacs/%s" filename)))
|
(format "http://www.emacswiki.org/emacs/download/%s" filename))
|
||||||
|
(wiki-url
|
||||||
|
(format "http://www.emacswiki.org/emacs/%s" filename)))
|
||||||
(pb/with-wiki-rate-limit
|
(pb/with-wiki-rate-limit
|
||||||
(url-copy-file download-url filename t))
|
(url-copy-file download-url filename t))
|
||||||
(with-current-buffer (pb/with-wiki-rate-limit
|
(with-current-buffer (pb/with-wiki-rate-limit
|
||||||
|
@ -260,6 +267,7 @@ seconds; the server cuts off after 10 requests in 20 seconds.")
|
||||||
(let* ((url (format "git://github.com/%s.git" (plist-get config :repo))))
|
(let* ((url (format "git://github.com/%s.git" (plist-get config :repo))))
|
||||||
(pb/checkout-git name (plist-put (copy-sequence config) :url url) dir)))
|
(pb/checkout-git name (plist-put (copy-sequence config) :url url) dir)))
|
||||||
|
|
||||||
|
|
||||||
(defun pb/bzr-repo (dir)
|
(defun pb/bzr-repo (dir)
|
||||||
"Get the current bzr repo for DIR."
|
"Get the current bzr repo for DIR."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
@ -312,7 +320,8 @@ seconds; the server cuts off after 10 requests in 20 seconds.")
|
||||||
(delete-directory dir t nil))
|
(delete-directory dir t nil))
|
||||||
(print "cloning repository")
|
(print "cloning repository")
|
||||||
(pb/run-process nil "hg" "clone" repo dir)))
|
(pb/run-process nil "hg" "clone" repo dir)))
|
||||||
(apply 'pb/run-process dir "hg" "log" "--style" "compact" "-l1" (pb/expand-file-list dir config))
|
(apply 'pb/run-process dir "hg" "log" "--style" "compact" "-l1"
|
||||||
|
(pb/expand-file-list dir config))
|
||||||
(pb/find-parse-time
|
(pb/find-parse-time
|
||||||
"\\([0-9]\\{4\\}-[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\\}\\)"))))
|
||||||
|
|
||||||
|
@ -335,7 +344,8 @@ seconds; the server cuts off after 10 requests in 20 seconds.")
|
||||||
pkg-file))
|
pkg-file))
|
||||||
|
|
||||||
(defun pb/read-from-file (file-name)
|
(defun pb/read-from-file (file-name)
|
||||||
"Read and return the Lisp data stored in FILE-NAME, or nil if no such file exists."
|
"Read and return the Lisp data stored in FILE-NAME,or nil if no
|
||||||
|
such file exists."
|
||||||
(when (file-exists-p file-name)
|
(when (file-exists-p file-name)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents-literally file-name)
|
(insert-file-contents-literally file-name)
|
||||||
|
@ -344,8 +354,9 @@ seconds; the server cuts off after 10 requests in 20 seconds.")
|
||||||
|
|
||||||
|
|
||||||
(defun pb/create-tar (file dir &optional files)
|
(defun pb/create-tar (file dir &optional files)
|
||||||
"Create a tar FILE containing the contents of DIR, or just FILES if non-nil.
|
"Create a tar FILE containing the contents of DIR, or just
|
||||||
The file is written to `package-build-working-dir'."
|
FILES if non-nil. The file is written to
|
||||||
|
`package-build-working-dir'."
|
||||||
(let* ((default-directory package-build-working-dir))
|
(let* ((default-directory package-build-working-dir))
|
||||||
(apply 'process-file
|
(apply 'process-file
|
||||||
"tar" nil
|
"tar" nil
|
||||||
|
@ -388,7 +399,8 @@ The file is written to `package-build-working-dir'."
|
||||||
(nth 1 pkgfile-info)))))
|
(nth 1 pkgfile-info)))))
|
||||||
|
|
||||||
(defun pb/expand-file-list (dir config)
|
(defun pb/expand-file-list (dir config)
|
||||||
"In DIR, expand the :files for CONFIG, some of which may be shell-style wildcards."
|
"In DIR, expand the :files for CONFIG, some of which may be
|
||||||
|
shell-style wildcards."
|
||||||
(let ((default-directory dir))
|
(let ((default-directory dir))
|
||||||
(mapcan 'file-expand-wildcards
|
(mapcan 'file-expand-wildcards
|
||||||
(or (plist-get config :files) (list "*.el")))))
|
(or (plist-get config :files) (list "*.el")))))
|
||||||
|
@ -411,7 +423,8 @@ If PKG-INFO is nil, an empty one is created."
|
||||||
package-build-archive-dir)))
|
package-build-archive-dir)))
|
||||||
|
|
||||||
(defun pb/add-to-archive-contents (pkg-info type)
|
(defun pb/add-to-archive-contents (pkg-info type)
|
||||||
"Add the built archive with info PKG-INFO and TYPE to `package-build-archive-alist'."
|
"Add the built archive with info PKG-INFO and TYPE to
|
||||||
|
`package-build-archive-alist'."
|
||||||
(let* ((name (intern (aref pkg-info 0)))
|
(let* ((name (intern (aref pkg-info 0)))
|
||||||
(requires (aref pkg-info 1))
|
(requires (aref pkg-info 1))
|
||||||
(desc (or (aref pkg-info 2) "No description available."))
|
(desc (or (aref pkg-info 2) "No description available."))
|
||||||
|
@ -429,7 +442,8 @@ If PKG-INFO is nil, an empty one is created."
|
||||||
type)))))
|
type)))))
|
||||||
|
|
||||||
(defun pb/archive-file-name (archive-entry)
|
(defun pb/archive-file-name (archive-entry)
|
||||||
"Return the path of the file in which the package for ARCHIVE-ENTRY is stored."
|
"Return the path of the file in which the package for
|
||||||
|
ARCHIVE-ENTRY is stored."
|
||||||
(expand-file-name (format "%s-%s.%s"
|
(expand-file-name (format "%s-%s.%s"
|
||||||
(car archive-entry)
|
(car archive-entry)
|
||||||
(car (aref (cdr archive-entry) 0))
|
(car (aref (cdr archive-entry) 0))
|
||||||
|
|
Loading…
Reference in a new issue