Skip to content
This repository
Browse code

Add support for method website guessers

  • Loading branch information...
commit 59c8c440e7a6d92421975f65562f6f163c13590d 1 parent 04f7c86
Ryan Thompson DarwinAwardWinner authored

Showing 2 changed files with 27 additions and 15 deletions. Show diff stats Hide diff stats

  1. +18 9 el-get-core.el
  2. +9 6 el-get-list-packages.el
27 el-get-core.el
@@ -45,16 +45,25 @@ call for doing the named package action in the given method.")
45 45 (and (el-get-method name :install) t))
46 46
47 47 (defun* el-get-register-method (name &key install update remove
48   - install-hook remove-hook compute-checksum)
  48 + install-hook remove-hook compute-checksum
  49 + guess-website)
49 50 "Register the method for backend NAME, with given functions"
50   - (loop for required-arg in '(install update remove)
51   - unless (symbol-value required-arg)
52   - do (error "Missing required argument: :%s" required-arg))
53   - (let ((def (list :install install :update update :remove remove)))
54   - (when install-hook (setq def (plist-put def :install-hook install-hook)))
55   - (when remove-hook (setq def (plist-put def :remove-hook remove-hook)))
56   - (when compute-checksum (setq def (plist-put def :compute-checksum compute-checksum)))
57   - (setq el-get-methods (plist-put el-get-methods name def))))
  51 + (let (method-def)
  52 + (loop for required-arg in '(install update remove)
  53 + unless (symbol-value required-arg)
  54 + do (error "Missing required argument: :%s" required-arg)
  55 + do (setq method-def
  56 + (plist-put method-def
  57 + (intern (format ":%s" required-arg))
  58 + (symbol-value required-arg))))
  59 + (loop for optional-arg in '(install-hook remove-hook
  60 + compute-checksum guess-website)
  61 + if (symbol-value optional-arg)
  62 + do (setq method-def
  63 + (plist-put method-def
  64 + (intern (format ":%s" optional-arg))
  65 + (symbol-value optional-arg))))
  66 + (setq el-get-methods (plist-put el-get-methods name method-def))))
58 67
59 68 (put 'el-get-register-method 'lisp-indent-function
60 69 (get 'prog1 'lisp-indent-function))
15 el-get-list-packages.el
@@ -16,6 +16,9 @@
16 16 ;;
17 17 ;; Description of packages. (Code based on `describe-function').
18 18 ;;
  19 +(require 'el-get-core)
  20 +(require 'cl)
  21 +
19 22 (define-button-type 'el-get-help-package-def
20 23 :supertype 'help-xref
21 24 'help-function (lambda (package) (find-file (el-get-recipe-filename package)))
@@ -64,11 +67,11 @@ matching REGEX with TYPE and ARGS as parameter."
64 67 (re-search-backward regex nil t)
65 68 (apply #'help-xref-button 1 type args))))
66 69
67   -(defun el-get-guess-github-website (url)
68   - "If a package's URL is on Github, return the project's Github URL."
69   - (when (and url (string-match "github\\.com/" url))
70   - (replace-regexp-in-string "\\.git$" ""
71   - (replace-regexp-in-string "\\(git\\|https\\)://" "http://" url))))
  70 +(defun el-get-guess-website (package)
  71 + (let* ((type (el-get-package-type package))
  72 + (guesser (el-get-method type :guess-website)))
  73 + (when guesser
  74 + (funcall guesser package))))
72 75
73 76 (defun el-get-describe-1 (package)
74 77 (let* ((psym (el-get-as-symbol package))
@@ -99,7 +102,7 @@ matching REGEX with TYPE and ARGS as parameter."
99 102 (princ ".\n\n")
100 103
101 104 (let ((website (or website
102   - (and (eq 'git type) (el-get-guess-github-website url)))))
  105 + (el-get-guess-website package))))
103 106 (when website
104 107 (el-get-describe-princ-button (format "Website: %s\n" website)
105 108 ": \\(.+\\)" 'help-url website)))

0 comments on commit 59c8c44

Please sign in to comment.
Something went wrong with that request. Please try again.