首页   注册   登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Emacs

emacs 自动安装 package 包

  •  
  •   frylkrttj · 219 天前 · 484 次点击
    这是一个创建于 219 天前的主题,其中的信息可能已经有所发展或是发生改变。

    下面是别人的配置,有些看不懂,请问 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 回复  |  直到 2019-03-11 09:15:11 +08:00
        1
    SamsonWang   191 天前
    min-version 是一个可选的传入参数
    建议你找个 lisp 教程看看
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   3995 人在线   最高记录 5043   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.3 · 25ms · UTC 07:20 · PVG 15:20 · LAX 00:20 · JFK 03:20
    ♥ Do have faith in what you're doing.