packages.el 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. ;;; packages.el --- Emacs packages and interfaces to other package systems
  2. ;; Copyright © 2014–2019 Alex Kost
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;;
  8. ;; This program 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
  11. ;; GNU General Public License for more details.
  12. ;;
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. (require 'al-key)
  16. ;;; Emacs packages
  17. (al/bind-keys
  18. :prefix-map al/package-map
  19. :prefix-docstring "Map for Emacs packages commands."
  20. :prefix "H-q"
  21. ("H-q" . al/quelpa)
  22. ("q" (let (quelpa-update-melpa-p)
  23. (call-interactively #'quelpa)))
  24. ("l" . al/switch-to-packages)
  25. ("a" . al/add-package-archive)
  26. ("r" . al/remove-package-archive))
  27. (with-eval-after-load 'package
  28. (setq package-archives nil)
  29. (al/bind-keys
  30. :map package-menu-mode-map
  31. ("u" . package-menu-describe-package)
  32. ("I" . package-menu-mark-install)
  33. ("D" . package-menu-mark-delete)
  34. ("^" . package-menu-mark-upgrades)
  35. ("z" . package-menu-mark-unmark)))
  36. (setq
  37. quelpa-upgrade-p t
  38. ;; Quelpa dirs are used in several places of my config.
  39. quelpa-dir (al/emacs-data-dir-file "quelpa")
  40. quelpa-build-dir (expand-file-name "build" quelpa-dir))
  41. (with-eval-after-load 'al-quelpa
  42. (defun al/emacs-repo (name)
  43. "Return git url of a repository with my package NAME."
  44. (concat "https://gitlab.com/alezost-emacs/" name ".git"))
  45. (setq
  46. al/main-packages
  47. `((quelpa :fetcher github :repo "quelpa/quelpa")
  48. (mwim :fetcher git :url ,(al/emacs-repo "mwim"))
  49. (alect-themes :fetcher git :url ,(al/emacs-repo "alect-themes"))
  50. (dvorak-layouts :fetcher git :url ,(al/emacs-repo "dvorak-layouts"))
  51. (dim :fetcher git :url ,(al/emacs-repo "dim"))
  52. (insert-pair :fetcher git :url ,(al/emacs-repo "insert-pair"))
  53. (imenus :fetcher git :url ,(al/emacs-repo "imenus"))
  54. smex
  55. smartparens
  56. elisp-slime-nav
  57. hydra
  58. (yasnippet :fetcher github :repo "capitaomorte/yasnippet"
  59. :files ("yasnippet.el"))
  60. github-browse-file
  61. (shift-number :fetcher git :url ,(al/emacs-repo "shift-number"))
  62. (pathify :fetcher git :url ,(al/emacs-repo "pathify"))
  63. (point-pos :fetcher git :url ,(al/emacs-repo "point-pos"))
  64. (web-search :fetcher git :url ,(al/emacs-repo "web-search"))
  65. (text-search :fetcher git :url ,(al/emacs-repo "text-search"))
  66. (echo-msk :fetcher git :url ,(al/emacs-repo "echo-msk"))
  67. (darts-value :fetcher git :url ,(al/emacs-repo "darts-value"))
  68. (debpaste :fetcher git :url ,(al/emacs-repo "debpaste"))
  69. (aurel :fetcher git :url ,(al/emacs-repo "aurel"))
  70. (make-color :fetcher git :url ,(al/emacs-repo "make-color"))
  71. (pretty-sha-path :fetcher git :url ,(al/emacs-repo "pretty-sha-path"))
  72. (date-at-point :fetcher git :url ,(al/emacs-repo "date-at-point"))
  73. (journal :fetcher git :url ,(al/emacs-repo "journal"))
  74. pcmpl-args
  75. org-pdfview
  76. org-emms
  77. (dictem :fetcher github :repo "cheusov/dictem")
  78. google-translate
  79. (emms-state :fetcher git :url ,(al/emacs-repo "emms-state"))
  80. emms-player-simple-mpv
  81. browse-kill-ring
  82. outline-magic
  83. markdown-mode
  84. syslog-mode
  85. list-environment
  86. (mysql :fetcher github :repo "haxney/mysql")
  87. (sql-completion :fetcher github :repo "emacsmirror/sql-completion")
  88. sauron
  89. erc-hl-nicks
  90. (erc-view-log :fetcher github :repo "alezost/erc-view-log"
  91. :branch "general-regexps")
  92. hl-todo)
  93. al/extra-packages
  94. `(indent-guide
  95. mentor
  96. pkgbuild-mode
  97. ;; With the MELPA's 'magit' package recipe, magit repo will be
  98. ;; downloaded 4 times to build the magit package itself and its
  99. ;; dependencies (git-commit, magit-popup and with-editor). So
  100. ;; install everything in one piece.
  101. (magit :fetcher github :repo "magit/magit"
  102. :files ("lisp/*.el" "Documentation/*.texi"))
  103. (rainbow-mode :fetcher url :url "http://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/packages/rainbow-mode/rainbow-mode.el")
  104. (sunrise-commander :fetcher github :repo "escherdragon/sunrise-commander")
  105. (typing-practice :fetcher url :url "https://raw.github.com/mebubo/dotfiles/master/.emacs.d/site-lisp/typing-practice.el")
  106. (mana :fetcher git :url ,(al/emacs-repo "mana"))
  107. (ducpel :fetcher git :url ,(al/emacs-repo "ducpel")
  108. :files ("*.el"))
  109. typing-game
  110. (sokoban :fetcher github :repo "leoliu/sokoban"
  111. :files ("*.el" "sokoban.levels")))))
  112. ;;; Guix
  113. (setq guix-current-profile al/guix-user-profile-dir)
  114. (let ((dir (al/devel-dir-file "guix")))
  115. (when (file-exists-p dir)
  116. (setq guix-load-path dir)))
  117. (al/bind-key "H-x" guix)
  118. (al/bind-keys
  119. :prefix-map al/guix-map
  120. :prefix-docstring "Map for guix."
  121. :prefix "H-M-x"
  122. ("H-x" . guix)
  123. ("f" . build-farm)
  124. ("e" . guix-edit)
  125. ("b" . guix-switch-to-buffer)
  126. ("P" . guix-prettify-mode)
  127. ("z" . guix-switch-to-repl)
  128. ("C-n" . guix-packages-by-name)
  129. ("n" . guix-search-by-name)
  130. ("r" . guix-search-by-regexp)
  131. ("A" . guix-all-packages)
  132. ("N" . guix-newest-packages)
  133. ("I" . guix-installed-packages)
  134. ("O" . guix-obsolete-packages)
  135. ("G" . guix-generations)
  136. ("a" . guix-about)
  137. ("h" . guix-help)
  138. ("H" . guix-hash)
  139. ("p" . guix-profiles)
  140. ("H-p" . guix-set-current-profile)
  141. ("i" (al/display-buffer (guix-package-info-buffer-name
  142. guix-current-profile)))
  143. ("<ctrl-i>" (al/display-buffer (guix-generation-info-buffer-name
  144. guix-current-profile)))
  145. ("l" (al/display-buffer (guix-package-list-buffer-name
  146. guix-current-profile)))
  147. ("C-l" (al/display-buffer (guix-generation-list-buffer-name
  148. guix-current-profile)))
  149. ("u" . al/guix-commit-url))
  150. (defconst al/guix-list-keys
  151. '(("i" . bui-list-describe)
  152. ("S" . guix-package-list-size))
  153. "Alist of auxiliary keys for guix list maps.")
  154. (defconst al/guix-list-key-vars
  155. '(al/lazy-moving-keys
  156. al/tabulated-list-keys
  157. al/bui-list-keys
  158. al/guix-list-keys))
  159. (with-eval-after-load 'guix-external
  160. (setq guix-guile-program "guile"))
  161. (with-eval-after-load 'guix-repl
  162. (when (require 'al-geiser nil t)
  163. (defun al/geiser-add-guix-socket ()
  164. (cl-pushnew guix-repl-current-socket al/geiser-sockets
  165. :test #'string=))
  166. (add-hook 'guix-repl-after-start-hook 'al/geiser-add-guix-socket)
  167. (remove-hook 'guix-repl-after-operation-hook
  168. 'guix-repl-autoload-emacs-packages-maybe)))
  169. (with-eval-after-load 'guix-misc
  170. (setq
  171. guix-operation-option-separator " │ ")
  172. (when (display-graphic-p)
  173. (setq
  174. guix-operation-option-false-string "☐"
  175. guix-operation-option-true-string "☑")))
  176. (with-eval-after-load 'guix-ui
  177. (defconst al/guix-ui-keys
  178. '(("M-P" (message "%s" (guix-ui-current-profile))))
  179. "Alist of auxiliary keys for `guix-ui-map'.")
  180. (al/bind-keys-from-vars 'guix-ui-map 'al/guix-ui-keys t))
  181. (with-eval-after-load 'guix-ui-package
  182. (setq
  183. guix-package-list-type 'package)
  184. (defconst al/guix-package-info-keys
  185. '(("M-d" . guix-package-info-edit)
  186. ("I" . guix-package-info-install)
  187. ("D" . guix-package-info-delete)
  188. ("U" . guix-package-info-upgrade)
  189. ("S" . guix-package-info-size))
  190. "Alist of auxiliary keys for `guix-package-info-mode-map'.")
  191. (defconst al/guix-package-list-keys
  192. '(("M-d" . guix-package-list-edit)
  193. ("I" . guix-package-list-mark-install)
  194. ("D" . guix-package-list-mark-delete)
  195. ("U" . guix-package-list-mark-upgrade))
  196. "Alist of auxiliary keys for `guix-package-list-mode-map'.")
  197. (defconst al/guix-output-list-keys
  198. '(("M-d" . guix-output-list-edit)
  199. ("I" . guix-output-list-mark-install)
  200. ("D" . guix-output-list-mark-delete)
  201. ("U" . guix-output-list-mark-upgrade))
  202. "Alist of auxiliary keys for `guix-output-list-mode-map'.")
  203. (al/bind-keys-from-vars 'guix-package-info-mode-map
  204. '(al/button-keys al/guix-package-info-keys)
  205. t)
  206. (al/bind-keys-from-vars 'guix-package-list-mode-map
  207. (append al/guix-list-key-vars '(al/guix-package-list-keys))
  208. t)
  209. (al/bind-keys-from-vars 'guix-output-list-mode-map
  210. (append al/guix-list-key-vars '(al/guix-output-list-keys))
  211. t))
  212. (with-eval-after-load 'guix-ui-generation
  213. (setq
  214. guix-generation-list-show-single t
  215. guix-generation-packages-update-buffer nil
  216. guix-generation-output-name-width 40)
  217. (defconst al/guix-generation-list-keys
  218. '(("E" . guix-generation-list-ediff)
  219. ("D" . guix-generation-list-mark-delete))
  220. "Alist of auxiliary keys for `guix-generation-list-mode-map'.")
  221. (al/bind-keys-from-vars 'guix-generation-list-mode-map
  222. (append al/guix-list-key-vars '(al/guix-generation-list-keys))
  223. t))
  224. (with-eval-after-load 'guix-ui-service
  225. (defconst al/guix-service-info-keys
  226. '(("M-d" . guix-service-info-edit))
  227. "Alist of auxiliary keys for `guix-service-info-mode-map'.")
  228. (defconst al/guix-service-list-keys
  229. '(("M-d" . guix-service-list-edit))
  230. "Alist of auxiliary keys for `guix-service-list-mode-map'.")
  231. (al/bind-keys-from-vars 'guix-service-info-mode-map
  232. '(al/button-keys al/guix-service-info-keys)
  233. t)
  234. (al/bind-keys-from-vars 'guix-service-list-mode-map
  235. (append al/guix-list-key-vars '(al/guix-service-list-keys))
  236. t))
  237. (with-eval-after-load 'guix-ui-package-location
  238. (defconst al/guix-package-location-list-keys
  239. '(("M-d" . guix-package-location-list-edit))
  240. "Alist of auxiliary keys for `guix-package-location-list-mode-map'.")
  241. (al/bind-keys-from-vars 'guix-package-location-list-mode-map
  242. (append al/guix-list-key-vars '(al/guix-package-location-list-keys))
  243. t))
  244. (with-eval-after-load 'guix-ui-service-location
  245. (defconst al/guix-service-location-list-keys
  246. '(("M-d" . guix-service-location-list-edit))
  247. "Alist of auxiliary keys for `guix-service-location-list-mode-map'.")
  248. (al/bind-keys-from-vars 'guix-service-location-list-mode-map
  249. (append al/guix-list-key-vars '(al/guix-service-location-list-keys))
  250. t))
  251. (with-eval-after-load 'guix-ui-license
  252. (defconst al/guix-license-list-keys
  253. '(("M-d" . guix-license-list-edit))
  254. "Alist of auxiliary keys for `guix-license-list-mode-map'.")
  255. (al/bind-keys-from-vars 'guix-license-list-mode-map
  256. (append al/guix-list-key-vars '(al/guix-license-list-keys))
  257. t))
  258. (with-eval-after-load 'guix-ui-store-item
  259. (defconst al/guix-store-item-list-keys
  260. '("R"
  261. ("M-d" . guix-store-item-list-edit)
  262. ("r" . guix-store-item-list-requisites)
  263. ("d" . guix-store-item-list-derivers)
  264. ("D" . guix-store-item-list-mark-delete))
  265. "Alist of auxiliary keys for `guix-store-item-list-mode-map'.")
  266. (al/bind-keys-from-vars 'guix-store-item-list-mode-map
  267. (append al/guix-list-key-vars '(al/guix-store-item-list-keys))
  268. t))
  269. (with-eval-after-load 'guix-ui-profile
  270. (setq guix-profiles
  271. (append guix-profiles
  272. (al/guix-profiles))))
  273. (with-eval-after-load 'guix-utils
  274. (setq
  275. guix-find-file-function #'org-open-file))
  276. (al/add-after-init-hook 'global-guix-prettify-mode)
  277. (with-eval-after-load 'guix-build-log
  278. (setq guix-build-log-minor-mode-activate nil)
  279. (defconst al/guix-build-log-common-keys
  280. '(("M-." . guix-build-log-previous-phase)
  281. ("M-e" . guix-build-log-next-phase))
  282. "Alist of auxiliary keys for `guix-build-log-common-map'.")
  283. (defconst al/guix-build-log-keys
  284. '(("C-c c" . compilation-shell-minor-mode))
  285. "Alist of auxiliary keys for `guix-build-log-mode-map'.")
  286. (al/bind-keys-from-vars 'guix-build-log-common-map
  287. 'al/guix-build-log-common-keys)
  288. (al/bind-keys-from-vars 'guix-build-log-mode-map
  289. 'al/guix-build-log-keys t))
  290. (with-eval-after-load 'guix-popup
  291. ;; Use "P" for packages and "p" for profiles.
  292. (magit-change-popup-key 'guix-popup :action ?p ?–)
  293. (magit-change-popup-key 'guix-popup :action ?P ?p)
  294. (magit-change-popup-key 'guix-popup :action ?– ?P)
  295. (when (require 'al-magit-popup nil t)
  296. (al/magit-add-popup-keys
  297. 'guix-popup :action
  298. '((?z "switch to REPL" guix-switch-to-repl)
  299. (?u "browse commit URL" al/guix-commit-url)
  300. (?f "build farm" build-farm)))))
  301. ;;; Aurel
  302. (al/bind-keys
  303. :prefix-map al/aurel-map
  304. :prefix-docstring "Map for aurel."
  305. :prefix "C-H-a"
  306. ("i" . al/switch-to-aurel-info)
  307. ("l" . al/switch-to-aurel-list)
  308. ("C-n" . aurel-package-info)
  309. ("p" . aurel-package-search)
  310. ("n" . aurel-package-search)
  311. ("m" . aurel-maintainer-search)
  312. ("I" . aurel-installed-packages))
  313. (with-eval-after-load 'aurel
  314. (setq
  315. aurel-download-directory (al/src-dir-file "abs")
  316. aurel-aur-user-name "alezost"
  317. aurel-aur-user-package-info-check t
  318. aurel-info-aur-user-string "——————————————————————————————————————\n"
  319. aurel-info-installed-package-string aurel-info-aur-user-string
  320. aurel-debug-level 9
  321. aurel-list-format
  322. '((name aurel-list-get-name 20 t)
  323. (version nil 9 t)
  324. (installed-version nil 9 t)
  325. (maintainer aurel-list-get-maintainer 13 t)
  326. (votes nil 8 bui-list-sort-numerically-4 :right-align t)
  327. (description nil 30 nil))
  328. aurel-list-titles
  329. '((votes . "V.")
  330. (version . "Ver.")
  331. (installed-version . "Inst.")))
  332. (defconst al/aurel-filter-keys
  333. ;; Default `aurel-enable-filter' was left for backward compatibility.
  334. '(("f" . bui-enable-filter))
  335. "Alist of auxiliary keys for `aurel-filter-map'.")
  336. (al/bind-keys-from-vars 'aurel-filter-map 'al/aurel-filter-keys))
  337. ;;; packages.el ends here