Update promotion and demotion conventions and apply them to markdown

This commit is contained in:
syl20bnr 2018-06-06 01:15:48 -04:00
parent 49b21c4c3c
commit 834c39c2fd
4 changed files with 37 additions and 14 deletions

View File

@ -301,7 +301,8 @@ In normal mode Vim style movement should be enabled with these keybindings:
*** Promotion, Demotion and element movement
Promotion, demotion and movement of headings or list elements (whatever is
possible) should be enabled with the following keys in any mode
possible) should be enabled with the following keys when in Vim style or
Hybrid with hjkl movements enabled:
| Key Binding | Description |
|-------------+------------------------------|
@ -310,6 +311,16 @@ possible) should be enabled with the following keys in any mode
| ~M-k~ | Move element up |
| ~M-l~ | Demote heading by one level |
In all editing styles promotion and demotion can be done with the following
keys:
| Key Binding | Description |
|-------------+------------------------------|
| ~M-down~ | Move element down |
| ~M-left~ | Promote heading by one level |
| ~M-right~ | Demote heading by one level |
| ~M-up~ | Move element up |
*** Table editing
If table specific commands are available the they are grouped under the
~SPC m t~ group.

View File

@ -188,12 +188,12 @@ To generate a table of contents type on top of the buffer:
** Promotion, Demotion
| Evil | Holy | Command |
|-------+-------------+--------------------|
| ~M-k~ | ~C-c C-x u~ | markdown-move-up |
| ~M-j~ | ~C-c C-x d~ | markdown-move-down |
| ~M-h~ | ~C-c C-x l~ | markdown-promote |
| ~M-l~ | ~C-c C-x r~ | markdown-demote |
| Key Binding | Command |
|--------------------+--------------------|
| ~M-k~ or ~M-up~ | markdown-move-up |
| ~M-j~ or ~M-down~ | markdown-move-down |
| ~M-h~ or ~M-left~ | markdown-promote |
| ~M-l~ or ~M-right~ | markdown-demote |
** Toggles

View File

@ -51,3 +51,15 @@ Will work on both org-mode and any mode that accepts plain html."
:back back)))
(dolist (mode markdown--key-bindings-modes)
(mmm-add-mode-ext-class mode nil class))))
(defun spacemacs//markdown-hjkl-promotion-demotion (style)
"Set promotion/demotiion on 'hjkl' for the given editing STYLE."
(when (or (eq 'vim style)
(and (eq 'hybrid style)
hybrid-mode-enable-hjkl-bindings))
(dolist (s '(normal insert))
(evil-define-key s markdown-mode-map
(kbd "M-h") 'markdown-promote
(kbd "M-j") 'markdown-move-down
(kbd "M-k") 'markdown-move-up
(kbd "M-l") 'markdown-demote))))

View File

@ -143,13 +143,13 @@
;; next visible heading is not exactly what we want but close enough
"gl" 'outline-next-visible-heading)
;; Promotion, Demotion
(mapc (lambda (state)
(evil-define-key state markdown-mode-map
(kbd "M-h") 'markdown-promote
(kbd "M-j") 'markdown-move-down
(kbd "M-k") 'markdown-move-up
(kbd "M-l") 'markdown-demote))
'(normal insert)))))
(add-hook 'spacemacs-editing-style-hook
'spacemacs//markdown-hjkl-promotion-demotion)
(spacemacs//markdown-hjkl-promotion-demotion dotspacemacs-editing-style)
(define-key markdown-mode-map (kbd "M-<down>") 'markdown-move-down)
(define-key markdown-mode-map (kbd "M-<left>") 'markdown-promote)
(define-key markdown-mode-map (kbd "M-<right>") 'markdown-demote)
(define-key markdown-mode-map (kbd "M-<up>") 'markdown-move-up))))
(defun markdown/init-markdown-toc ()
(use-package markdown-toc