Skip to content

Commit 7b6678e

Browse files
cpauliksyl20bnr
authored andcommitted
Org markdown: Improve consistency of key bindings for markup language
1 parent 3870c30 commit 7b6678e

File tree

3 files changed

+80
-43
lines changed

3 files changed

+80
-43
lines changed

contrib/lang/markdown/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ To generate a table of contents type on top of the buffer:
4949

5050
Key Binding | Description
5151
----------------------|------------------------------------------------------------
52-
<kbd>SPC m "</kbd> | insert hr
52+
<kbd>SPC m -</kbd> | insert hr
5353
<kbd>SPC m a l</kbd> | insert link
5454
<kbd>SPC m a L</kbd> | insert reference link dwim
5555
<kbd>SPC m a u</kbd> | insert uri

contrib/lang/markdown/packages.el

+41-36
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,46 @@
2828
(sp-local-pair 'markdown-mode "'" nil :actions nil))
2929
(progn
3030
(evil-leader/set-key-for-mode 'markdown-mode
31-
;; Element insertion
32-
"m\"" 'markdown-insert-hr
33-
"mal" 'markdown-insert-link
34-
"maL" 'markdown-insert-reference-link-dwim
35-
"mau" 'markdown-insert-uri
36-
"maf" 'markdown-insert-footnote
37-
"maw" 'markdown-insert-wiki-link
31+
;; Insertion of common elements
32+
"m-" 'markdown-insert-hr
33+
"mil" 'markdown-insert-link
34+
"miL" 'markdown-insert-reference-link-dwim
35+
"miu" 'markdown-insert-uri
36+
"mif" 'markdown-insert-footnote
37+
"miw" 'markdown-insert-wiki-link
3838
"mii" 'markdown-insert-image
3939
"miI" 'markdown-insert-reference-image
40-
"mth" 'markdown-insert-header-dwim
41-
"mtH" 'markdown-insert-header-setext-dwim
42-
"mt1" 'markdown-insert-header-atx-1
43-
"mt2" 'markdown-insert-header-atx-2
44-
"mt3" 'markdown-insert-header-atx-3
45-
"mt4" 'markdown-insert-header-atx-4
46-
"mt5" 'markdown-insert-header-atx-5
47-
"mt6" 'markdown-insert-header-atx-6
48-
"mt!" 'markdown-insert-header-setext-1
49-
"mt@" 'markdown-insert-header-setext-2
50-
"mss" 'markdown-insert-bold
51-
"mse" 'markdown-insert-italic
52-
"msc" 'markdown-insert-code
53-
"msb" 'markdown-insert-blockquote
54-
"msB" 'markdown-blockquote-region
55-
"msp" 'markdown-insert-pre
56-
"msP" 'markdown-pre-region
40+
;; headings
41+
"mhh" 'markdown-insert-header-dwim
42+
"mhH" 'markdown-insert-header-setext-dwim
43+
"mh1" 'markdown-insert-header-atx-1
44+
"mh2" 'markdown-insert-header-atx-2
45+
"mh3" 'markdown-insert-header-atx-3
46+
"mh4" 'markdown-insert-header-atx-4
47+
"mh5" 'markdown-insert-header-atx-5
48+
"mh6" 'markdown-insert-header-atx-6
49+
"mh!" 'markdown-insert-header-setext-1
50+
"mh@" 'markdown-insert-header-setext-2
51+
;; text manipulation
52+
"mtb" 'markdown-insert-bold
53+
"mti" 'markdown-insert-italic
54+
"mtc" 'markdown-insert-code
55+
"mtq" 'markdown-insert-blockquote
56+
"mtQ" 'markdown-blockquote-region
57+
"mtp" 'markdown-insert-pre
58+
"mtP" 'markdown-pre-region
5759
;; Element removal
5860
"mk" 'markdown-kill-thing-at-point
5961
;; Promotion, Demotion, Completion, and Cycling
60-
"m=" 'markdown-promote
61-
"m-" 'markdown-demote
6262
"m]" 'markdown-complete
6363
;; Following and Jumping
6464
"mo" 'markdown-follow-thing-at-point
65-
"mj" 'markdown-jump
65+
"m <RET>" 'markdown-jump
6666
;; Indentation
6767
"m>" 'markdown-indent-region
6868
"m<" 'markdown-exdent-region
6969
;; Header navigation
70-
"mn" 'outline-next-visible-heading
7170
"mp" 'outline-previous-visible-heading
72-
"mf" 'outline-forward-same-level
73-
"mb" 'outline-backward-same-level
74-
"mu" 'outline-up-heading
7571
;; Buffer-wide commands
7672
"mc]" 'markdown-complete-buffer
7773
"mcm" 'markdown-other-window
@@ -83,16 +79,25 @@
8379
"mcc" 'markdown-check-refs
8480
"mcn" 'markdown-cleanup-list-numbers
8581
;; List editing
86-
"mlk" 'markdown-move-up
87-
"mlj" 'markdown-move-down
88-
"mlh" 'markdown-promote
89-
"mll" 'markdown-demote
9082
"mli" 'markdown-insert-list-item
9183
;; Movement
9284
"m{" 'markdown-backward-paragraph
9385
"m}" 'markdown-forward-paragraph
9486
"mN" 'markdown-next-link
95-
"mP" 'markdown-previous-link))))
87+
"mP" 'markdown-previous-link)
88+
89+
;; normal state movements
90+
(evil-define-key 'normal markdown-mode-map
91+
"gj" 'outline-forward-same-level
92+
"gk" 'outline-backward-same-level
93+
"gh" 'outline-up-heading
94+
;; next visible heading is not exactly what we want but close enough
95+
"gl" 'outline-next-visible-heading
96+
)
97+
(define-key markdown-mode-map (kbd "M-k") 'markdown-move-up)
98+
(define-key markdown-mode-map (kbd "M-j") 'markdown-move-down)
99+
(define-key markdown-mode-map (kbd "M-h") 'markdown-promote)
100+
(define-key markdown-mode-map (kbd "M-l") 'markdown-demote))))
96101

97102
(defun markdown/init-markdown-toc ()
98103
(use-package markdown-toc

contrib/org/packages.el

+38-6
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@
3737
"a" nil "ma" 'org-agenda
3838
"c" nil "mA" 'org-archive-subtree
3939
"o" nil "mC" 'evil-org-recompute-clocks
40-
"l" nil "ml" 'evil-org-open-links
41-
"t" nil "mt" 'org-show-todo-tree)
40+
"l" nil "m <RET>" 'evil-org-open-links
41+
"t" nil "mT" 'org-show-todo-tree)
42+
(evil-define-key 'normal evil-org-mode-map
43+
"O" 'evil-open-above
44+
)
4245
(spacemacs|diminish evil-org-mode "" " e"))))
4346

4447
(defun org/init-org ()
@@ -53,20 +56,43 @@
5356
'(spacemacs|hide-lighter org-indent-mode))
5457
(setq org-startup-indented t)
5558

59+
(defmacro spacemacs|org-emphasize (fname char)
60+
"Make function for setting the emphasize in org mode"
61+
`(defun ,fname () (interactive)
62+
(org-emphasize ,char))
63+
)
5664
(evil-leader/set-key-for-mode 'org-mode
5765
"mc" 'org-capture
5866
"md" 'org-deadline
5967
"me" 'org-export-dispatch
6068
"mf" 'org-set-effort
61-
"mi" 'org-clock-in
69+
"mI" 'org-clock-in
6270
"mj" 'helm-org-in-buffer-headings
63-
"mo" 'org-clock-out
6471
"mm" 'org-ctrl-c-ctrl-c
72+
(concat "m" dotspacemacs-major-mode-leader-key) 'org-ctrl-c-ctrl-c
6573
"mn" 'org-narrow-to-subtree
6674
"mN" 'widen
75+
"mO" 'org-clock-out
6776
"mq" 'org-clock-cancel
6877
"mr" 'org-refile
69-
"ms" 'org-schedule)
78+
"mS" 'org-schedule
79+
;; headings
80+
"mhh" 'org-insert-heading-after-current
81+
"mhH" 'org-insert-heading
82+
;; insertion of common elements
83+
"mil" 'org-insert-link
84+
"mif" 'org-footnote-new
85+
;; images and other link types have no commands in org mode-line
86+
;; could be inserted using yasnippet?
87+
;; text manipulation
88+
"mtb" (spacemacs|org-emphasize spacemacs/org-bold ?*)
89+
"mti" (spacemacs|org-emphasize spacemacs/org-italic ?/)
90+
"mtc" (spacemacs|org-emphasize spacemacs/org-code ?~)
91+
"mtu" (spacemacs|org-emphasize spacemacs/org-underline ?_)
92+
"mtv" (spacemacs|org-emphasize spacemacs/org-verbose ?=)
93+
"mts" (spacemacs|org-emphasize spacemacs/org-strike-through ?+)
94+
"mt <SPC>" (spacemacs|org-emphasize spacemacs/org-clear ? )
95+
)
7096

7197
(eval-after-load "org-agenda"
7298
'(progn
@@ -81,7 +107,13 @@
81107
(progn
82108
(require 'org-indent)
83109
(define-key global-map "\C-cl" 'org-store-link)
84-
(define-key global-map "\C-ca" 'org-agenda))))
110+
(define-key global-map "\C-ca" 'org-agenda)
111+
(evil-leader/set-key
112+
"Cc" 'org-capture
113+
)
114+
))
115+
116+
)
85117

86118
(defun org/init-org-bullets ()
87119
(use-package org-bullets

0 commit comments

Comments
 (0)