Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

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