diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 748734fae19f..9351dad4e273 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -29,7 +29,7 @@ _PR = pull request_ - if you still have several commits, squash them into only one commit - rebase your PR branch on top of upstream `develop` before submitting the PR -Those PRs are fast-forwarded. +Those PRs are fast-forwarded whenever it's possible. 2) For complex pull requests: diff --git a/README.md b/README.md index 98a9804a8e5a..31107e83b632 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,11 @@ for contribution guidelines_ - [Commands](#commands) - [Return to normal mode](#return-to-normal-mode) - [Executing Vim, Emacs and shell commands](#executing-vim-emacs-and-shell-commands) - - [Navigation](#navigation) + - [Navigating](#navigating) - [Point/Cursor](#pointcursor) - [Vim motions with ace-jump mode](#vim-motions-with-ace-jump-mode) + - [Window manipulation](#window-manipulation) + - [Golden ratio](#golden-ratio) - [Buffers and Files](#buffers-and-files) - [Ido](#ido) - [NeoTree file tree](#neotree-file-tree) @@ -80,28 +82,27 @@ for contribution guidelines_ - [Visual Star](#visual-star) - [Listing symbols by semantic](#listing-symbols-by-semantic) - [Helm-swoop](#helm-swoop) - - [Window manipulation](#window-manipulation) - - [Golden ratio](#golden-ratio) - - [Text manipulation commands](#text-manipulation-commands) - - [Change font size](#change-font-size) - - [Spell checking](#spell-checking) - - [Region selection](#region-selection) - - [Region narrowing](#region-narrowing) - - [Line formatting](#line-formatting) - - [Auto-completion](#auto-completion) - - [Commenting](#commenting) - - [Errors handling](#errors-handling) + - [Editing](#editing) + - [Text manipulation commands](#text-manipulation-commands) + - [Change font size](#change-font-size) + - [Increase/Decrease numbers](#increasedecrease-numbers) + - [Spell checking](#spell-checking) + - [Region selection](#region-selection) + - [Region narrowing](#region-narrowing) + - [Line formatting](#line-formatting) + - [Auto-completion](#auto-completion) + - [Commenting](#commenting) + - [Editing Lisp code](#editing-lisp-code) + - [Key bindings maps](#key-bindings-maps) + - [Regular normal state bindings](#regular-normal-state-bindings) + - [Lisp specific bindings](#lisp-specific-bindings) - [Project management](#project-management) - [Working with Git](#working-with-git) - [Magit](#magit) - [Quick guide for recurring use cases in Magit](#quick-guide-for-recurring-use-cases-in-magit) - [Git gutter bitmaps](#git-gutter-bitmaps) - - [Editing Lisp code](#editing-lisp-code) - - [Philosophy](#philosophy) - - [Intuitive navigation model](#intuitive-navigation-model) - - [Key bindings maps](#key-bindings-maps) - - [Regular normal state bindings](#regular-normal-state-bindings) - - [Lisp specific bindings](#lisp-specific-bindings) + - [Registers](#registers) + - [Errors handling](#errors-handling) - [Modes](#modes) - [Helm](#helm) - [Erlang](#erlang) @@ -733,6 +734,8 @@ They are both extended with various packages to build on their foundations. [evil-exchange][] | port of [vim-exchange][] [evil-surround][] | port of [vim-surround][] [evil-nerd-commenter][] | port of [nerdcommenter][] +[evil-search-highlight-persist][] | emulation of hlsearch behavior +[evil-numbers][] | like C-a/C-x in vim [NeoTree][neotree] | mimic [NERD Tree][nerdtree] ### Helm extensions @@ -788,7 +791,7 @@ Vim | `:` Emacs | ` :` Shell | ` !` -### Navigation +### Navigating #### Point/Cursor @@ -822,6 +825,56 @@ Key Binding | Description ` l` | initiate ace jump line mode `` ``` | go back to the previous location (before the jump) +#### Window manipulation + +Every window has a number displayed at the start of the mode-line and can +be quickly accessed using ` number`. + +Key Binding | Description +--------------|---------------------------------------------------------------- +` 1` | go to first window +` 2` | go to window number 2 +` 3` | go to window number 3 +` 4` | go to window number 4 +` 5` | go to window number 5 +` 6` | go to window number 6 +` 7` | go to window number 7 +` 8` | go to window number 8 +` 9` | go to window number 9 +` 0` | go to window number 10 + +Windows manipulation commands (start with `w`): + +Key Binding | Description +--------------|---------------------------------------------------------------- +` w b` | split a window horizontally +` w c` | close a window +` w d` | toggle window dedication (dedicated window cannot be used by a mode) +` w H` | move window to the left +` w J` | move window to the bottom +` w K` | move window to the top +` w L` | move window to the right +` w m` | maximize/minimize a window +` w M` | maximize/minimize a window, when maximized the buffer is centered +` w p m` | open messages buffer in a popup window +` w p p` | close the current sticky popup window +` w r` | rotate windows clockwise +` w R` | rotate windows counter-clockwise +` w u` | undo window layout (used to effectively undo a close window) +` w U` | redo window layout +` w v` | split a window vertically +` w w` | cycle and focus between windows + +##### Golden ratio + +Split windows can be dynamically resized depending on whether they are selected +or not. Resizing is performed by the [golden-ratio][golden-ratio] mode. +By default `golden-ratio` if off. + +The mode can be toggled on and off with: + + t g + #### Buffers and Files `Spacemacs` uses `ido` for opening files since `ido` way to navigate @@ -1013,57 +1066,9 @@ Key Binding | Description ` s S` | execute `helm-multi-swoop` ` s C-s` | execute `helm-multi-swoop-all` -### Window manipulation - -Every window has a number displayed at the start of the mode-line and can -be quickly accessed using ` number`. - -Key Binding | Description ---------------|---------------------------------------------------------------- -` 1` | go to first window -` 2` | go to window number 2 -` 3` | go to window number 3 -` 4` | go to window number 4 -` 5` | go to window number 5 -` 6` | go to window number 6 -` 7` | go to window number 7 -` 8` | go to window number 8 -` 9` | go to window number 9 -` 0` | go to window number 10 +### Editing -Windows manipulation commands (start with `w`): - -Key Binding | Description ---------------|---------------------------------------------------------------- -` w b` | split a window horizontally -` w c` | close a window -` w d` | toggle window dedication (dedicated window cannot be used by a mode) -` w H` | move window to the left -` w J` | move window to the bottom -` w K` | move window to the top -` w L` | move window to the right -` w m` | maximize/minimize a window -` w M` | maximize/minimize a window, when maximized the buffer is centered -` w p m` | open messages buffer in a popup window -` w p p` | close the current sticky popup window -` w r` | rotate windows clockwise -` w R` | rotate windows counter-clockwise -` w u` | undo window layout (used to effectively undo a close window) -` w U` | redo window layout -` w v` | split a window vertically -` w w` | cycle and focus between windows - -#### Golden ratio - -Split windows can be dynamically resized depending on whether they are selected -or not. Resizing is performed by the [golden-ratio][golden-ratio] mode. -By default `golden-ratio` if off. - -The mode can be toggled on and off with: - - t g - -### Text manipulation commands +#### Text manipulation commands Text related commands (start with `x`): @@ -1083,7 +1088,7 @@ Text related commands (start with `x`): ` x w c` | count the number of words in the selection region ` x w C` | count the number of occurrences per word in the select region -### Change font size +#### Change font size The font size of the current buffer can be adjusted with the commands: @@ -1097,7 +1102,27 @@ Key Binding | Description `=` | reset the font size Any other key | leave the font scaling micro-state -### Spell checking +#### Increase/Decrease numbers + +`Spacemacs` uses [evil-numbers][] to easily increase or increase numbers. + +Key Binding | Description +--------------|------------------------------------------------------------ +` n +` | increase the number under point by one and initiate micro-state +` n -` | decrease the number under point by one and initiate micro-state + +In micro-state: + +Key Binding | Description +--------------|------------------------------------------------------------ +`+` | increase the number under point by one +`-` | decrease the number under point by one +Any other key | leave the micro-state + +**Tips:** you can increase or decrease a value by more that once by using a +prefix argument (ie. `10 n +` will add 10 to the number under point). + +#### Spell checking Spell checking commands start with `S`: @@ -1108,7 +1133,7 @@ Spell checking commands start with `S`: ` S n` | go to the next spell check error -### Region selection +#### Region selection Vi `Visual` modes are all supported by `evil`, `Spacemacs` adds another `Visual` mode via the [expand-region][] mode. @@ -1121,7 +1146,7 @@ Key Binding | Description `r` | reset the region to initial selection `ESC` | leave expand-region mode -### Region narrowing +#### Region narrowing The displayed text of a buffer can be narrowed with the commands (start with `n`): @@ -1133,7 +1158,7 @@ Key Binding | Description ` n r` | narrow the buffer to the selected text ` n w` | widen, i.e show the whole buffer again -### Line formatting +#### Line formatting `Spacemacs` replaces the default `J` Vi key binding (join current line with next line) by a slightly more frequent action which is to `go to the line below point @@ -1153,7 +1178,7 @@ Line formatting commands start with `j`: Used together these key bindings are very powerful to quickly reformat the code. -### Auto-completion +#### Auto-completion `Spacemacs` uses [auto-complete][] auto-completion engine. @@ -1166,7 +1191,7 @@ Used together these key bindings are very powerful to quickly reformat the code. `return` | complete word, if word is already completed insert a carriage return -### Commenting +#### Commenting Comments are handled by [evil-nerd-commenter][], it's bound to the following keys. @@ -1180,28 +1205,106 @@ Comments are handled by [evil-nerd-commenter][], it's bound to the following key ` n c i` | comment invert ` n c c` | comment operator +#### Editing Lisp code -### Errors handling +Lisp navigation and edition is performed with a custom evil `lisp state` +provided by [evil-lisp-state][evil-lisp-state] package. -`Spacemacs` uses [Flycheck][flycheck] to gives error feedback on the fly. -The checks are only performed at save time by default. +Intuitive navigation model: -Errors management commands (star with `f` for `flycheck`): +`hjkl` behaves like in the default `normal state`. - Key Binding | Description -------------------|------------------------------------------------------------ -` f c` | clear all errors -` f l` | display the `flycheck` list of errors/warnings -` f n` | go to the next `flycheck` error -` f p` | go to the previous flycheck error +**Next sexp on the same level (sibling)** +- `L` next sexp +- `H` previous sexp -Custom fringe bitmaps: +**Change level (parent/children)** +- `J` go to next sexp one level down +- `K` go to previous one level up - Symbol | Description -:----------------------------------------------------------------------------------------------:|------------ -![dot-error](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/dot-error.png) | Error -![dot-warning](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/dot-warning.png) | warning -![dot-info](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/dot-info.png) | Info +And that's it! All these commands always put the point _at the beginning_ of +the sexp. + +##### Key bindings maps + +###### Regular normal state bindings + +Key Binding | Function +--------------|------------------------------------------------------------ +`a` | evil-append +`c` | evil-change +`d` | evil-delete +`h` | next char +`i` | evil-insert-state +`I` | evil-insert-line +`j` | next visual line +`k` | previous visual line +`l` | next char +`o` | evil-insert-below +`O` | evil-insert-above +`p` | evil-past-after +`P` | evil-past-before +`r` | evil-replace +`C-r` | undo-tree-redo +`u` | undo-tree-undo +`x` | evil-delete-char +`X` | evil-delete-backward-char +`y` | evil-yank +`ESC` | evil-normal-state + +###### Lisp specific bindings + +_In this table we assume that `evil-lisp-state-backward-prefix` is set to +default ``_ + +Key Binding | Function +--------------|------------------------------------------------------------ +`(` | insert sibling before sexp and switch to `insert state` +`)` | insert sibling after sexp and switch to `insert state` +`$` | sp-end-of-sexp +`0` | sp-beginning-of-sexp +`A` | sp-absorb-sexp +`b` | sp-forward-barf-sexp +` b` | sp-backward-barf-sexp +`C` | sp-convolute-sexp +`Dd` | sp-kill-hybrid-sexp +`Dx` | sp-kill-sexp +` Dx` | sp-backward-kill-sexp +`Ds` | sp-kill-symbol +` Ds` | sp-backward-kill-symbol +`Dw` | sp-kill-word +` Dw` | sp-backward-kill-word +`E$` | evil-lisp-state-eval-sexp-end-of-line +`Ee` | eval-last-sexp +`Ef` | eval-defun +`gs` | go to source of symbol under point +`gt` | sp-transpose-sexp +`gT` | sp-transpose-hybrid-sexp +`H` | previous sexp at the same level +`J` | next sexp one level down +`K` | previous sexp one level up +`L` | next sexp of the same level +`M` | sp-join-sexp (think about `merge-sexp`) +`R` | sp-raise-sexp +`s` | sp-forward-slurp-sexp +` s` | sp-backward-slurp-sexp +`S` | sp-splice-sexp-killing-forward +` S` | sp-splice-sexp-killing-backward +`w` | wrap sexp +`W` | unwrap sexp +` W` | sp-backward-unwrap-sexp +`Y` | sp-copy-sexp +` y` | sp-backward-copy-sexp +`backspace` | sp-backward-delete-char +`S-backspace` | sp-delete-char +`RET` | indent next line +`S-RET` | insert new line char and switch to `insert state` + +**Reminder:** +`lisp state` is a [base state](#base-states) which means that leaving +the `insert state` when the previous state was `lisp` will set you back +in `lisp state`. +To go back to `normal state` press `` or `fd` while in `lisp state`. ### Project management @@ -1335,118 +1438,38 @@ you can answer `y` with no issue. ![git-del](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/git-del-line.png) | at least one line has been deleted ![git-mod](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/git-mod-line.png) | modified line -### Editing Lisp code - -Lisp navigation and edition is performed with a custom evil `lisp state` -provided by [evil-lisp-state][evil-lisp-state] package. - -#### Philosophy - -`evil-lisp-state` goal is to replace as much as possible the `normal state` in -lisp buffers. - -To achieve this goal, this mode tries to keep the useful commands from the -`normal state` and add new commands (often with `shift` modifier) for -manipulating the data structure. - -_Note: Be sure to try the key bindings '(' and ')'. I use them all the time -and it may be one of the best features of this mode._ - -#### Intuitive navigation model - -`hjkl` behaves like in the default `normal state`. - -**Next sexp on the same level (sibling)** -- `L` next sexp -- `H` previous sexp +### Registers -**Change level (parent/children)** -- `J` go to next sexp one level down -- `K` go to previous one level up - -And that's it! All these commands always put the point _at the beginning_ of -the sexp. +Access commands to the various registers start with `r`: -#### Key bindings maps + Key Binding | Description +------------------|------------------------------------------------------------ +` r e` | show evil yank and named registers +` r m` | show marks register +` r r` | show helm register +` r y` | show kill ring -##### Regular normal state bindings +### Errors handling -Key Binding | Function ---------------|------------------------------------------------------------ -`a` | evil-append -`c` | evil-change -`d` | evil-delete -`h` | next char -`i` | evil-insert-state -`I` | evil-insert-line -`j` | next visual line -`k` | previous visual line -`l` | next char -`o` | evil-insert-below -`O` | evil-insert-above -`p` | evil-past-after -`P` | evil-past-before -`r` | evil-replace -`C-r` | undo-tree-redo -`u` | undo-tree-undo -`x` | evil-delete-char -`X` | evil-delete-backward-char -`y` | evil-yank -`ESC` | evil-normal-state +`Spacemacs` uses [Flycheck][flycheck] to gives error feedback on the fly. +The checks are only performed at save time by default. -##### Lisp specific bindings +Errors management commands (star with `f` for `flycheck`): -_In this table we assume that `evil-lisp-state-backward-prefix` is set to -default ``_ + Key Binding | Description +------------------|------------------------------------------------------------ +` f c` | clear all errors +` f l` | display the `flycheck` list of errors/warnings +` f n` | go to the next `flycheck` error +` f p` | go to the previous flycheck error -Key Binding | Function ---------------|------------------------------------------------------------ -`(` | insert sibling before sexp and switch to `insert state` -`)` | insert sibling after sexp and switch to `insert state` -`$` | sp-end-of-sexp -`0` | sp-beginning-of-sexp -`A` | sp-absorb-sexp -`b` | sp-forward-barf-sexp -` b` | sp-backward-barf-sexp -`C` | sp-convolute-sexp -`Dd` | sp-kill-hybrid-sexp -`Dx` | sp-kill-sexp -` Dx` | sp-backward-kill-sexp -`Ds` | sp-kill-symbol -` Ds` | sp-backward-kill-symbol -`Dw` | sp-kill-word -` Dw` | sp-backward-kill-word -`E$` | evil-lisp-state-eval-sexp-end-of-line -`Ee` | eval-last-sexp -`Ef` | eval-defun -`gs` | go to source of symbol under point -`gt` | sp-transpose-sexp -`gT` | sp-transpose-hybrid-sexp -`H` | previous sexp at the same level -`J` | next sexp one level down -`K` | previous sexp one level up -`L` | next sexp of the same level -`M` | sp-join-sexp (think about `merge-sexp`) -`R` | sp-raise-sexp -`s` | sp-forward-slurp-sexp -` s` | sp-backward-slurp-sexp -`S` | sp-splice-sexp-killing-forward -` S` | sp-splice-sexp-killing-backward -`w` | wrap sexp -`W` | unwrap sexp -` W` | sp-backward-unwrap-sexp -`Y` | sp-copy-sexp -` y` | sp-backward-copy-sexp -`backspace` | sp-backward-delete-char -`S-backspace` | sp-delete-char -`RET` | indent next line -`S-RET` | insert new line char and switch to `insert state` +Custom fringe bitmaps: -**Reminder:** -`lisp state` is a [base state](#base-states) which means that leaving -the `insert state` when the previous state was `lisp` will set you back -in `lisp state`. -To go back to `normal state` press `` or `fd` while in `lisp state`. + Symbol | Description +:----------------------------------------------------------------------------------------------:|------------ +![dot-error](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/dot-error.png) | Error +![dot-warning](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/dot-warning.png) | warning +![dot-info](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/doc/dot-info.png) | Info ### Modes @@ -1753,3 +1776,4 @@ Thank you to the whole Emacs community from core developers to elisp hackers! [CONTRIBUTE.md-CL]: https://github.com/syl20bnr/spacemacs/blob/master/CONTRIBUTE.md#submitting-a-contribution-layer-upstream [neotree]: https://github.com/jaypei/emacs-neotree [nerdtree]: https://github.com/scrooloose/nerdtree +[evil-numbers]: https://github.com/cofi/evil-numbers diff --git a/contrib/syl20bnr/packages.el b/contrib/syl20bnr/packages.el index d5cc7681b548..d98bbe038e1a 100644 --- a/contrib/syl20bnr/packages.el +++ b/contrib/syl20bnr/packages.el @@ -58,37 +58,64 @@ disabling some faces in order to make colored identifiers stand out." "Display a short documentation in the mini buffer." (let ((var (intern (format "rainbow-identifiers-cie-l*a*b*-%s" component)))) - (message "Change color %s mini-mode (value: %s) + (echo "Change color %s mini-mode (value: %s) + to increase %s - to decrease %s = to reset Press any other key to exit." component (eval var) component component))) - (defun syl20bnr/change-color-component - (component inc reset) + (defun syl20bnr/change-color-component-overlay-map (component) "Set a temporary overlay map to easily change a color COMPONENT from rainbow-identifier mode. The color COMPONENT can be 'saturation' or - 'lightness'. INC is the value to add to the COMPONENT. If RESET is not nil - then INC is the new value of the COMPONENT." + 'lightness'." (set-temporary-overlay-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "+") - `(lambda () (interactive) (syl20bnr/change-color-component-func - ,component ,inc))) - (define-key map (kbd "-") - `(lambda () (interactive) (syl20bnr/change-color-component-func - ,component ,(- inc)))) - (define-key map (kbd "=") - `(lambda () (interactive) (syl20bnr/change-color-component-func - ,component ,reset t))) + (let ((map (make-sparse-keymap)) + (up-func (intern (format "syl20bnr/change-color-%s-up" component))) + (down-func (intern (format "syl20bnr/change-color-%s-down" component))) + (reset-func (intern (format "syl20bnr/change-color-%s-reset" component)))) + (define-key map (kbd "+") up-func) + (define-key map (kbd "-") down-func) + (define-key map (kbd "=") reset-func) map) t) - (syl20bnr/change-color-mini-mode-doc component)) + (syl20bnr/change-color-mini-mode-doc component)) + + (defun syl20bnr/start-change-color-saturation () + "Initiate the overlay map to change the saturation." + (interactive) + (syl20bnr/change-color-component-overlay-map "saturation")) + (defun syl20bnr/change-color-saturation-up () + "Increase the saturation by 5 units." + (interactive) + (syl20bnr/change-color-component-func "saturation" 5)) + (defun syl20bnr/change-color-saturation-down () + "Decrease the saturation by 5 units." + (interactive) + (syl20bnr/change-color-component-func "saturation" -5)) + (defun syl20bnr/change-color-saturation-reset () + "Reset the saturation to 100." + (interactive) + (syl20bnr/change-color-component-func "saturation" 100 t)) + (defun syl20bnr/start-change-color-lightness () + "Initiate the overlay map to change the lightness." + (interactive) + (syl20bnr/change-color-component-overlay-map "lightness")) + (defun syl20bnr/change-color-lightness-up () + "Increase the lightness by 5 units." + (interactive) + (syl20bnr/change-color-component-func "lightness" 5)) + (defun syl20bnr/change-color-lightness-down () + "Decrease the lightness by 5 units." + (interactive) + (syl20bnr/change-color-component-func "lightness" -5)) + (defun syl20bnr/change-color-lightness-reset () + "Reset the lightness to 40." + (interactive) + (syl20bnr/change-color-component-func "lightness" 40 t)) (defun syl20bnr/change-color-component-func (component inc &optional reset) "Change the color component by adding INC value to it. If RESET is not nil the color component is set to INC." - (interactive) (let* ((var (intern (format "rainbow-identifiers-cie-l*a*b*-%s" component))) (new-value (+ (eval var) inc))) @@ -99,12 +126,8 @@ Press any other key to exit." component (eval var) component component))) (setq new-value 0)) (set var new-value))) (font-lock-fontify-buffer) - (syl20bnr/change-color-mini-mode-doc component))) + (syl20bnr/change-color-component-overlay-map component))) ;; key bindings - (evil-leader/set-key "cs" - '(lambda () (interactive) - (syl20bnr/change-color-component "saturation" 5 100))) - (evil-leader/set-key "cl" - '(lambda () (interactive) - (syl20bnr/change-color-component "lightness" 5 40)))))) + (evil-leader/set-key "cs" 'syl20bnr/start-change-color-saturation) + (evil-leader/set-key "cl" 'syl20bnr/start-change-color-lightness)))) diff --git a/spacemacs/funcs.el b/spacemacs/funcs.el index 410ee14c1835..2ce33283f9f2 100644 --- a/spacemacs/funcs.el +++ b/spacemacs/funcs.el @@ -11,6 +11,12 @@ (dolist (fun funs) (add-hook hook fun))) +(defun echo (msg &rest args) + "Display MSG in echo-area without logging it in *Messages* buffer." + (interactive) + (let ((message-log-max nil)) + (apply 'message msg args))) + (defun system-is-mac () (interactive) (string-equal system-type "darwin")) @@ -453,51 +459,52 @@ kill internal buffers too." (add-to-list 'default-frame-alist (cons 'font fontstr)) (set-default-font fontstr))) -(defun spacemacs/scale-font-size (direction) - "Set a temporary overlay map to easily change the font size. - DIRECTION is any number where: - - a positive number increase the size of the font - - a negative number decrease the size of the font - - 0 reset the font size to its default value" - (interactive) +(defun spacemacs/scale-font-size-overlay-map () + "Set a temporary overlay map to easily change the font size." (set-temporary-overlay-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "+") - '(lambda () (interactive) - (spacemacs/scale-up-or-down-font-size 1))) - (define-key map (kbd "-") - '(lambda () (interactive) - (spacemacs/scale-up-or-down-font-size -1))) - (define-key map (kbd "=") - '(lambda () (interactive) (spacemacs/reset-font-size))) - map) t) - (if (eq direction 0) - (spacemacs/reset-font-size) - (spacemacs/scale-up-or-down-font-size direction))) + (define-key map (kbd "+") 'spacemacs/scale-up-font) + (define-key map (kbd "-") 'spacemacs/scale-down-font) + (define-key map (kbd "=") 'spacemacs/reset-font-size) + map) t)) (defun spacemacs/font-scaling-micro-state-doc () "Display a short documentation in the mini buffer." - (message "Scale Font micro-state: + (echo "Scale Font micro-state: + to scale up - to scale down = to reset Press any other key to exit.")) +(spacemacs/font-scaling-micro-state-doc) + (defun spacemacs/scale-up-or-down-font-size (direction) "Scale the font. If DIRECTION is positive or zero the font is scaled up, otherwise it is scaled down." (interactive) (let ((scale 0.5)) - (if (< direction 0) - (text-scale-decrease scale) - (text-scale-increase scale)) - (spacemacs/font-scaling-micro-state-doc))) + (if (eq direction 0) + (text-scale-set 0) + (if (< direction 0) + (text-scale-decrease scale) + (text-scale-increase scale)))) + (spacemacs/scale-font-size-overlay-map) + (spacemacs/font-scaling-micro-state-doc)) + +(defun spacemacs/scale-up-font () + "Scale up the font." + (interactive) + (spacemacs/scale-up-or-down-font-size 1)) + +(defun spacemacs/scale-down-font () + "Scale up the font." + (interactive) + (spacemacs/scale-up-or-down-font-size -1)) (defun spacemacs/reset-font-size () - "Reset the font size (apply a scale of 0)." + "Reset the font size." (interactive) - (text-scale-set 0) - (spacemacs/font-scaling-micro-state-doc)) + (spacemacs/scale-up-or-down-font-size 0)) (defmacro spacemacs//diminish (mode lighter) "Diminish MODE name in mode line to LIGHTER." diff --git a/spacemacs/keybindings.el b/spacemacs/keybindings.el index cc399b0c6a65..30e0852791a3 100644 --- a/spacemacs/keybindings.el +++ b/spacemacs/keybindings.el @@ -97,9 +97,6 @@ "np" 'narrow-to-page "nf" 'narrow-to-defun "nw" 'widen) -;; misc ----------------------------------------------------------------------- -(evil-leader/set-key - "reg" 'evil-show-registers) ;; spell check --------------------------------------------------------------- (evil-leader/set-key "Sc" 'cofi/helm-flyspell-correct @@ -143,9 +140,9 @@ "ww" 'other-window) ;; text ----------------------------------------------------------------------- (evil-leader/set-key - "x=" (lambda () (interactive) (spacemacs/scale-font-size 0)) - "x+" (lambda () (interactive) (spacemacs/scale-font-size 1)) - "x-" (lambda () (interactive) (spacemacs/scale-font-size -1)) + "x=" 'spacemacs/reset-font-size + "x+" 'spacemacs/scale-up-font + "x-" 'spacemacs/scale-down-font "xdw" 'delete-trailing-whitespace "xtc" 'transpose-chars "xtl" 'transpose-lines diff --git a/spacemacs/packages.el b/spacemacs/packages.el index 86818350c2a0..7d2cbb640007 100644 --- a/spacemacs/packages.el +++ b/spacemacs/packages.el @@ -33,6 +33,7 @@ evil-leader evil-lisp-state evil-nerd-commenter + evil-numbers evil-surround evil-terminal-cursor-changer evil-visualstar @@ -343,6 +344,7 @@ DELETE-FUNC when calling CALLBACK. (lambda () (interactive) (evil-window-top) (evil-scroll-line-to-center nil))) + (evil-leader/set-key "re" 'evil-show-registers) ;; load evil-leader (use-package evil-leader :init @@ -394,7 +396,35 @@ DELETE-FUNC when calling CALLBACK. ;; add a lisp state (use-package evil-lisp-state :init - (evil-leader/set-key-for-mode 'emacs-lisp-mode "ml" 'evil-lisp-state))))) + (evil-leader/set-key-for-mode 'emacs-lisp-mode "ml" 'evil-lisp-state)) + (use-package evil-numbers + :config + (progn + (defun spacemacs/evil-numbers-micro-state-doc () + "Display a short documentation in the mini buffer." + (echo "+ to increase the value or - to decrease it")) + + (defun spacemacs/evil-numbers-micro-state-overlay-map () + "Set a temporary overlay map to easily increase or decrease a number" + (set-temporary-overlay-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "+") 'spacemacs/evil-numbers-increase) + (define-key map (kbd "-") 'spacemacs/evil-numbers-decrease) + map) t) + (spacemacs/evil-numbers-micro-state-doc)) + + (defun spacemacs/evil-numbers-increase (amount &optional no-region) + "Increase number at point." + (interactive "p*") + (evil-numbers/inc-at-pt amount no-region) + (spacemacs/evil-numbers-micro-state-overlay-map)) + (defun spacemacs/evil-numbers-decrease (amount) + "Decrease number at point." + (interactive "p*") + (evil-numbers/dec-at-pt amount) + (spacemacs/evil-numbers-micro-state-overlay-map)) + (evil-leader/set-key "n+" 'spacemacs/evil-numbers-increase) + (evil-leader/set-key "n-" 'spacemacs/evil-numbers-decrease)))))) (defun spacemacs/init-powerline () (use-package powerline @@ -757,7 +787,7 @@ DELETE-FUNC when calling CALLBACK. (propx/y (propertize x/y 'face ahs-plugin-whole-buffer-face)) (hidden (if (< 0 (- overlay-count (nth 4 st))) "*" "")) (prophidden (propertize hidden 'face '(:weight bold)))) - (message "%s %s%s press (n) or (N) to navigate, (R) for reset, (r) to change range" + (echo "%s %s%s press (n) or (N) to navigate, (R) for reset, (r) to change range" propplugin propx/y prophidden))))))) (defun spacemacs/init-bookmark () @@ -1335,16 +1365,25 @@ DELETE-FUNC when calling CALLBACK. (defun spacemacs/init-helm () (use-package helm + :idle (helm-mode +1) :defer t :init (setq helm-split-window-in-side-p nil + helm-quick-update t + helm-bookmark-show-location t + helm-buffers-fuzzy-matching t helm-always-two-windows t) (evil-leader/set-key ":" 'helm-M-x "bs" 'helm-mini "sl" 'helm-semantic-or-imenu "hb" 'helm-bookmarks - "kil" 'helm-show-kill-ring) + "ry" 'helm-show-kill-ring + "rr" 'helm-register + "rm" 'helm-all-mark-rings + "fh" 'helm-find-files + "" 'helm-apropos + ) :config (progn (helm-mode +1) @@ -1917,10 +1956,12 @@ DELETE-FUNC when calling CALLBACK. (defun spacemacs/init-visual-regexp-steroids () (use-package visual-regexp-steroids :defer t - :init - (evil-leader/set-key - "rR" 'vr/query-replace - "rr" 'vr/replace))) + ;; no shortcut for now (used by registers) + ;; :init + ;; (evil-leader/set-key + ;; "rR" 'vr/query-replace + ;; "rr" 'vr/replace) + )) (defun spacemacs/init-volatile-highlights () (use-package volatile-highlights @@ -1977,3 +2018,19 @@ DELETE-FUNC when calling CALLBACK. (defun spacemacs/init-zenburn-theme () (use-package zenburn-theme :defer t)) + +(defun spacemacs/init-coffee-mode () + (use-package coffee-mode + :defer t + :init + (progn + (defun spacemacs/coffee-indent () + (if (coffee-line-wants-indent) + ;; We need to insert an additional tab because the last line was special. + (coffee-insert-spaces (+ (coffee-previous-indent) coffee-tab-width)) + ;; otherwise keep at the same indentation level + (coffee-insert-spaces (coffee-previous-indent))) + ) + ;; indent to right position after `evil-open-blow' and `evil-open-above' + (add-hook 'coffee-mode-hook '(lambda () (setq indent-line-function 'spacemacs/coffee-indent))) + )))