From 7b6678efd6cece5bbb3419579590b843943f9e13 Mon Sep 17 00:00:00 2001 From: Christoph Paulik Date: Mon, 13 Apr 2015 10:09:50 +0200 Subject: [PATCH] Org markdown: Improve consistency of key bindings for markup language --- contrib/lang/markdown/README.md | 2 +- contrib/lang/markdown/packages.el | 77 ++++++++++++++++--------------- contrib/org/packages.el | 44 +++++++++++++++--- 3 files changed, 80 insertions(+), 43 deletions(-) diff --git a/contrib/lang/markdown/README.md b/contrib/lang/markdown/README.md index d8a3539b4..8190e22af 100644 --- a/contrib/lang/markdown/README.md +++ b/contrib/lang/markdown/README.md @@ -49,7 +49,7 @@ To generate a table of contents type on top of the buffer: Key Binding | Description ----------------------|------------------------------------------------------------ -SPC m " | insert hr +SPC m - | insert hr SPC m a l | insert link SPC m a L | insert reference link dwim SPC m a u | insert uri diff --git a/contrib/lang/markdown/packages.el b/contrib/lang/markdown/packages.el index a3f877e52..de6eeb2ab 100644 --- a/contrib/lang/markdown/packages.el +++ b/contrib/lang/markdown/packages.el @@ -28,50 +28,46 @@ (sp-local-pair 'markdown-mode "'" nil :actions nil)) (progn (evil-leader/set-key-for-mode 'markdown-mode - ;; Element insertion - "m\"" 'markdown-insert-hr - "mal" 'markdown-insert-link - "maL" 'markdown-insert-reference-link-dwim - "mau" 'markdown-insert-uri - "maf" 'markdown-insert-footnote - "maw" 'markdown-insert-wiki-link + ;; Insertion of common elements + "m-" 'markdown-insert-hr + "mil" 'markdown-insert-link + "miL" 'markdown-insert-reference-link-dwim + "miu" 'markdown-insert-uri + "mif" 'markdown-insert-footnote + "miw" 'markdown-insert-wiki-link "mii" 'markdown-insert-image "miI" 'markdown-insert-reference-image - "mth" 'markdown-insert-header-dwim - "mtH" 'markdown-insert-header-setext-dwim - "mt1" 'markdown-insert-header-atx-1 - "mt2" 'markdown-insert-header-atx-2 - "mt3" 'markdown-insert-header-atx-3 - "mt4" 'markdown-insert-header-atx-4 - "mt5" 'markdown-insert-header-atx-5 - "mt6" 'markdown-insert-header-atx-6 - "mt!" 'markdown-insert-header-setext-1 - "mt@" 'markdown-insert-header-setext-2 - "mss" 'markdown-insert-bold - "mse" 'markdown-insert-italic - "msc" 'markdown-insert-code - "msb" 'markdown-insert-blockquote - "msB" 'markdown-blockquote-region - "msp" 'markdown-insert-pre - "msP" 'markdown-pre-region + ;; headings + "mhh" 'markdown-insert-header-dwim + "mhH" 'markdown-insert-header-setext-dwim + "mh1" 'markdown-insert-header-atx-1 + "mh2" 'markdown-insert-header-atx-2 + "mh3" 'markdown-insert-header-atx-3 + "mh4" 'markdown-insert-header-atx-4 + "mh5" 'markdown-insert-header-atx-5 + "mh6" 'markdown-insert-header-atx-6 + "mh!" 'markdown-insert-header-setext-1 + "mh@" 'markdown-insert-header-setext-2 + ;; text manipulation + "mtb" 'markdown-insert-bold + "mti" 'markdown-insert-italic + "mtc" 'markdown-insert-code + "mtq" 'markdown-insert-blockquote + "mtQ" 'markdown-blockquote-region + "mtp" 'markdown-insert-pre + "mtP" 'markdown-pre-region ;; Element removal "mk" 'markdown-kill-thing-at-point ;; Promotion, Demotion, Completion, and Cycling - "m=" 'markdown-promote - "m-" 'markdown-demote "m]" 'markdown-complete ;; Following and Jumping "mo" 'markdown-follow-thing-at-point - "mj" 'markdown-jump + "m " 'markdown-jump ;; Indentation "m>" 'markdown-indent-region "m<" 'markdown-exdent-region ;; Header navigation - "mn" 'outline-next-visible-heading "mp" 'outline-previous-visible-heading - "mf" 'outline-forward-same-level - "mb" 'outline-backward-same-level - "mu" 'outline-up-heading ;; Buffer-wide commands "mc]" 'markdown-complete-buffer "mcm" 'markdown-other-window @@ -83,16 +79,25 @@ "mcc" 'markdown-check-refs "mcn" 'markdown-cleanup-list-numbers ;; List editing - "mlk" 'markdown-move-up - "mlj" 'markdown-move-down - "mlh" 'markdown-promote - "mll" 'markdown-demote "mli" 'markdown-insert-list-item ;; Movement "m{" 'markdown-backward-paragraph "m}" 'markdown-forward-paragraph "mN" 'markdown-next-link - "mP" 'markdown-previous-link)))) + "mP" 'markdown-previous-link) + + ;; normal state movements + (evil-define-key 'normal markdown-mode-map + "gj" 'outline-forward-same-level + "gk" 'outline-backward-same-level + "gh" 'outline-up-heading + ;; next visible heading is not exactly what we want but close enough + "gl" 'outline-next-visible-heading + ) + (define-key markdown-mode-map (kbd "M-k") 'markdown-move-up) + (define-key markdown-mode-map (kbd "M-j") 'markdown-move-down) + (define-key markdown-mode-map (kbd "M-h") 'markdown-promote) + (define-key markdown-mode-map (kbd "M-l") 'markdown-demote)))) (defun markdown/init-markdown-toc () (use-package markdown-toc diff --git a/contrib/org/packages.el b/contrib/org/packages.el index 0a2df542c..a13454136 100644 --- a/contrib/org/packages.el +++ b/contrib/org/packages.el @@ -37,8 +37,11 @@ "a" nil "ma" 'org-agenda "c" nil "mA" 'org-archive-subtree "o" nil "mC" 'evil-org-recompute-clocks - "l" nil "ml" 'evil-org-open-links - "t" nil "mt" 'org-show-todo-tree) + "l" nil "m " 'evil-org-open-links + "t" nil "mT" 'org-show-todo-tree) + (evil-define-key 'normal evil-org-mode-map + "O" 'evil-open-above + ) (spacemacs|diminish evil-org-mode " ⓔ" " e")))) (defun org/init-org () @@ -53,20 +56,43 @@ '(spacemacs|hide-lighter org-indent-mode)) (setq org-startup-indented t) + (defmacro spacemacs|org-emphasize (fname char) + "Make function for setting the emphasize in org mode" + `(defun ,fname () (interactive) + (org-emphasize ,char)) + ) (evil-leader/set-key-for-mode 'org-mode "mc" 'org-capture "md" 'org-deadline "me" 'org-export-dispatch "mf" 'org-set-effort - "mi" 'org-clock-in + "mI" 'org-clock-in "mj" 'helm-org-in-buffer-headings - "mo" 'org-clock-out "mm" 'org-ctrl-c-ctrl-c + (concat "m" dotspacemacs-major-mode-leader-key) 'org-ctrl-c-ctrl-c "mn" 'org-narrow-to-subtree "mN" 'widen + "mO" 'org-clock-out "mq" 'org-clock-cancel "mr" 'org-refile - "ms" 'org-schedule) + "mS" 'org-schedule + ;; headings + "mhh" 'org-insert-heading-after-current + "mhH" 'org-insert-heading + ;; insertion of common elements + "mil" 'org-insert-link + "mif" 'org-footnote-new + ;; images and other link types have no commands in org mode-line + ;; could be inserted using yasnippet? + ;; text manipulation + "mtb" (spacemacs|org-emphasize spacemacs/org-bold ?*) + "mti" (spacemacs|org-emphasize spacemacs/org-italic ?/) + "mtc" (spacemacs|org-emphasize spacemacs/org-code ?~) + "mtu" (spacemacs|org-emphasize spacemacs/org-underline ?_) + "mtv" (spacemacs|org-emphasize spacemacs/org-verbose ?=) + "mts" (spacemacs|org-emphasize spacemacs/org-strike-through ?+) + "mt " (spacemacs|org-emphasize spacemacs/org-clear ? ) + ) (eval-after-load "org-agenda" '(progn @@ -81,7 +107,13 @@ (progn (require 'org-indent) (define-key global-map "\C-cl" 'org-store-link) - (define-key global-map "\C-ca" 'org-agenda)))) + (define-key global-map "\C-ca" 'org-agenda) + (evil-leader/set-key + "Cc" 'org-capture + ) + )) + + ) (defun org/init-org-bullets () (use-package org-bullets