Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for method website guessers

  • Loading branch information...
commit 59c8c440e7a6d92421975f65562f6f163c13590d 1 parent 04f7c86
Ryan C. Thompson DarwinAwardWinner authored
Showing with 27 additions and 15 deletions.
  1. +18 −9 el-get-core.el
  2. +9 −6 el-get-list-packages.el
27 el-get-core.el
View
@@ -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
+ guess-website)
"Register the method for backend NAME, with given functions"
- (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))))
+ (let (method-def)
+ (loop for required-arg in '(install update remove)
+ unless (symbol-value required-arg)
+ 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))
15 el-get-list-packages.el
View
@@ -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)))
Please sign in to comment.
Something went wrong with that request. Please try again.