Klimi's new dotfiles with stow.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

175 rader
6.8 KiB

5 år sedan
  1. ;;; helm-config.el --- Applications library for `helm.el' -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
  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. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Code:
  14. ;;; Require
  15. ;;
  16. ;;
  17. (declare-function async-bytecomp-package-mode "ext:async-bytecomp.el")
  18. (when (require 'async-bytecomp nil t)
  19. (and (fboundp 'async-bytecomp-package-mode)
  20. (async-bytecomp-package-mode 1)))
  21. (defgroup helm-config nil
  22. "Various configurations for Helm."
  23. :group 'helm)
  24. (defcustom helm-command-prefix-key "C-x c"
  25. "The key `helm-command-prefix' is bound to in the global map."
  26. :type '(choice (string :tag "Key") (const :tag "no binding"))
  27. :group 'helm-config
  28. :set
  29. (lambda (var key)
  30. (when (and (boundp var) (symbol-value var))
  31. (define-key (current-global-map)
  32. (read-kbd-macro (symbol-value var)) nil))
  33. (when key
  34. (define-key (current-global-map)
  35. (read-kbd-macro key) 'helm-command-prefix))
  36. (set var key)))
  37. (defcustom helm-minibuffer-history-key "C-r"
  38. "The key `helm-minibuffer-history' is bound to in minibuffer local maps."
  39. :type '(choice (string :tag "Key") (const :tag "no binding"))
  40. :group 'helm-config
  41. :set
  42. (lambda (var key)
  43. (cl-dolist (map '(minibuffer-local-completion-map
  44. minibuffer-local-filename-completion-map
  45. minibuffer-local-filename-must-match-map ; Emacs 23.1.+
  46. minibuffer-local-isearch-map
  47. minibuffer-local-map
  48. minibuffer-local-must-match-filename-map ; Older Emacsen
  49. minibuffer-local-must-match-map
  50. minibuffer-local-ns-map))
  51. (let ((vmap (symbol-value map)))
  52. (when (and (boundp map) (keymapp vmap))
  53. (helm-aif (and (boundp var) (symbol-value var))
  54. (define-key vmap
  55. (if (stringp it) (read-kbd-macro it) it)
  56. nil))
  57. (when key
  58. (define-key (symbol-value map)
  59. (if (stringp key) (read-kbd-macro key) key)
  60. 'helm-minibuffer-history)))))
  61. (set var key)))
  62. ;;; Command Keymap
  63. ;;
  64. ;;
  65. (defvar helm-command-map
  66. (let ((map (make-sparse-keymap)))
  67. (define-key map (kbd "a") 'helm-apropos)
  68. (define-key map (kbd "e") 'helm-etags-select)
  69. (define-key map (kbd "l") 'helm-locate)
  70. (define-key map (kbd "s") 'helm-surfraw)
  71. (define-key map (kbd "r") 'helm-regexp)
  72. (define-key map (kbd "m") 'helm-man-woman)
  73. (define-key map (kbd "t") 'helm-top)
  74. (define-key map (kbd "/") 'helm-find)
  75. (define-key map (kbd "i") 'helm-semantic-or-imenu)
  76. (define-key map (kbd "I") 'helm-imenu-in-all-buffers)
  77. (define-key map (kbd "<tab>") 'helm-lisp-completion-at-point)
  78. (define-key map (kbd "p") 'helm-list-emacs-process)
  79. (define-key map (kbd "C-x r b") 'helm-filtered-bookmarks)
  80. (define-key map (kbd "M-y") 'helm-show-kill-ring)
  81. (define-key map (kbd "C-c <SPC>") 'helm-all-mark-rings)
  82. (define-key map (kbd "C-x C-f") 'helm-find-files)
  83. (define-key map (kbd "f") 'helm-multi-files)
  84. (define-key map (kbd "C-:") 'helm-eval-expression-with-eldoc)
  85. (define-key map (kbd "C-,") 'helm-calcul-expression)
  86. (define-key map (kbd "M-x") 'helm-M-x)
  87. (define-key map (kbd "M-s o") 'helm-occur)
  88. (define-key map (kbd "M-g a") 'helm-do-grep-ag)
  89. (define-key map (kbd "c") 'helm-colors)
  90. (define-key map (kbd "F") 'helm-select-xfont)
  91. (define-key map (kbd "8") 'helm-ucs)
  92. (define-key map (kbd "C-c f") 'helm-recentf)
  93. (define-key map (kbd "C-c g") 'helm-google-suggest)
  94. (define-key map (kbd "h i") 'helm-info-at-point)
  95. (define-key map (kbd "h r") 'helm-info-emacs)
  96. (define-key map (kbd "h g") 'helm-info-gnus)
  97. (define-key map (kbd "h h") 'helm-documentation)
  98. (define-key map (kbd "C-x C-b") 'helm-buffers-list)
  99. (define-key map (kbd "C-x r i") 'helm-register)
  100. (define-key map (kbd "C-c C-x") 'helm-run-external-command)
  101. (define-key map (kbd "b") 'helm-resume)
  102. (define-key map (kbd "M-g i") 'helm-gid)
  103. (define-key map (kbd "@") 'helm-list-elisp-packages)
  104. map))
  105. ;; Don't override the keymap we just defined with an empty
  106. ;; keymap. This also protect bindings changed by the user.
  107. (defvar helm-command-prefix)
  108. (define-prefix-command 'helm-command-prefix)
  109. (fset 'helm-command-prefix helm-command-map)
  110. (setq helm-command-prefix helm-command-map)
  111. ;;; Menu
  112. (require 'helm-easymenu)
  113. ;;;###autoload
  114. (defun helm-configuration ()
  115. "Customize `helm'."
  116. (interactive)
  117. (customize-group "helm"))
  118. ;;; Fontlock
  119. (cl-dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
  120. (font-lock-add-keywords
  121. mode
  122. '(("(\\<\\(with-helm-after-update-hook\\)\\>" 1 font-lock-keyword-face)
  123. ("(\\<\\(with-helm-temp-hook\\)\\>" 1 font-lock-keyword-face)
  124. ("(\\<\\(with-helm-window\\)\\>" 1 font-lock-keyword-face)
  125. ("(\\<\\(with-helm-quittable\\)\\>" 1 font-lock-keyword-face)
  126. ("(\\<\\(with-helm-current-buffer\\)\\>" 1 font-lock-keyword-face)
  127. ("(\\<\\(with-helm-buffer\\)\\>" 1 font-lock-keyword-face)
  128. ("(\\<\\(with-helm-show-completion\\)\\>" 1 font-lock-keyword-face)
  129. ("(\\<\\(with-helm-default-directory\\)\\>" 1 font-lock-keyword-face)
  130. ("(\\<\\(with-helm-restore-variables\\)\\>" 1 font-lock-keyword-face)
  131. ("(\\<\\(helm-multi-key-defun\\)\\>" 1 font-lock-keyword-face)
  132. ("(\\<\\(helm-while-no-input\\)\\>" 1 font-lock-keyword-face)
  133. ("(\\<\\(helm-aif\\)\\>" 1 font-lock-keyword-face)
  134. ("(\\<\\(helm-awhile\\)\\>" 1 font-lock-keyword-face)
  135. ("(\\<\\(helm-acond\\)\\>" 1 font-lock-keyword-face)
  136. ("(\\<\\(helm-aand\\)\\>" 1 font-lock-keyword-face)
  137. ("(\\<\\(helm-with-gensyms\\)\\>" 1 font-lock-keyword-face)
  138. ("(\\<\\(helm-read-answer\\)\\>" 1 font-lock-keyword-face))))
  139. ;;; Load the autoload file
  140. ;; It should have been generated either by
  141. ;; package.el or the make file.
  142. (load "helm-autoloads" nil t)
  143. (provide 'helm-config)
  144. ;; Local Variables:
  145. ;; byte-compile-warnings: (not obsolete)
  146. ;; coding: utf-8
  147. ;; indent-tabs-mode: nil
  148. ;; End:
  149. ;;; helm-config.el ends here