caizhiyuannn.github.io

nothing to say.. @caizhiyuannn@gmail.com

View the Project on GitHub

Table of Contents

  1. Emacs 第三方包 use-package
    1. 安装 use-package
      1. 开始
    2. 按键绑定 Key-binding

Emacs 第三方包 use-package

Use-package 是一个宏, 它能让你将一个包的 require 和它的相关的初始化等配置组织 在一起, 避免对同一个包的配置代码散落在不同的文件中.

安装 use-package

  1. 通过GitHub克隆源码进行安装
  2. 通过 MELPA 包仓库进行安装

开始

简单的声明 use-package 的例子

;; This is only needed once, near the top of the file
(eval-when-compile
  ;; Following line is not needed if use-package.el is in ~/.emacs.d
  (add-to-list 'load-path "<path where use-package is installed>")
  (require 'use-package))

(use-package foo)
    (use-package foo
      :init
      (setq foo-variable t))
    
    (use-package foo
      :init
      (setq foo-variable t)
      :config
      (foo-mode 1))
    
    (use-package color-moccur
      :commands (isearch-moccur isearch-all)
      :bind (("M-s O" . moccur)
             :map isearch-mode-map
             ("M-o" . isearch-moccur)
             ("M-O" . isearch-moccur-all))
      :init
      (setq isearch-lazy-highlight t)
      :config
      (use-package moccur-edit))
    

按键绑定 Key-binding

    (use-package ace-jump-mode
      :bind ("C-." . ace-jump-mode))
    
    (use-package ace-jump-mode
      :commands ace-jump-mode
      :init
      (bind-key "C-." 'ace-jump-mode))
    

##