From a8f898fecd0694ccbd5dcd4eeb8cafa2b79c8812 Mon Sep 17 00:00:00 2001 From: Keyvan Hedayati <k.hedayati@parspooyesh.com> Date: Tue, 26 Aug 2014 09:45:55 +0430 Subject: [PATCH 1/5] Added some forgotten keys to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 39bb565..1758cc9 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,9 @@ Keybinding | Description <kbd>F11</kbd> | Make the window full screen. <kbd>F12</kbd> | Toggle the Emacs menu bar. <kbd>C-x g</kbd> | Open Magit's status buffer. +<kbd>M-Z</kbd> | Zap up to char +<kbd>C-c J</kbd> | Open the buffer menu and go to the selected buffer in the current window. +<kbd>Super-></kbd> | Open the buffer menu and go to the selected buffer in the current window. <kbd>C-=</kbd> | Run `expand-region` (incremental text selection). <kbd>C-a</kbd> | Run `prelude-move-beginning-of-line`. Read [this](http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/) for details. From 34103f98c0d87e16a72557fcab65d1d7c75cc960 Mon Sep 17 00:00:00 2001 From: Keyvan Hedayati <k.hedayati@parspooyesh.com> Date: Tue, 26 Aug 2014 16:04:28 +0430 Subject: [PATCH 2/5] Fixed some mistakes in README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1758cc9..da1ef32 100644 --- a/README.md +++ b/README.md @@ -265,9 +265,8 @@ Keybinding | Description <kbd>F11</kbd> | Make the window full screen. <kbd>F12</kbd> | Toggle the Emacs menu bar. <kbd>C-x g</kbd> | Open Magit's status buffer. -<kbd>M-Z</kbd> | Zap up to char -<kbd>C-c J</kbd> | Open the buffer menu and go to the selected buffer in the current window. -<kbd>Super-></kbd> | Open the buffer menu and go to the selected buffer in the current window. +<kbd>M-Z</kbd> | Zap up to char. +<kbd>C-c J</kbd> or <kbd>Super-></kbd> | Switch between buffers with [`ace-jump-buffer`](https://github.com/waymondo/ace-jump-buffer) <kbd>C-=</kbd> | Run `expand-region` (incremental text selection). <kbd>C-a</kbd> | Run `prelude-move-beginning-of-line`. Read [this](http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/) for details. From bde6bb0d37eeeb68b76e305aee1636d037f664e4 Mon Sep 17 00:00:00 2001 From: "Tu, Do" <tuhdo1710@gmail.com> Date: Sat, 30 Aug 2014 14:03:31 +0700 Subject: [PATCH 3/5] Improve Helm configuration The current prelude-helm only uses a single command of Helm, which is a waste given how Helm contains many other commands. When prelude-helm is activated, users should be able to utilize all of these useful commands. If a user wants to use Helm, he will want to use all of its features anyway. prelude-helm is configured that it is able to be used with this [guide](http://tuhdo.github.io/helm-intro.html). --- README.md | 9 +++- modules/prelude-helm.el | 102 ++++++++++++++++++++++++++++++++-------- 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ba875e2..5e5fc57 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,6 @@ Keybinding | Description <kbd>C-c t</kbd> | Open a terminal emulator (`ansi-term`). <kbd>C-c k</kbd> | Kill all open buffers except the one you're currently in. <kbd>C-c TAB</kbd> | Indent and copy region to clipboard -<kbd>C-c h</kbd> | Open Helm (available if you've enabled the `prelude-helm` module). <kbd>C-c I</kbd> | Open user's init file. <kbd>C-c S</kbd> | Open shell's init file. <kbd>C-c . +</kbd> | Increment integer at point. Default is +1. @@ -369,6 +368,14 @@ If you ever forget any of Projectile's keybindings just do a: <kbd>C-c p C-h</kbd> +#### Helm + +Helm is setup according to this guide: [A Package in a league of its own: Helm](http://tuhdo.github.io/helm-intro.html). + +You can learn Helm usage and key bindings following the guide. <kbd>C-c h</kbd> +is Prelude's default prefix key for Helm. If you don't remember any key binding, +append <kbd>C-h</kbd> after <kbd>C-c h</kbd> for a list of key bindings in Helm. + #### Key-chords **Key-chords are available only when the `prelude-key-chord` module has been enabled.** diff --git a/modules/prelude-helm.el b/modules/prelude-helm.el index 2033def..ec2d0a4 100644 --- a/modules/prelude-helm.el +++ b/modules/prelude-helm.el @@ -32,30 +32,92 @@ ;;; Code: -(prelude-require-packages '(helm helm-projectile)) +(prelude-require-packages '(helm helm-projectile helm-descbinds)) + +(require 'helm) + +;; must set before helm-config, otherwise helm use default +;; prefix "C-x c", which is inconvenient because you can +;; accidentially pressed "C-x C-c" +(setq helm-command-prefix-key "C-c h") + +(require 'helm-config) +(require 'helm-eshell) +(require 'helm-files) +(require 'helm-grep) + +(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebihnd tab to do persistent action +(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal +(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z + +(define-key helm-grep-mode-map (kbd "<return>") 'helm-grep-mode-jump-other-window) +(define-key helm-grep-mode-map (kbd "n") 'helm-grep-mode-jump-other-window-forward) +(define-key helm-grep-mode-map (kbd "p") 'helm-grep-mode-jump-other-window-backward) + +(setq + helm-google-suggest-use-curl-p t + helm-scroll-amount 4 ; scroll 4 lines other window using M-<next>/M-<prior> + helm-quick-update t ; do not display invisible candidates + helm-idle-delay 0.01 ; be idle for this many seconds, before updating in delayed sources. + helm-input-idle-delay 0.01 ; be idle for this many seconds, before updating candidate buffer + helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp. + helm-split-window-default-side 'other ;; open helm buffer in another window + helm-split-window-in-side-p t ;; open helm buffer inside current window, not occupy whole other window + helm-buffers-favorite-modes (append helm-buffers-favorite-modes + '(picture-mode artist-mode)) + helm-candidate-number-limit 500 ; limit the number of displayed canidates + helm-M-x-requires-pattern 0 ; show all candidates when set to 0 + helm-ff-file-name-history-use-recentf t + helm-move-to-line-cycle-in-source t ; move to end or beginning of source + ; when reaching top or bottom of source. + ido-use-virtual-buffers t ; Needed in helm-buffers-list + helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non-nil + ; useful in helm-mini that lists buffers + ) + +(global-set-key (kbd "M-x") 'helm-M-x) +(global-set-key (kbd "M-y") 'helm-show-kill-ring) +(global-set-key (kbd "C-x b") 'helm-mini) +(global-set-key (kbd "C-x C-f") 'helm-find-files) +(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings) +(global-set-key (kbd "C-c h o") 'helm-occur) +(global-set-key (kbd "C-c h g") 'helm-do-grep) +(global-set-key (kbd "C-c h C-c w") 'helm-wikipedia-suggest) +(global-set-key (kbd "C-c h x") 'helm-register) + +(define-key 'help-command (kbd "C-f") 'helm-apropos) +(define-key 'help-command (kbd "r") 'helm-info-emacs) +(define-key 'help-command (kbd "C-l") 'helm-locate-library) + +;; use helm to list eshell history +(add-hook 'eshell-mode-hook + #'(lambda () + (define-key eshell-mode-map (kbd "M-l") 'helm-eshell-history))) + +;;; Save current position to mark ring +(add-hook 'helm-goto-line-before-hook 'helm-save-current-pos-to-mark-ring) + +;; show minibuffer history with Helm +(define-key minibuffer-local-map (kbd "M-p") 'helm-minibuffer-history) +(define-key minibuffer-local-map (kbd "M-n") 'helm-minibuffer-history) + +(define-key global-map [remap find-tag] 'helm-etags-select) +(define-key global-map [remap list-buffers] 'helm-buffers-list) + +(define-key shell-mode-map (kbd "M-p") 'helm-comint-input-ring) ; shell history. -(require 'helm-misc) (require 'helm-projectile) +(setq projectile-completion-system 'helm) -(defun helm-prelude () - "Preconfigured `helm'." - (interactive) - (condition-case nil - (if (projectile-project-root) - (helm-projectile) - ;; otherwise fallback to `helm-mini' - (helm-mini)) - ;; fall back to helm mini if an error occurs (usually in `projectile-project-root') - (error (helm-mini)))) +(push "Press <C-c p h> to navigate a project in Helm." prelude-tips) -(eval-after-load 'prelude-mode - '(progn - (define-key prelude-mode-map (kbd "C-c h") 'helm-prelude) - (easy-menu-add-item nil '("Tools" "Prelude") - '("Navigation" - ["Helm" helm-prelude])))) - -(push "Press <C-c h> to navigate a project in Helm." prelude-tips) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; PACKAGE: helm-descbinds ;; +;; ;; +;; GROUP: Convenience -> Helm -> Helm Descbinds ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(require 'helm-descbinds) +(helm-descbinds-mode) (provide 'prelude-helm) From e379c876c2b770701be044ead7a374be54140002 Mon Sep 17 00:00:00 2001 From: toctan <tianjin.sc@gmail.com> Date: Sat, 30 Aug 2014 23:30:16 +0800 Subject: [PATCH 4/5] Flat index with python imenu --- modules/prelude-python.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/prelude-python.el b/modules/prelude-python.el index 1f7a44e..10ca704 100644 --- a/modules/prelude-python.el +++ b/modules/prelude-python.el @@ -45,8 +45,8 @@ buffer-file-coding-system))) (if coding-system (symbol-name - (or (coding-system-get coding-system 'mime-charset) - (coding-system-change-eol-conversion coding-system nil))) + (or (coding-system-get coding-system 'mime-charset) + (coding-system-change-eol-conversion coding-system nil))) "ascii-8bit"))) (defun prelude-python--insert-coding-comment (encoding) @@ -78,9 +78,12 @@ "Defaults for Python programming." (subword-mode +1) (setq-local electric-layout-rules - '((?: . (lambda () + '((?: . (lambda () (if (python-info-statement-starts-block-p) 'after))))) + (when (fboundp #'python-imenu-create-flat-index) + (setq-local imenu-create-index-function + #'python-imenu-create-flat-index)) (electric-layout-mode +1) (add-hook 'after-save-hook 'prelude-python-mode-set-encoding nil 'local)) From 10b045c29a3a1f35ecf8181b567587bd092e1290 Mon Sep 17 00:00:00 2001 From: "Tu, Do" <tuhdo1710@gmail.com> Date: Sat, 30 Aug 2014 23:56:06 +0700 Subject: [PATCH 5/5] Allow enable/disable global helm key bindings Since some users prefer using default Prelude commands, a new global mode is defined: prelude-global-helm-mode. When activate, Helm binds some global key bindings to its own commands. When deactivate, Helm removes the bindings and Prelude uses the default bindings. --- README.md | 32 +++++++++++++++-- modules/prelude-helm.el | 78 +++++++++++++++++++++++++---------------- 2 files changed, 77 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 5e5fc57..eaad200 100644 --- a/README.md +++ b/README.md @@ -372,9 +372,35 @@ If you ever forget any of Projectile's keybindings just do a: Helm is setup according to this guide: [A Package in a league of its own: Helm](http://tuhdo.github.io/helm-intro.html). -You can learn Helm usage and key bindings following the guide. <kbd>C-c h</kbd> -is Prelude's default prefix key for Helm. If you don't remember any key binding, -append <kbd>C-h</kbd> after <kbd>C-c h</kbd> for a list of key bindings in Helm. +You can learn Helm usage and key bindings following the guide. <kbd>C-c h</kbd> is Prelude's default prefix key for Helm. +If you don't remember any key binding, append <kbd>C-h</kbd> after <kbd>C-c h</kbd> for a list of key bindings in Helm. + +By default, Helm won't activate these global key bindings, so you can use Helm along with Ido and Prelude's default commands: + +Key binding | Description +-------------------|---------------------------------------------- +<kbd>M-x</kbd> | Run [helm-M-x](http://tuhdo.github.io/helm-intro.html#sec-3), an interactive version of <kbd>M-x</kdb>. +<kbd>M-y</kbd> | Run [helm-show-kill-ring](http://tuhdo.github.io/helm-intro.html#sec-4), shows the content of `kill-ring`. +<kbd>C-x b </kbd> | Run [helm-mini](http://tuhdo.github.io/helm-intro.html#sec-5), an interactive version of `C-x b` with more features. +<kbd>C-x C-f</kbd> | Run [helm-find-files](http://tuhdo.github.io/helm-intro.html#sec-6), an interactive version of `find-file` with more features. +<kbd>C-h C-f </kbd>| Run [helm-apropos](http://tuhdo.github.io/helm-intro.html#sec-13), an interactive version of `apropos-command`. +<kbd>C-h r</kbd> | Run [helm-info-emacs](http://tuhdo.github.io/helm-intro.html#sec-14), an interactive version of `info-emacs-manual`. +<kbd>C-h C-l </kbd>| Run `helm-locate-library` that can search for locations of any file loaded into Emacs. + +This key binding won't be activated in `shell-mode`: + +Key Binding | Description +-------------------|---------------------------------------------- +<kbd>M-l</kbd> | Run `helm-comint-input-ring` that shows `shell` history using Helm interface. + +These key bindings won't be activated in `eshell-mode`: + +Key Binding | Description +-------------------|---------------------------------------------- +<kbd>M-l</kbd> | Run `helm-eshell-history` that shows `eshell` history using Helm interface. + +You can use above key bindings by putting `(prelude-global-helm-global-mode +1)` right after `(require 'prelude-helm)`. If you enable +these key bindings, you should not enable `prelude-ido`. #### Key-chords diff --git a/modules/prelude-helm.el b/modules/prelude-helm.el index ec2d0a4..3878331 100644 --- a/modules/prelude-helm.el +++ b/modules/prelude-helm.el @@ -1,6 +1,6 @@ ;;; prelude-helm.el --- Helm setup ;; -;; Copyright © 2011-2013 Bozhidar Batsov +;; Copyright © 2011-2014 Bozhidar Batsov ;; ;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; URL: https://github.com/bbatsov/prelude @@ -11,7 +11,7 @@ ;;; Commentary: -;; Some config for Helm. +;; Some config for Helm that follows thiks guide: http://tuhdo.github.io/helm-intro.html ;;; License: @@ -64,58 +64,76 @@ helm-split-window-default-side 'other ;; open helm buffer in another window helm-split-window-in-side-p t ;; open helm buffer inside current window, not occupy whole other window helm-buffers-favorite-modes (append helm-buffers-favorite-modes - '(picture-mode artist-mode)) + '(picture-mode artist-mode)) helm-candidate-number-limit 500 ; limit the number of displayed canidates - helm-M-x-requires-pattern 0 ; show all candidates when set to 0 + helm-M-x-requires-pattern 0 ; show all candidates when set to 0 helm-ff-file-name-history-use-recentf t helm-move-to-line-cycle-in-source t ; move to end or beginning of source ; when reaching top or bottom of source. - ido-use-virtual-buffers t ; Needed in helm-buffers-list + ido-use-virtual-buffers t ; Needed in helm-buffers-list helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non-nil ; useful in helm-mini that lists buffers ) -(global-set-key (kbd "M-x") 'helm-M-x) -(global-set-key (kbd "M-y") 'helm-show-kill-ring) -(global-set-key (kbd "C-x b") 'helm-mini) -(global-set-key (kbd "C-x C-f") 'helm-find-files) -(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings) (global-set-key (kbd "C-c h o") 'helm-occur) (global-set-key (kbd "C-c h g") 'helm-do-grep) (global-set-key (kbd "C-c h C-c w") 'helm-wikipedia-suggest) (global-set-key (kbd "C-c h x") 'helm-register) - -(define-key 'help-command (kbd "C-f") 'helm-apropos) -(define-key 'help-command (kbd "r") 'helm-info-emacs) -(define-key 'help-command (kbd "C-l") 'helm-locate-library) - -;; use helm to list eshell history -(add-hook 'eshell-mode-hook - #'(lambda () - (define-key eshell-mode-map (kbd "M-l") 'helm-eshell-history))) +(global-set-key (kbd "C-c h SPC") 'helm-all-mark-rings) ;;; Save current position to mark ring (add-hook 'helm-goto-line-before-hook 'helm-save-current-pos-to-mark-ring) -;; show minibuffer history with Helm -(define-key minibuffer-local-map (kbd "M-p") 'helm-minibuffer-history) -(define-key minibuffer-local-map (kbd "M-n") 'helm-minibuffer-history) +(defvar prelude-global-helm-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "M-x") 'helm-M-x) + (define-key map (kbd "M-y") 'helm-show-kill-ring) + (define-key map (kbd "C-x b") 'helm-mini) + (define-key map (kbd "C-x C-f") 'helm-find-files) + (define-key map (kbd "C-h C-f") 'helm-apropos) + (define-key map (kbd "C-h r") 'helm-info-emacs) + (define-key map (kbd "C-h C-l") 'helm-locate-library) + map) + "Keymap for Helm to replace standard Prelude's commands") -(define-key global-map [remap find-tag] 'helm-etags-select) -(define-key global-map [remap list-buffers] 'helm-buffers-list) +(define-minor-mode prelude-global-helm-minor-mode + "Minor mode to replace Prelude default commands with \\{prelude-global-helm-map}" + :keymap prelude-global-helm-mode-map + (progn + ;; show minibuffer history with Helm + (define-key minibuffer-local-map (kbd "M-l") 'helm-minibuffer-history) + (define-key global-map [remap find-tag] 'helm-etags-select) + (define-key global-map [remap list-buffers] 'helm-mini) -(define-key shell-mode-map (kbd "M-p") 'helm-comint-input-ring) ; shell history. + ;; shell history. + (define-key shell-mode-map (kbd "M-l") 'helm-comint-input-ring) + + ;; use helm to list eshell history + (add-hook 'eshell-mode-hook + #'(lambda () + (define-key eshell-mode-map (kbd "M-l") 'helm-eshell-history))))) + +(define-globalized-minor-mode prelude-global-helm-global-mode prelude-global-helm-minor-mode prelude-global-helm-global-mode-on) + +(defun prelude-global-helm-global-mode-on () + "Turn on `prelude-global-helm-minor-mode'" + (prelude-global-helm-minor-mode +1) + ) + +(defun prelude-global-helm-global-mode-off () + "Turn off `prelude-global-helm-minor-mode'" + (prelude-global-helm-minor-mode -1)) + +(helm-mode 1) + +;; PACKAGE: helm-projectile (require 'helm-projectile) (setq projectile-completion-system 'helm) (push "Press <C-c p h> to navigate a project in Helm." prelude-tips) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; PACKAGE: helm-descbinds ;; -;; ;; -;; GROUP: Convenience -> Helm -> Helm Descbinds ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; PACKAGE: helm-descbinds (require 'helm-descbinds) (helm-descbinds-mode)