2015-06-04 18:23:21 -04:00
|
|
|
(add-hook 'text-mode-hook 'narf|enable-hard-wrap)
|
|
|
|
(add-hook 'prog-mode-hook 'narf|enable-comment-hard-wrap)
|
2014-11-29 20:21:03 -05:00
|
|
|
|
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))
|
2015-06-04 18:23:21 -04:00
|
|
|
:functions (markdown-use-region-p markdown-unwrap-things-in-region
|
|
|
|
markdown-wrap-or-insert markdown-unwrap-thing-at-point)
|
2015-03-17 02:35:59 -04:00
|
|
|
:init
|
|
|
|
;; Implement strike-through formatting
|
|
|
|
(defvar markdown-regex-del "\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)")
|
2014-11-29 20:21:03 -05:00
|
|
|
:config
|
2014-12-12 15:26:34 -05:00
|
|
|
(progn
|
2015-03-17 02:35:59 -04:00
|
|
|
(defun markdown-insert-del ()
|
2015-04-23 00:31:54 -04:00
|
|
|
(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)
|
|
|
|
(markdown-wrap-or-insert delim delim 'word nil nil)))))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
(sp-local-pair 'markdown-mode "*" "*"
|
|
|
|
:unless '(sp-point-after-bol-p sp-point-before-same-p sp-point-after-same-p))
|
|
|
|
|
|
|
|
(bind :map markdown-mode-map
|
|
|
|
"<backspace>" nil
|
|
|
|
"<M-left>" nil
|
|
|
|
"<M-right>" nil
|
|
|
|
|
|
|
|
"M-*" 'markdown-insert-list-item
|
|
|
|
"M-b" 'markdown-insert-bold
|
|
|
|
"M-i" 'markdown-insert-italic
|
|
|
|
"M-`" 'markdown-insert-del
|
|
|
|
|
|
|
|
:normal :visual
|
|
|
|
",i" 'markdown-insert-image
|
|
|
|
",l" 'markdown-insert-link
|
|
|
|
",L" 'markdown-insert-reference-link-dwim
|
|
|
|
",b" 'markdown-preview
|
|
|
|
|
|
|
|
:normal
|
|
|
|
"[p" 'markdown-promote
|
|
|
|
"]p" 'markdown-demote
|
|
|
|
|
|
|
|
:insert
|
|
|
|
"M--" 'markdown-insert-hr)))
|
2014-12-12 15:35:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
(provide 'init-text)
|
|
|
|
;;; init-text.el ends here
|