Klimi's new dotfiles with stow.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

1048 satır
33 KiB

4 yıl önce
  1. This is use-package.info, produced by makeinfo version 6.5 from
  2. use-package.texi.
  3. Copyright (C) 2012-2017 John Wiegley <johnw@newartisans.com>
  4. You can redistribute this document and/or modify it under the terms
  5. of the GNU General Public License as published by the Free Software
  6. Foundation, either version 3 of the License, or (at your option)
  7. any later version.
  8. This document is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. INFO-DIR-SECTION Emacs
  13. START-INFO-DIR-ENTRY
  14. * use-package: (use-package). Declarative package configuration for Emacs.
  15. END-INFO-DIR-ENTRY
  16. 
  17. File: use-package.info, Node: Top, Next: Introduction, Up: (dir)
  18. use-package User Manual
  19. ***********************
  20. use-package is...
  21. Copyright (C) 2012-2017 John Wiegley <johnw@newartisans.com>
  22. You can redistribute this document and/or modify it under the terms
  23. of the GNU General Public License as published by the Free Software
  24. Foundation, either version 3 of the License, or (at your option)
  25. any later version.
  26. This document is distributed in the hope that it will be useful,
  27. but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  29. General Public License for more details.
  30. * Menu:
  31. * Introduction::
  32. * Installation::
  33. * Getting Started::
  34. * Keywords::
  35. * FAQ::
  36. * Debugging Tools::
  37. * Command Index::
  38. * Function Index::
  39. * Variable Index::
  40. — The Detailed Node Listing —
  41. Installation
  42. * Installing from an Elpa Archive::
  43. * Installing from the Git Repository::
  44. * Post-Installation Tasks::
  45. Keywords
  46. * ‘:after’: after.
  47. * ‘:bind-keymap’, ‘:bind-keymap*’: bind-keymap bind-keymap*.
  48. * ‘:bind’, ‘:bind*’: bind bind*.
  49. * ‘:commands’: commands.
  50. * ‘:preface’, ‘:init’, ‘:config’: preface init config.
  51. * ‘:custom’: custom.
  52. * ‘:custom-face’: custom-face.
  53. * ‘:defer’, ‘:demand’: defer demand.
  54. * ‘:defines’, ‘:functions’: defines functions.
  55. * ‘:diminish’, ‘:delight’: diminish delight.
  56. * ‘:disabled’: disabled.
  57. * ‘:ensure’, ‘:pin’: ensure pin.
  58. * ‘:hook’: hook.
  59. * ‘:if’, ‘:when’, ‘:unless’: if when unless.
  60. * ‘:load-path’: load-path.
  61. * ‘:mode’, ‘:interpreter’: mode interpreter.
  62. * ‘:magic’, ‘:magic-fallback’: magic magic-fallback.
  63. * ‘:no-require’: no-require.
  64. * ‘:requires’: requires.
  65. ‘:bind’, ‘:bind*’
  66. * Binding to local keymaps::
  67. FAQ
  68. * FAQ - How to ...?::
  69. * FAQ - Issues and Errors::
  70. FAQ - How to ...?
  71. * This is a question::
  72. FAQ - Issues and Errors
  73. * This is an issues::
  74. 
  75. File: use-package.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top
  76. 1 Introduction
  77. **************
  78. The ‘use-package’ macro allows you to isolate package configuration in
  79. your ‘.emacs’ file in a way that is both performance-oriented and, well,
  80. tidy. I created it because I have over 400 packages that I use in
  81. Emacs, and things were getting difficult to manage. Yet with this
  82. utility my total load time is around 2 seconds, with no loss of
  83. functionality!
  84. 
  85. File: use-package.info, Node: Installation, Next: Getting Started, Prev: Introduction, Up: Top
  86. 2 Installation
  87. **************
  88. use-package can be installed using Emacs’ package manager or manually
  89. from its development repository.
  90. * Menu:
  91. * Installing from an Elpa Archive::
  92. * Installing from the Git Repository::
  93. * Post-Installation Tasks::
  94. 
  95. File: use-package.info, Node: Installing from an Elpa Archive, Next: Installing from the Git Repository, Up: Installation
  96. 2.1 Installing from an Elpa Archive
  97. ===================================
  98. use-package is available from Melpa and Melpa-Stable. If you haven’t
  99. used Emacs’ package manager before, then it is high time you familiarize
  100. yourself with it by reading the documentation in the Emacs manual, see
  101. *note (emacs)Packages::. Then add one of the archives to
  102. ‘package-archives’:
  103. • To use Melpa:
  104. (require 'package)
  105. (add-to-list 'package-archives
  106. '("melpa" . "https://melpa.org/packages/") t)
  107. • To use Melpa-Stable:
  108. (require 'package)
  109. (add-to-list 'package-archives
  110. '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  111. Once you have added your preferred archive, you need to update the
  112. local package list using:
  113. M-x package-refresh-contents RET
  114. Once you have done that, you can install use-package and its
  115. dependencies using:
  116. M-x package-install RET use-package RET
  117. Now see *note Post-Installation Tasks::.
  118. 
  119. File: use-package.info, Node: Installing from the Git Repository, Next: Post-Installation Tasks, Prev: Installing from an Elpa Archive, Up: Installation
  120. 2.2 Installing from the Git Repository
  121. ======================================
  122. First, use Git to clone the use-package repository:
  123. $ git clone https://github.com/jwiegley/use-package.git ~/.emacs.d/site-lisp/use-package
  124. $ cd ~/.emacs.d/site-lisp/use-package
  125. Then compile the libraries and generate the info manuals:
  126. $ make
  127. You may need to create ‘/path/to/use-package/config.mk’ with the
  128. following content before running ‘make’:
  129. LOAD_PATH = -L /path/to/use-package
  130. Finally add this to your init file:
  131. (add-to-list 'load-path "~/.emacs.d/site-lisp/use-package")
  132. (require 'use-package)
  133. (with-eval-after-load 'info
  134. (info-initialize)
  135. (add-to-list 'Info-directory-list
  136. "~/.emacs.d/site-lisp/use-package/"))
  137. Note that elements of ‘load-path’ should not end with a slash, while
  138. those of ‘Info-directory-list’ should.
  139. Instead of running use-package directly from the repository by adding
  140. it to the ‘load-path’, you might want to instead install it in some
  141. other directory using ‘sudo make install’ and setting ‘load-path’
  142. accordingly.
  143. To update use-package use:
  144. $ git pull
  145. $ make
  146. At times it might be necessary to run ‘make clean all’ instead.
  147. To view all available targets use ‘make help’.
  148. Now see *note Post-Installation Tasks::.
  149. 
  150. File: use-package.info, Node: Post-Installation Tasks, Prev: Installing from the Git Repository, Up: Installation
  151. 2.3 Post-Installation Tasks
  152. ===========================
  153. After installing use-package you should verify that you are indeed using
  154. the use-package release you think you are using. It’s best to restart
  155. Emacs before doing so, to make sure you are not using an outdated value
  156. for ‘load-path’.
  157. C-h v use-package-version RET
  158. should display something like
  159. use-package-version’s value is "2.4"
  160. If you are completely new to use-package then see *note Getting
  161. Started::.
  162. If you run into problems, then please see the *note FAQ::. Also see
  163. the *note Debugging Tools::.
  164. 
  165. File: use-package.info, Node: Getting Started, Next: Keywords, Prev: Installation, Up: Top
  166. 3 Getting Started
  167. *****************
  168. TODO. For now, see ‘README.md’.
  169. 
  170. File: use-package.info, Node: Keywords, Next: FAQ, Prev: Getting Started, Up: Top
  171. 4 Keywords
  172. **********
  173. * Menu:
  174. * ‘:after’: after.
  175. * ‘:bind-keymap’, ‘:bind-keymap*’: bind-keymap bind-keymap*.
  176. * ‘:bind’, ‘:bind*’: bind bind*.
  177. * ‘:commands’: commands.
  178. * ‘:preface’, ‘:init’, ‘:config’: preface init config.
  179. * ‘:custom’: custom.
  180. * ‘:custom-face’: custom-face.
  181. * ‘:defer’, ‘:demand’: defer demand.
  182. * ‘:defines’, ‘:functions’: defines functions.
  183. * ‘:diminish’, ‘:delight’: diminish delight.
  184. * ‘:disabled’: disabled.
  185. * ‘:ensure’, ‘:pin’: ensure pin.
  186. * ‘:hook’: hook.
  187. * ‘:if’, ‘:when’, ‘:unless’: if when unless.
  188. * ‘:load-path’: load-path.
  189. * ‘:mode’, ‘:interpreter’: mode interpreter.
  190. * ‘:magic’, ‘:magic-fallback’: magic magic-fallback.
  191. * ‘:no-require’: no-require.
  192. * ‘:requires’: requires.
  193. 
  194. File: use-package.info, Node: after, Next: bind-keymap bind-keymap*, Up: Keywords
  195. 4.1 ‘:after’
  196. ============
  197. Sometimes it only makes sense to configure a package after another has
  198. been loaded, because certain variables or functions are not in scope
  199. until that time. This can achieved using an ‘:after’ keyword that
  200. allows a fairly rich description of the exact conditions when loading
  201. should occur. Here is an example:
  202. (use-package hydra
  203. :load-path "site-lisp/hydra")
  204. (use-package ivy
  205. :load-path "site-lisp/swiper")
  206. (use-package ivy-hydra
  207. :after (ivy hydra))
  208. In this case, because all of these packages are demand-loaded in the
  209. order they occur, the use of ‘:after’ is not strictly necessary. By
  210. using it, however, the above code becomes order-independent, without an
  211. implicit depedence on the nature of your init file.
  212. By default, ‘:after (foo bar)’ is the same as ‘:after (:all foo
  213. bar)’, meaning that loading of the given package will not happen until
  214. both ‘foo’ and ‘bar’ have been loaded. Here are some of the other
  215. possibilities:
  216. :after (foo bar)
  217. :after (:all foo bar)
  218. :after (:any foo bar)
  219. :after (:all (:any foo bar) (:any baz quux))
  220. :after (:any (:all foo bar) (:all baz quux))
  221. When you nest selectors, such as ‘(:any (:all foo bar) (:all baz
  222. quux))’, it means that the package will be loaded when either both ‘foo’
  223. and ‘bar’ have been loaded, or both ‘baz’ and ‘quux’ have been loaded.
  224. 
  225. File: use-package.info, Node: bind-keymap bind-keymap*, Next: bind bind*, Prev: after, Up: Keywords
  226. 4.2 ‘:bind-keymap’, ‘:bind-keymap*’
  227. ===================================
  228. Normally ‘:bind’ expects that commands are functions that will be
  229. autoloaded from the given package. However, this does not work if one
  230. of those commands is actually a keymap, since keymaps are not functions,
  231. and cannot be autoloaded using Emacs’ ‘autoload’ mechanism.
  232. To handle this case, ‘use-package’ offers a special, limited variant
  233. of ‘:bind’ called ‘:bind-keymap’. The only difference is that the
  234. "commands" bound to by ‘:bind-keymap’ must be keymaps defined in the
  235. package, rather than command functions. This is handled behind the
  236. scenes by generating custom code that loads the package containing the
  237. keymap, and then re-executes your keypress after the first load, to
  238. reinterpret that keypress as a prefix key.
  239. For example:
  240. (use-package projectile
  241. :bind-keymap
  242. ("C-c p" . projectile-command-map)
  243. 
  244. File: use-package.info, Node: bind bind*, Next: commands, Prev: bind-keymap bind-keymap*, Up: Keywords
  245. 4.3 ‘:bind’, ‘:bind*’
  246. =====================
  247. Another common thing to do when loading a module is to bind a key to
  248. primary commands within that module:
  249. (use-package ace-jump-mode
  250. :bind ("C-." . ace-jump-mode))
  251. This does two things: first, it creates an autoload for the
  252. ‘ace-jump-mode’ command and defers loading of ‘ace-jump-mode’ until you
  253. actually use it. Second, it binds the key ‘C-.’ to that command. After
  254. loading, you can use ‘M-x describe-personal-keybindings’ to see all such
  255. keybindings you’ve set throughout your ‘.emacs’ file.
  256. A more literal way to do the exact same thing is:
  257. (use-package ace-jump-mode
  258. :commands ace-jump-mode
  259. :init
  260. (bind-key "C-." 'ace-jump-mode))
  261. When you use the ‘:commands’ keyword, it creates autoloads for those
  262. commands and defers loading of the module until they are used. Since
  263. the ‘:init’ form is always run—even if ‘ace-jump-mode’ might not be on
  264. your system—remember to restrict ‘:init’ code to only what would succeed
  265. either way.
  266. The ‘:bind’ keyword takes either a cons or a list of conses:
  267. (use-package hi-lock
  268. :bind (("M-o l" . highlight-lines-matching-regexp)
  269. ("M-o r" . highlight-regexp)
  270. ("M-o w" . highlight-phrase)))
  271. The ‘:commands’ keyword likewise takes either a symbol or a list of
  272. symbols.
  273. NOTE: Special keys like ‘tab’ or ‘F1’-‘Fn’ can be written in square
  274. brackets, i.e. ‘[tab]’ instead of ‘"tab"’. The syntax for the
  275. keybindings is similar to the "kbd" syntax: see the Emacs Manual
  276. (https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html)
  277. for more information.
  278. Examples:
  279. (use-package helm
  280. :bind (("M-x" . helm-M-x)
  281. ("M-<f5>" . helm-find-files)
  282. ([f10] . helm-buffers-list)
  283. ([S-f10] . helm-recentf)))
  284. * Menu:
  285. * Binding to local keymaps::
  286. 
  287. File: use-package.info, Node: Binding to local keymaps, Up: bind bind*
  288. 4.3.1 Binding to local keymaps
  289. ------------------------------
  290. Slightly different from binding a key to a keymap, is binding a key
  291. *within* a local keymap that only exists after the package is loaded.
  292. ‘use-package’ supports this with a ‘:map’ modifier, taking the local
  293. keymap to bind to:
  294. (use-package helm
  295. :bind (:map helm-command-map
  296. ("C-c h" . helm-execute-persistent-action)))
  297. The effect of this statement is to wait until ‘helm’ has loaded, and
  298. then to bind the key ‘C-c h’ to ‘helm-execute-persistent-action’ within
  299. Helm’s local keymap, ‘helm-mode-map’.
  300. Multiple uses of ‘:map’ may be specified. Any binding occurring
  301. before the first use of ‘:map’ are applied to the global keymap:
  302. (use-package term
  303. :bind (("C-c t" . term)
  304. :map term-mode-map
  305. ("M-p" . term-send-up)
  306. ("M-n" . term-send-down)
  307. :map term-raw-map
  308. ("M-o" . other-window)
  309. ("M-p" . term-send-up)
  310. ("M-n" . term-send-down)))
  311. 
  312. File: use-package.info, Node: commands, Next: preface init config, Prev: bind bind*, Up: Keywords
  313. 4.4 ‘:commands’
  314. ===============
  315. 
  316. File: use-package.info, Node: preface init config, Next: custom, Prev: commands, Up: Keywords
  317. 4.5 ‘:preface’, ‘:init’, ‘:config’
  318. ==================================
  319. Here is the simplest ‘use-package’ declaration:
  320. ;; This is only needed once, near the top of the file
  321. (eval-when-compile
  322. ;; Following line is not needed if use-package.el is in ~/.emacs.d
  323. (add-to-list 'load-path "<path where use-package is installed>")
  324. (require 'use-package))
  325. (use-package foo)
  326. This loads in the package ‘foo’, but only if ‘foo’ is available on
  327. your system. If not, a warning is logged to the ‘*Messages*’ buffer.
  328. If it succeeds, a message about ‘"Loading foo"’ is logged, along with
  329. the time it took to load, if it took over 0.1 seconds.
  330. Use the ‘:init’ keyword to execute code before a package is loaded.
  331. It accepts one or more forms, up until the next keyword:
  332. (use-package foo
  333. :init
  334. (setq foo-variable t))
  335. Similarly, ‘:config’ can be used to execute code after a package is
  336. loaded. In cases where loading is done lazily (see more about
  337. autoloading below), this execution is deferred until after the autoload
  338. occurs:
  339. (use-package foo
  340. :init
  341. (setq foo-variable t)
  342. :config
  343. (foo-mode 1))
  344. As you might expect, you can use ‘:init’ and ‘:config’ together:
  345. (use-package color-moccur
  346. :commands (isearch-moccur isearch-all)
  347. :bind (("M-s O" . moccur)
  348. :map isearch-mode-map
  349. ("M-o" . isearch-moccur)
  350. ("M-O" . isearch-moccur-all))
  351. :init
  352. (setq isearch-lazy-highlight t)
  353. :config
  354. (use-package moccur-edit))
  355. In this case, I want to autoload the commands ‘isearch-moccur’ and
  356. ‘isearch-all’ from ‘color-moccur.el’, and bind keys both at the global
  357. level and within the ‘isearch-mode-map’ (see next section). When the
  358. package is actually loaded (by using one of these commands),
  359. ‘moccur-edit’ is also loaded, to allow editing of the ‘moccur’ buffer.
  360. 
  361. File: use-package.info, Node: custom, Next: custom-face, Prev: preface init config, Up: Keywords
  362. 4.6 ‘:custom’
  363. =============
  364. The ‘:custom’ keyword allows customization of package custom variables.
  365. (use-package comint
  366. :custom
  367. (comint-buffer-maximum-size 20000 "Increase comint buffer size.")
  368. (comint-prompt-read-only t "Make the prompt read only."))
  369. The documentation string is not mandatory.
  370. 
  371. File: use-package.info, Node: custom-face, Next: defer demand, Prev: custom, Up: Keywords
  372. 4.7 ‘:custom-face’
  373. ==================
  374. The ‘:custom-face’ keyword allows customization of package custom faces.
  375. (use-package eruby-mode
  376. :custom-face
  377. (eruby-standard-face ((t (:slant italic)))))
  378. 
  379. File: use-package.info, Node: defer demand, Next: defines functions, Prev: custom-face, Up: Keywords
  380. 4.8 ‘:defer’, ‘:demand’
  381. =======================
  382. In almost all cases you don’t need to manually specify ‘:defer t’. This
  383. is implied whenever ‘:bind’ or ‘:mode’ or ‘:interpreter’ is used.
  384. Typically, you only need to specify ‘:defer’ if you know for a fact that
  385. some other package will do something to cause your package to load at
  386. the appropriate time, and thus you would like to defer loading even
  387. though use-package isn’t creating any autoloads for you.
  388. You can override package deferral with the ‘:demand’ keyword. Thus,
  389. even if you use ‘:bind’, using ‘:demand’ will force loading to occur
  390. immediately and not establish an autoload for the bound key.
  391. 
  392. File: use-package.info, Node: defines functions, Next: diminish delight, Prev: defer demand, Up: Keywords
  393. 4.9 ‘:defines’, ‘:functions’
  394. ============================
  395. Another feature of ‘use-package’ is that it always loads every file that
  396. it can when ‘.emacs’ is being byte-compiled. This helps to silence
  397. spurious warnings about unknown variables and functions.
  398. However, there are times when this is just not enough. For those
  399. times, use the ‘:defines’ and ‘:functions’ keywords to introduce dummy
  400. variable and function declarations solely for the sake of the
  401. byte-compiler:
  402. (use-package texinfo
  403. :defines texinfo-section-list
  404. :commands texinfo-mode
  405. :init
  406. (add-to-list 'auto-mode-alist '("\\.texi$" . texinfo-mode)))
  407. If you need to silence a missing function warning, you can use
  408. ‘:functions’:
  409. (use-package ruby-mode
  410. :mode "\\.rb\\'"
  411. :interpreter "ruby"
  412. :functions inf-ruby-keys
  413. :config
  414. (defun my-ruby-mode-hook ()
  415. (require 'inf-ruby)
  416. (inf-ruby-keys))
  417. (add-hook 'ruby-mode-hook 'my-ruby-mode-hook))
  418. 
  419. File: use-package.info, Node: diminish delight, Next: disabled, Prev: defines functions, Up: Keywords
  420. 4.10 ‘:diminish’, ‘:delight’
  421. ============================
  422. ‘use-package’ also provides built-in support for the diminish and
  423. delight utilities—if you have them installed. Their purpose is to
  424. remove or change minor mode strings in your mode-line.
  425. diminish (https://github.com/myrjola/diminish.el) is invoked with the
  426. ‘:diminish’ keyword, which is passed either a minor mode symbol, a cons
  427. of the symbol and its replacement string, or just a replacement string,
  428. in which case the minor mode symbol is guessed to be the package name
  429. with "-mode" appended at the end:
  430. (use-package abbrev
  431. :diminish abbrev-mode
  432. :config
  433. (if (file-exists-p abbrev-file-name)
  434. (quietly-read-abbrev-file)))
  435. delight (https://elpa.gnu.org/packages/delight.html) is invoked with
  436. the ‘:delight’ keyword, which is passed a minor mode symbol, a
  437. replacement string or quoted mode-line data
  438. (https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Data.html)
  439. (in which case the minor mode symbol is guessed to be the package name
  440. with "-mode" appended at the end), both of these, or several lists of
  441. both. If no arguments are provided, the default mode name is hidden
  442. completely.
  443. ;; Don't show anything for rainbow-mode.
  444. (use-package rainbow-mode
  445. :delight)
  446. ;; Don't show anything for auto-revert-mode, which doesn't match
  447. ;; its package name.
  448. (use-package autorevert
  449. :delight auto-revert-mode)
  450. ;; Remove the mode name for projectile-mode, but show the project name.
  451. (use-package projectile
  452. :delight '(:eval (concat " " (projectile-project-name))))
  453. ;; Completely hide visual-line-mode and change auto-fill-mode to " AF".
  454. (use-package emacs
  455. :delight
  456. (auto-fill-function " AF")
  457. (visual-line-mode))
  458. 
  459. File: use-package.info, Node: disabled, Next: ensure pin, Prev: diminish delight, Up: Keywords
  460. 4.11 ‘:disabled’
  461. ================
  462. The ‘:disabled’ keyword can turn off a module you’re having difficulties
  463. with, or stop loading something you’re not using at the present time:
  464. (use-package ess-site
  465. :disabled
  466. :commands R)
  467. When byte-compiling your ‘.emacs’ file, disabled declarations are
  468. omitted from the output entirely, to accelerate startup times.
  469. 
  470. File: use-package.info, Node: ensure pin, Next: hook, Prev: disabled, Up: Keywords
  471. 4.12 ‘:ensure’, ‘:pin’
  472. ======================
  473. You can use ‘use-package’ to load packages from ELPA with ‘package.el’.
  474. This is particularly useful if you share your ‘.emacs’ among several
  475. machines; the relevant packages are downloaded automatically once
  476. declared in your ‘.emacs’. The ‘:ensure’ keyword causes the package(s)
  477. to be installed automatically if not already present on your system (set
  478. ‘(setq use-package-always-ensure t)’ if you wish this behavior to be
  479. global for all packages):
  480. (use-package magit
  481. :ensure t)
  482. If you need to install a different package from the one named by
  483. ‘use-package’, you can specify it like this:
  484. (use-package tex
  485. :ensure auctex)
  486. Lastly, when running on Emacs 24.4 or later, use-package can pin a
  487. package to a specific archive, allowing you to mix and match packages
  488. from different archives. The primary use-case for this is preferring
  489. packages from the ‘melpa-stable’ and ‘gnu’ archives, but using specific
  490. packages from ‘melpa’ when you need to track newer versions than what is
  491. available in the ‘stable’ archives is also a valid use-case.
  492. By default ‘package.el’ prefers ‘melpa’ over ‘melpa-stable’ due to
  493. the versioning ‘(> evil-20141208.623 evil-1.0.9)’, so even if you are
  494. tracking only a single package from ‘melpa’, you will need to tag all
  495. the non-‘melpa’ packages with the appropriate archive. If this really
  496. annoys you, then you can set ‘use-package-always-pin’ to set a default.
  497. If you want to manually keep a package updated and ignore upstream
  498. updates, you can pin it to ‘manual’, which as long as there is no
  499. repository by that name, will Just Work(tm).
  500. ‘use-package’ throws an error if you try to pin a package to an
  501. archive that has not been configured using ‘package-archives’ (apart
  502. from the magic ‘manual’ archive mentioned above):
  503. Archive 'foo' requested for package 'bar' is not available.
  504. Example:
  505. (use-package company
  506. :ensure t
  507. :pin melpa-stable)
  508. (use-package evil
  509. :ensure t)
  510. ;; no :pin needed, as package.el will choose the version in melpa
  511. (use-package adaptive-wrap
  512. :ensure t
  513. ;; as this package is available only in the gnu archive, this is
  514. ;; technically not needed, but it helps to highlight where it
  515. ;; comes from
  516. :pin gnu)
  517. (use-package org
  518. :ensure t
  519. ;; ignore org-mode from upstream and use a manually installed version
  520. :pin manual)
  521. *NOTE*: the ‘:pin’ argument has no effect on emacs versions < 24.4.
  522. 
  523. File: use-package.info, Node: hook, Next: if when unless, Prev: ensure pin, Up: Keywords
  524. 4.13 ‘:hook’
  525. ============
  526. The ‘:hook’ keyword allows adding functions onto hooks, here only the
  527. basename of the hook is required. Thus, all of the following are
  528. equivalent:
  529. (use-package ace-jump-mode
  530. :hook prog-mode)
  531. (use-package ace-jump-mode
  532. :hook (prog-mode . ace-jump-mode))
  533. (use-package ace-jump-mode
  534. :commands ace-jump-mode
  535. :init
  536. (add-hook 'prog-mode-hook #'ace-jump-mode))
  537. And likewise, when multiple hooks should be applied, the following
  538. are also equivalent:
  539. (use-package ace-jump-mode
  540. :hook (prog-mode text-mode))
  541. (use-package ace-jump-mode
  542. :hook ((prog-mode text-mode) . ace-jump-mode))
  543. (use-package ace-jump-mode
  544. :hook ((prog-mode . ace-jump-mode)
  545. (text-mode . ace-jump-mode)))
  546. (use-package ace-jump-mode
  547. :commands ace-jump-mode
  548. :init
  549. (add-hook 'prog-mode-hook #'ace-jump-mode)
  550. (add-hook 'text-mode-hook #'ace-jump-mode))
  551. The use of ‘:hook’, as with ‘:bind’, ‘:mode’, ‘:interpreter’, etc.,
  552. causes the functions being hooked to implicitly be read as ‘:commands’
  553. (meaning they will establish interactive ‘autoload’ definitions for that
  554. module, if not already defined as functions), and so ‘:defer t’ is also
  555. implied by ‘:hook’.
  556. 
  557. File: use-package.info, Node: if when unless, Next: load-path, Prev: hook, Up: Keywords
  558. 4.14 ‘:if’, ‘:when’, ‘:unless’
  559. ==============================
  560. You can use the ‘:if’ keyword to predicate the loading and
  561. initialization of modules.
  562. For example, I only want ‘edit-server’ running for my main, graphical
  563. Emacs, not for other Emacsen I may start at the command line:
  564. (use-package edit-server
  565. :if window-system
  566. :init
  567. (add-hook 'after-init-hook 'server-start t)
  568. (add-hook 'after-init-hook 'edit-server-start t))
  569. In another example, we can load things conditional on the operating
  570. system:
  571. (use-package exec-path-from-shell
  572. :if (memq window-system '(mac ns))
  573. :ensure t
  574. :config
  575. (exec-path-from-shell-initialize))
  576. Note that ‘:when’ is provided as an alias for ‘:if’, and ‘:unless
  577. foo’ means the same thing as ‘:if (not foo)’.
  578. 
  579. File: use-package.info, Node: load-path, Next: mode interpreter, Prev: if when unless, Up: Keywords
  580. 4.15 ‘:load-path’
  581. =================
  582. If your package needs a directory added to the ‘load-path’ in order to
  583. load, use ‘:load-path’. This takes a symbol, a function, a string or a
  584. list of strings. If the path is relative, it is expanded within
  585. ‘user-emacs-directory’:
  586. (use-package ess-site
  587. :load-path "site-lisp/ess/lisp/"
  588. :commands R)
  589. Note that when using a symbol or a function to provide a dynamically
  590. generated list of paths, you must inform the byte-compiler of this
  591. definition so the value is available at byte-compilation time. This is
  592. done by using the special form ‘eval-and-compile’ (as opposed to
  593. ‘eval-when-compile’). Further, this value is fixed at whatever was
  594. determined during compilation, to avoid looking up the same information
  595. again on each startup:
  596. (eval-and-compile
  597. (defun ess-site-load-path ()
  598. (shell-command "find ~ -path ess/lisp")))
  599. (use-package ess-site
  600. :load-path (lambda () (list (ess-site-load-path)))
  601. :commands R)
  602. 
  603. File: use-package.info, Node: mode interpreter, Next: magic magic-fallback, Prev: load-path, Up: Keywords
  604. 4.16 ‘:mode’, ‘:interpreter’
  605. ============================
  606. Similar to ‘:bind’, you can use ‘:mode’ and ‘:interpreter’ to establish
  607. a deferred binding within the ‘auto-mode-alist’ and
  608. ‘interpreter-mode-alist’ variables. The specifier to either keyword can
  609. be a cons cell, a list of cons cells, or a string or regexp:
  610. (use-package ruby-mode
  611. :mode "\\.rb\\'"
  612. :interpreter "ruby")
  613. ;; The package is "python" but the mode is "python-mode":
  614. (use-package python
  615. :mode ("\\.py\\'" . python-mode)
  616. :interpreter ("python" . python-mode))
  617. If you aren’t using ‘:commands’, ‘:bind’, ‘:bind*’, ‘:bind-keymap’,
  618. ‘:bind-keymap*’, ‘:mode’, or ‘:interpreter’ (all of which imply
  619. ‘:defer’; see the docstring for ‘use-package’ for a brief description of
  620. each), you can still defer loading with the ‘:defer’ keyword:
  621. (use-package ace-jump-mode
  622. :defer t
  623. :init
  624. (autoload 'ace-jump-mode "ace-jump-mode" nil t)
  625. (bind-key "C-." 'ace-jump-mode))
  626. This does exactly the same thing as the following:
  627. (use-package ace-jump-mode
  628. :bind ("C-." . ace-jump-mode))
  629. 
  630. File: use-package.info, Node: magic magic-fallback, Next: no-require, Prev: mode interpreter, Up: Keywords
  631. 4.17 ‘:magic’, ‘:magic-fallback’
  632. ================================
  633. Similar to ‘:mode‘ and ‘:interpreter‘, you can also use ‘:magic‘ and
  634. ‘:magic-fallback‘ to cause certain function to be run if the beginning
  635. of a file matches a given regular expression. The difference between
  636. the two is that ‘:magic-fallback‘ has a lower priority than ‘:mode‘.
  637. For example:
  638. “‘ elisp (use-package pdf-tools :load-path "site-lisp/pdf-tools/lisp"
  639. :magic ("%PDF" . pdf-view-mode) :config (pdf-tools-install)) “‘
  640. This registers an autoloaded command for ‘pdf-view-mode‘, defers
  641. loading of ‘pdf-tools‘, and runs ‘pdf-view-mode‘ if the beginning of a
  642. buffer matches the string ‘"%PDF"‘.
  643. 
  644. File: use-package.info, Node: no-require, Next: requires, Prev: magic magic-fallback, Up: Keywords
  645. 4.18 ‘:no-require’
  646. ==================
  647. Normally, ‘use-package’ will load each package at compile time before
  648. compiling the configuration, to ensure that any necessary symbols are in
  649. scope to satisfy the byte-compiler. At times this can cause problems,
  650. since a package may have special loading requirements, and all that you
  651. want to use ‘use-package’ for is to add a configuration to the
  652. ‘eval-after-load’ hook. In such cases, use the ‘:no-require’ keyword:
  653. (use-package foo
  654. :no-require t
  655. :config
  656. (message "This is evaluated when `foo' is loaded"))
  657. 
  658. File: use-package.info, Node: requires, Prev: no-require, Up: Keywords
  659. 4.19 ‘:requires’
  660. ================
  661. While the ‘:after’ keyword delays loading until the dependencies are
  662. loaded, the somewhat simpler ‘:requires’ keyword simply never loads the
  663. package if the dependencies are not available at the time the
  664. ‘use-package’ declaration is encountered. By "available" in this
  665. context it means that ‘foo’ is available of ‘(featurep 'foo)’ evaulates
  666. to a non-nil value. For example:
  667. (use-package abbrev
  668. :requires foo)
  669. This is the same as:
  670. (use-package abbrev
  671. :if (featurep 'foo))
  672. As a convenience, a list of such packages may be specified:
  673. (use-package abbrev
  674. :requires (foo bar baz))
  675. For more complex logic, such as that supported by ‘:after’, simply
  676. use ‘:if’ and the appropriate Lisp expression.
  677. 
  678. File: use-package.info, Node: FAQ, Next: Debugging Tools, Prev: Keywords, Up: Top
  679. Appendix A FAQ
  680. **************
  681. The next two nodes lists frequently asked questions.
  682. Please also use the *note Debugging Tools::.
  683. * Menu:
  684. * FAQ - How to ...?::
  685. * FAQ - Issues and Errors::
  686. 
  687. File: use-package.info, Node: FAQ - How to ...?, Next: FAQ - Issues and Errors, Up: FAQ
  688. A.1 FAQ - How to ...?
  689. =====================
  690. * Menu:
  691. * This is a question::
  692. 
  693. File: use-package.info, Node: This is a question, Up: FAQ - How to ...?
  694. A.1.1 This is a question
  695. ------------------------
  696. This is an answer.
  697. 
  698. File: use-package.info, Node: FAQ - Issues and Errors, Prev: FAQ - How to ...?, Up: FAQ
  699. A.2 FAQ - Issues and Errors
  700. ===========================
  701. * Menu:
  702. * This is an issues::
  703. 
  704. File: use-package.info, Node: This is an issues, Up: FAQ - Issues and Errors
  705. A.2.1 This is an issues
  706. -----------------------
  707. This is a description.
  708. 
  709. File: use-package.info, Node: Debugging Tools, Next: Command Index, Prev: FAQ, Up: Top
  710. B Debugging Tools
  711. *****************
  712. TODO
  713. Please also see the *note FAQ::.
  714. 
  715. File: use-package.info, Node: Command Index, Next: Function Index, Prev: Debugging Tools, Up: Top
  716. Appendix C Command Index
  717. ************************
  718. 
  719. File: use-package.info, Node: Function Index, Next: Variable Index, Prev: Command Index, Up: Top
  720. Appendix D Function Index
  721. *************************
  722. 
  723. File: use-package.info, Node: Variable Index, Prev: Function Index, Up: Top
  724. Appendix E Variable Index
  725. *************************
  726. 
  727. Tag Table:
  728. Node: Top784
  729. Node: Introduction2819
  730. Node: Installation3306
  731. Node: Installing from an Elpa Archive3658
  732. Node: Installing from the Git Repository4773
  733. Node: Post-Installation Tasks6309
  734. Node: Getting Started7022
  735. Node: Keywords7194
  736. Node: after8113
  737. Node: bind-keymap bind-keymap*9645
  738. Node: bind bind*10698
  739. Node: Binding to local keymaps12738
  740. Node: commands13829
  741. Node: preface init config13971
  742. Node: custom16049
  743. Node: custom-face16489
  744. Node: defer demand16809
  745. Node: defines functions17621
  746. Node: diminish delight18766
  747. Node: disabled20709
  748. Node: ensure pin21204
  749. Node: hook23934
  750. Node: if when unless25352
  751. Node: load-path26298
  752. Node: mode interpreter27444
  753. Node: magic magic-fallback28755
  754. Node: no-require29600
  755. Node: requires30304
  756. Node: FAQ31191
  757. Node: FAQ - How to ...?31474
  758. Node: This is a question31646
  759. Node: FAQ - Issues and Errors31794
  760. Node: This is an issues31977
  761. Node: Debugging Tools32132
  762. Node: Command Index32306
  763. Node: Function Index32462
  764. Node: Variable Index32619
  765. 
  766. End Tag Table
  767. 
  768. Local Variables:
  769. coding: utf-8
  770. End: