Emacs学习笔记(3)——基于MELPA的Emace插件安装

来源:http://ergoemacs.org/emacs/emacs_package_system.html

在Emacs版本号24以上的文件.emacs中写入如下语句,以实现可安装插件的显示

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/")
   t)
  (package-initialize))
然后用语句:M-x eval-buffer,实现文件.Emacs的重调用


restart emacs.

emacs packages elpa screenshotEmacs  list-packages screenshot
  1. Now, call list-packages.
  2. Find the package you want, move cursor to the line press Enter ↵.
  3. press Tab ↹ to move cursor to the “Install” button then press Enter ↵.
  4. Then, you can start to use the package.

Following are details.

Listing Available Packages

Call list-packages.

Install Packages

This list is shown in package-menu-mode. In this mode, here's the most useful keys:

  • Enter ↵】 (package-menu-describe-package) → Describe the package under cursor.
  • i】 (package-menu-mark-install) → mark for installation.
  • u】 (package-menu-mark-unmark) → unmark.
  • d】 (package-menu-mark-delete) → mark for deletion (removal of a installed package).
  • x】 (package-menu-execute) → for “execute” (start install/uninstall of marked items).
  • r】 (package-menu-refresh) → refresh the list from server.

(For complete list of keys, call describe-mode 【Ctrl+h m】)

For example, i want to install the clojure-mode. I type i to mark it, x to run install. Then, i got the following files in my dir, all automatically byte-compiled and loaded.

~/.emacs.d/elpa/clojure-mode-1.7.1:
clojure-mode-autoloads.el
clojure-mode-pkg.el
clojure-mode-pkg.elc
clojure-mode.el
clojure-mode.elc

and now i can call clojure-mode, and it works right there! (no need to restart, but for some packages, you may need to turn it on or restart emacs.)

Upgrade Packages

To upgrade packages, just press 【U x】.

  • package-menu-mark-upgrades 【U】 → For any package that has a new version, the installed one will be marked “D” (for delete), and new one will be marked “I” (to install).
  • package-menu-execute 【x】 → run the marked commands on packages.

WARNING: package upgrade is not reliable. It is better to upgrade one package at a time. First delete the package, then install the latest.

Installed Packages Location

New packages are installed at ~/.emacs.d/elpa/.

If you want to remove all external packages, you can delete this entire directory and restart emacs. It is harmless to do so.

Packages Repositories

The source of the packages are from package servers. There are several.

  • http://elpa.gnu.org/ Default. Official GNU Emacs package repository. This repository contains the minimal set, and each package is signed by Free Software Foundation.
  • http://marmalade-repo.org/ Marmalade. More extensive number of packages.
  • http://melpa.org/ MELPA. As of 2016-01-16, MELPA has most packages, and updated daily.

To add it, put the following in your emacs init file:

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/")
   t)
  (package-initialize))

Note: the emacs package system, called ELPA (aka package.el), is started by Tom Tromey. Marmalade is started by Nathan Weizenbaum. MELPA is started by Donald Ephraim Curtis (aka milkypostman) Thank you guys.

Helpful Commands and Variables

package-enable-at-startup. By default, this is t (true).

package-load-list. This determines which packages should be loaded at start-up.

Call describe-function or describe-variable for details.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值