mirror of https://github.com/Chizi123/.emacs.d.git

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