mirror of
https://github.com/larstvei/Try.git
synced 2025-04-19 19:20:12 +00:00
Compare commits
No commits in common. "master" and "0.0.1" have entirely different histories.
10
try.el
10
try.el
@ -36,6 +36,9 @@
|
|||||||
(require 'package)
|
(require 'package)
|
||||||
(require 'url)
|
(require 'url)
|
||||||
|
|
||||||
|
(defvar try-tmp-dir (make-temp-file "try" t)
|
||||||
|
"A temporary directory for storing packages.")
|
||||||
|
|
||||||
(defun try-raw-link-p (url)
|
(defun try-raw-link-p (url)
|
||||||
"Returns non-nil if this looks like an URL to a .el file."
|
"Returns non-nil if this looks like an URL to a .el file."
|
||||||
(string-match-p "[^:]*://\\([^?\r\n]+\\).*\.el?$" url))
|
(string-match-p "[^:]*://\\([^?\r\n]+\\).*\.el?$" url))
|
||||||
@ -65,10 +68,10 @@
|
|||||||
(completing-read "url or package: " pkgs)))
|
(completing-read "url or package: " pkgs)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun try-and-refresh (&optional url-or-package)
|
(defun try-and-refresh ()
|
||||||
"Refreshes package-list before calling `try'."
|
"Refreshes package-list before calling `try'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(package-refresh-contents) (try url-or-package))
|
(package-refresh-contents) (try))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun try (&optional url-or-package)
|
(defun try (&optional url-or-package)
|
||||||
@ -84,8 +87,7 @@ to a raw .el file. Packages are stored in `try-tmp-dir' and raw
|
|||||||
(package-symbol (intern url-or-package)))
|
(package-symbol (intern url-or-package)))
|
||||||
(cond ((try-raw-link-p url-or-package) (try-raw-link url-or-package))
|
(cond ((try-raw-link-p url-or-package) (try-raw-link url-or-package))
|
||||||
((try-package-exists-p package-symbol)
|
((try-package-exists-p package-symbol)
|
||||||
(let* ((tmp-dir (make-temp-file (concat url-or-package "-") t))
|
(let ((package-user-dir try-tmp-dir)
|
||||||
(package-user-dir tmp-dir)
|
|
||||||
(package-alist nil))
|
(package-alist nil))
|
||||||
(if (version< emacs-version "25.1")
|
(if (version< emacs-version "25.1")
|
||||||
(package-install package-symbol)
|
(package-install package-symbol)
|
||||||
|
Loading…
Reference in New Issue
Block a user