2014-09-05 17:08:40 -04:00
|
|
|
(provide 'init-text)
|
2014-08-07 18:35:22 -04:00
|
|
|
|
2014-11-29 20:21:03 -05:00
|
|
|
(add-hook 'text-mode-hook 'turn-on-auto-fill)
|
|
|
|
(add-hook 'prog-mode-hook 'enable-comment-hard-wrap)
|
|
|
|
|
2014-08-29 22:37:25 -04:00
|
|
|
(use-package markdown-mode
|
2014-12-05 17:28:03 -05:00
|
|
|
:mode (("\\.md$" . markdown-mode)
|
|
|
|
("/README$" . markdown-mode))
|
2014-09-20 16:54:04 -04:00
|
|
|
:pre-load
|
2014-08-21 03:33:30 -04:00
|
|
|
(progn
|
2014-09-30 16:35:53 -04:00
|
|
|
;; Implement strike-through formatting
|
2014-09-20 16:54:04 -04:00
|
|
|
(defvar markdown-regex-del "\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)")
|
|
|
|
(defun markdown-insert-del ()
|
|
|
|
(interactive)
|
|
|
|
(let ((delim "~~"))
|
|
|
|
(if (markdown-use-region-p)
|
|
|
|
;; Active region
|
|
|
|
(let ((bounds (markdown-unwrap-things-in-region
|
|
|
|
(region-beginning) (region-end)
|
|
|
|
markdown-regex-del 2 4)))
|
|
|
|
(markdown-wrap-or-insert delim delim nil (car bounds) (cdr bounds)))
|
|
|
|
;; Bold markup removal, bold word at point, or empty markup insertion
|
|
|
|
(if (thing-at-point-looking-at markdown-regex-del)
|
|
|
|
(markdown-unwrap-thing-at-point nil 2 4)
|
2014-11-29 20:21:03 -05:00
|
|
|
(markdown-wrap-or-insert delim delim 'word nil nil))))))
|
|
|
|
:config
|
|
|
|
(let ((map markdown-mode-map))
|
|
|
|
(bind '(normal visual) map
|
|
|
|
",i" 'markdown-insert-image
|
|
|
|
",l" 'markdown-insert-link
|
|
|
|
",L" 'markdown-insert-reference-link-dwim
|
|
|
|
",b" 'markdown-preview)
|
|
|
|
|
|
|
|
(bind 'normal map
|
|
|
|
"[p" 'markdown-promote
|
|
|
|
"]p" 'markdown-demote)
|
|
|
|
|
|
|
|
(bind 'insert map
|
|
|
|
(kbd "M--") 'markdown-insert-hr)
|
|
|
|
|
|
|
|
(bind map
|
|
|
|
(kbd "<backspace>") nil
|
|
|
|
(kbd "<M-left>") nil
|
|
|
|
(kbd "<M-right>") nil
|
|
|
|
|
|
|
|
(kbd "s-*") 'markdown-insert-list-item
|
|
|
|
(kbd "s-b") 'markdown-insert-bold
|
|
|
|
(kbd "s-i") 'markdown-insert-italic
|
|
|
|
(kbd "s-`") 'markdown-insert-del)))
|