
下面是别人的配置,有些看不懂,请问 min-version 这个是什么啊,怎么我在 melpa 里面找不到这个包?
(require 'package) (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/") ("org" . "http://orgmode.org/elpa"))) (defun require-package (package &optional min-version no-refresh) "Install given PACKAGE, optionally requiring MIN-VERSION. If NO-REFRESH is non-nil, the available package lists will not be re-downloaded in order to locate PACKAGE." (or (package-installed-p package min-version) (let* ((known (cdr (assoc package package-archive-contents))) (versions (mapcar #'package-desc-version known))) (if (cl-find-if (lambda (v) (version-list-<= min-version v)) versions) (package-install package) (if no-refresh (error "No version of %s >= %S is available" package min-version) (package-refresh-contents) (require-package package min-version t)))))) (defun maybe-require-package (package &optional min-version no-refresh) "Try to install PACKAGE, and return non-nil if successful. In the event of failure, return nil and print a warning message. Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the available package lists will not be re-downloaded in order to locate PACKAGE." (condition-case err (require-package package min-version no-refresh) (error (message "Couldn't install optional package `%s': %S" package err) nil))) (setq package-enable-at-startup nil) (package-initialize) (require-package 'magit) ;;;auto install magit 1 SamsonWang 2019-03-11 09:15:11 +08:00 min-version 是一个可选的传入参数 建议你找个 lisp 教程看看 |