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

emacs 自动安装 package 包

  •  
  •   frylkrttj · 2019-02-11 09:44:08 +08:00 · 4202 次点击
    这是一个创建于 2118 天前的主题,其中的信息可能已经有所发展或是发生改变。

    下面是别人的配置,有些看不懂,请问 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
    SamsonWang
        1
    SamsonWang  
       2019-03-11 09:15:11 +08:00
    min-version 是一个可选的传入参数
    建议你找个 lisp 教程看看
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3757 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 05:08 · PVG 13:08 · LAX 21:08 · JFK 00:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.