Commit 59c8c440 authored by Ryan C. Thompson's avatar Ryan C. Thompson

Add support for method website guessers

parent 04f7c866
......@@ -45,16 +45,25 @@ call for doing the named package action in the given method.")
(and (el-get-method name :install) t))
(defun* el-get-register-method (name &key install update remove
install-hook remove-hook compute-checksum)
install-hook remove-hook compute-checksum
"Register the method for backend NAME, with given functions"
(let (method-def)
(loop for required-arg in '(install update remove)
unless (symbol-value required-arg)
do (error "Missing required argument: :%s" required-arg))
(let ((def (list :install install :update update :remove remove)))
(when install-hook (setq def (plist-put def :install-hook install-hook)))
(when remove-hook (setq def (plist-put def :remove-hook remove-hook)))
(when compute-checksum (setq def (plist-put def :compute-checksum compute-checksum)))
(setq el-get-methods (plist-put el-get-methods name def))))
do (error "Missing required argument: :%s" required-arg)
do (setq method-def
(plist-put method-def
(intern (format ":%s" required-arg))
(symbol-value required-arg))))
(loop for optional-arg in '(install-hook remove-hook
compute-checksum guess-website)
if (symbol-value optional-arg)
do (setq method-def
(plist-put method-def
(intern (format ":%s" optional-arg))
(symbol-value optional-arg))))
(setq el-get-methods (plist-put el-get-methods name method-def))))
(put 'el-get-register-method 'lisp-indent-function
(get 'prog1 'lisp-indent-function))
......@@ -16,6 +16,9 @@
;; Description of packages. (Code based on `describe-function').
(require 'el-get-core)
(require 'cl)
(define-button-type 'el-get-help-package-def
:supertype 'help-xref
'help-function (lambda (package) (find-file (el-get-recipe-filename package)))
......@@ -64,11 +67,11 @@ matching REGEX with TYPE and ARGS as parameter."
(re-search-backward regex nil t)
(apply #'help-xref-button 1 type args))))
(defun el-get-guess-github-website (url)
"If a package's URL is on Github, return the project's Github URL."
(when (and url (string-match "github\\.com/" url))
(replace-regexp-in-string "\\.git$" ""
(replace-regexp-in-string "\\(git\\|https\\)://" "http://" url))))
(defun el-get-guess-website (package)
(let* ((type (el-get-package-type package))
(guesser (el-get-method type :guess-website)))
(when guesser
(funcall guesser package))))
(defun el-get-describe-1 (package)
(let* ((psym (el-get-as-symbol package))
......@@ -99,7 +102,7 @@ matching REGEX with TYPE and ARGS as parameter."
(princ ".\n\n")
(let ((website (or website
(and (eq 'git type) (el-get-guess-github-website url)))))
(el-get-guess-website package))))
(when website
(el-get-describe-princ-button (format "Website: %s\n" website)
": \\(.+\\)" 'help-url website)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment