Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
5.5 KiB

  1. ;;; prelude-helm.el --- Helm setup
  2. ;;
  3. ;; Copyright © 2011-2014 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Some config for Helm that follows thiks guide: http://tuhdo.github.io/helm-intro.html
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. (prelude-require-packages '(helm helm-projectile helm-descbinds))
  29. (require 'helm)
  30. ;; must set before helm-config, otherwise helm use default
  31. ;; prefix "C-x c", which is inconvenient because you can
  32. ;; accidentially pressed "C-x C-c"
  33. (setq helm-command-prefix-key "C-c h")
  34. (require 'helm-config)
  35. (require 'helm-eshell)
  36. (require 'helm-files)
  37. (require 'helm-grep)
  38. (define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebihnd tab to do persistent action
  39. (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
  40. (define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
  41. (define-key helm-grep-mode-map (kbd "<return>") 'helm-grep-mode-jump-other-window)
  42. (define-key helm-grep-mode-map (kbd "n") 'helm-grep-mode-jump-other-window-forward)
  43. (define-key helm-grep-mode-map (kbd "p") 'helm-grep-mode-jump-other-window-backward)
  44. (setq
  45. helm-google-suggest-use-curl-p t
  46. helm-scroll-amount 4 ; scroll 4 lines other window using M-<next>/M-<prior>
  47. helm-quick-update t ; do not display invisible candidates
  48. helm-idle-delay 0.01 ; be idle for this many seconds, before updating in delayed sources.
  49. helm-input-idle-delay 0.01 ; be idle for this many seconds, before updating candidate buffer
  50. helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
  51. helm-split-window-default-side 'other ;; open helm buffer in another window
  52. helm-split-window-in-side-p t ;; open helm buffer inside current window, not occupy whole other window
  53. helm-buffers-favorite-modes (append helm-buffers-favorite-modes
  54. '(picture-mode artist-mode))
  55. helm-candidate-number-limit 500 ; limit the number of displayed canidates
  56. helm-M-x-requires-pattern 0 ; show all candidates when set to 0
  57. helm-ff-file-name-history-use-recentf t
  58. helm-move-to-line-cycle-in-source t ; move to end or beginning of source
  59. ; when reaching top or bottom of source.
  60. ido-use-virtual-buffers t ; Needed in helm-buffers-list
  61. helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non-nil
  62. ; useful in helm-mini that lists buffers
  63. )
  64. (global-set-key (kbd "C-c h o") 'helm-occur)
  65. (global-set-key (kbd "C-c h g") 'helm-do-grep)
  66. (global-set-key (kbd "C-c h C-c w") 'helm-wikipedia-suggest)
  67. (global-set-key (kbd "C-c h x") 'helm-register)
  68. (global-set-key (kbd "C-c h SPC") 'helm-all-mark-rings)
  69. ;;; Save current position to mark ring
  70. (add-hook 'helm-goto-line-before-hook 'helm-save-current-pos-to-mark-ring)
  71. (defvar prelude-global-helm-mode-map
  72. (let ((map (make-sparse-keymap)))
  73. (define-key map (kbd "M-x") 'helm-M-x)
  74. (define-key map (kbd "M-y") 'helm-show-kill-ring)
  75. (define-key map (kbd "C-x b") 'helm-mini)
  76. (define-key map (kbd "C-x C-f") 'helm-find-files)
  77. (define-key map (kbd "C-h C-f") 'helm-apropos)
  78. (define-key map (kbd "C-h r") 'helm-info-emacs)
  79. (define-key map (kbd "C-h C-l") 'helm-locate-library)
  80. map)
  81. "Keymap for Helm to replace standard Prelude's commands")
  82. (define-minor-mode prelude-global-helm-minor-mode
  83. "Minor mode to replace Prelude default commands with \\{prelude-global-helm-map}"
  84. :keymap prelude-global-helm-mode-map
  85. (progn
  86. ;; show minibuffer history with Helm
  87. (define-key minibuffer-local-map (kbd "M-l") 'helm-minibuffer-history)
  88. (define-key global-map [remap find-tag] 'helm-etags-select)
  89. (define-key global-map [remap list-buffers] 'helm-mini)
  90. ;; shell history.
  91. (define-key shell-mode-map (kbd "M-l") 'helm-comint-input-ring)
  92. ;; use helm to list eshell history
  93. (add-hook 'eshell-mode-hook
  94. #'(lambda ()
  95. (define-key eshell-mode-map (kbd "M-l") 'helm-eshell-history)))))
  96. (define-globalized-minor-mode prelude-global-helm-global-mode prelude-global-helm-minor-mode prelude-global-helm-global-mode-on)
  97. (defun prelude-global-helm-global-mode-on ()
  98. "Turn on `prelude-global-helm-minor-mode'"
  99. (prelude-global-helm-minor-mode +1)
  100. )
  101. (defun prelude-global-helm-global-mode-off ()
  102. "Turn off `prelude-global-helm-minor-mode'"
  103. (prelude-global-helm-minor-mode -1))
  104. (helm-mode 1)
  105. ;; PACKAGE: helm-projectile
  106. (require 'helm-projectile)
  107. (setq projectile-completion-system 'helm)
  108. (push "Press <C-c p h> to navigate a project in Helm." prelude-tips)
  109. ;; PACKAGE: helm-descbinds
  110. (require 'helm-descbinds)
  111. (helm-descbinds-mode)
  112. (provide 'prelude-helm)
  113. ;;; prelude-helm.el ends here