Skip to content

Instantly share code, notes, and snippets.

@vermiculus
Created February 4, 2018 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vermiculus/adfe8270ed0664448f2ef1d1e57d6f29 to your computer and use it in GitHub Desktop.
Save vermiculus/adfe8270ed0664448f2ef1d1e57d6f29 to your computer and use it in GitHub Desktop.
;; a packagelet for figuring out where melpa is. will move point to commit in magit-log buffers.
(defun melpautil-where-is-melpa (package &optional force-refresh)
(interactive (list (intern (let-alist (magithub-repo) .name))
current-prefix-arg))
(let ((commit (melpautil-commit-for-package package force-refresh)))
(unless commit
(error "Commit not found"))
(setq commit (magit-rev-parse "--short" commit))
(when (derived-mode-p 'magit-log-mode)
(goto-char 0)
(while (not (string= commit (magit-section-value (magit-current-section))))
(magit-section-forward-sibling)))
(message "MELPA is at %s" (magit-get-shortname commit))))
(defconst melpautil-archive-url "http://melpa.org/archive.json")
(defvar melpautil-archive nil)
(defun melpautil--get-archive (refresh-now)
(let ((now (current-time))
(archive-url ))
(cdr (if (or (null melpautil-archive)
refresh-now
;; auto refresh every five minutes
(< 300 (time-to-seconds (time-subtract now (car melpautil-archive)))))
(setq melpautil-archive
(cons now (with-current-buffer (url-retrieve-synchronously melpautil-archive-url)
(search-forward "\n\n")
(json-read))))
melpautil-archive))))
(defun melpautil-commit-for-package (package &optional refresh-now)
(let-alist (alist-get package (melpautil--get-archive refresh-now))
.props.commit))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment