Add lang/text
This commit is contained in:
parent
2df2c9298f
commit
6f67dff8f2
3 changed files with 45 additions and 19 deletions
22
modules/lang/text/autoload.el
Normal file
22
modules/lang/text/autoload.el
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
;;; lang/text/autoload.el
|
||||||
|
|
||||||
|
;; Implement strike-through formatting
|
||||||
|
(defvar +text--markdown-regex-del
|
||||||
|
"\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)")
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +text/markdown-insert-del ()
|
||||||
|
"Surround region in github strike-through delimiters."
|
||||||
|
(interactive)
|
||||||
|
(let ((delim "~~"))
|
||||||
|
(if (markdown-use-region-p)
|
||||||
|
;; Active region
|
||||||
|
(let ((bounds (markdown-unwrap-things-in-region
|
||||||
|
(region-beginning) (region-end)
|
||||||
|
+text--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 +text--markdown-regex-del)
|
||||||
|
(markdown-unwrap-thing-at-point nil 2 4)
|
||||||
|
(markdown-wrap-or-insert delim delim 'word nil nil)))))
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
;;; module-text.el
|
;;; lang/text/config.el
|
||||||
|
|
||||||
(associate! text-mode :match "/LICENSE$")
|
(@def-package markdown-mode
|
||||||
|
|
||||||
(use-package markdown-mode
|
|
||||||
:mode ("\\.m\\(d\\|arkdown\\)$" "/README$"
|
:mode ("\\.m\\(d\\|arkdown\\)$" "/README$"
|
||||||
("/README\\.md$" . gfm-mode))
|
("/README\\.md$" . gfm-mode))
|
||||||
:init
|
:init
|
||||||
(add-hook! markdown-mode
|
|
||||||
(auto-fill-mode +1)
|
|
||||||
(setq line-spacing 2
|
|
||||||
fill-column 70))
|
|
||||||
(setq markdown-enable-wiki-links t
|
(setq markdown-enable-wiki-links t
|
||||||
markdown-enable-math t
|
markdown-enable-math t
|
||||||
markdown-italic-underscore t
|
markdown-italic-underscore t
|
||||||
|
@ -17,23 +11,27 @@
|
||||||
markdown-gfm-additional-languages '("sh"))
|
markdown-gfm-additional-languages '("sh"))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(def-electric! markdown-mode :chars ("+" "#"))
|
(@add-hook markdown-mode
|
||||||
|
(auto-fill-mode +1)
|
||||||
|
(setq line-spacing 2
|
||||||
|
fill-column 70))
|
||||||
|
|
||||||
(sp-local-pair
|
(sp-local-pair
|
||||||
'(markdown-mode gfm-mode)
|
'(markdown-mode gfm-mode)
|
||||||
"\`\`\`" "\`\`\`" :post-handlers '(("||\n" "RET")))
|
"\`\`\`" "\`\`\`" :post-handlers '(("||\n" "RET")))
|
||||||
|
|
||||||
(map! :map gfm-mode-map "`" 'self-insert-command)
|
(@set :electric-chars "+" "#")
|
||||||
(map! :map markdown-mode-map
|
(@map :map gfm-mode-map "`" 'self-insert-command)
|
||||||
|
(@map :map markdown-mode-map
|
||||||
"<backspace>" nil
|
"<backspace>" nil
|
||||||
"<M-left>" nil
|
"<M-left>" nil
|
||||||
"<M-right>" nil
|
"<M-right>" nil
|
||||||
"M-*" 'markdown-insert-list-item
|
"M-*" 'markdown-insert-list-item
|
||||||
"M-b" 'markdown-insert-bold
|
"M-b" 'markdown-insert-bold
|
||||||
"M-i" 'markdown-insert-italic
|
"M-i" 'markdown-insert-italic
|
||||||
"M-`" 'doom/markdown-insert-del
|
"M-`" '+text/markdown-insert-del
|
||||||
;; Assumes you have a markdown renderer plugin in chrome
|
;; Assumes you have a markdown renderer plugin in chrome
|
||||||
:nv "M-r" (λ! (doom-open-with "Google Chrome"))
|
:nv "M-r" (@λ (doom-open-with "Google Chrome"))
|
||||||
;; TODO: Make context sensitive
|
;; TODO: Make context sensitive
|
||||||
:n "[p" 'markdown-promote
|
:n "[p" 'markdown-promote
|
||||||
:n "]p" 'markdown-demote
|
:n "]p" 'markdown-demote
|
||||||
|
@ -44,11 +42,11 @@
|
||||||
:nv "L" 'markdown-insert-reference-link-dwim
|
:nv "L" 'markdown-insert-reference-link-dwim
|
||||||
:nv "b" 'markdown-preview)))
|
:nv "b" 'markdown-preview)))
|
||||||
|
|
||||||
(use-package markdown-toc :after markdown-mode)
|
|
||||||
|
|
||||||
(use-package rst
|
(@def-package markdown-toc
|
||||||
|
:after markdown-mode)
|
||||||
|
|
||||||
|
|
||||||
|
(@def-package rst ; built-in
|
||||||
:mode ("\\.re?st$" . rst-mode)
|
:mode ("\\.re?st$" . rst-mode)
|
||||||
:config (def-builder! rst-mode rst-compile-pdf-preview))
|
:config (@set :builder '(rst-mode rst-compile-pdf-preview)))
|
||||||
|
|
||||||
(provide 'module-text)
|
|
||||||
;;; module-text.el ends here
|
|
||||||
|
|
6
modules/lang/text/packages.el
Normal file
6
modules/lang/text/packages.el
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
;; -*- no-byte-compile: t; -*-
|
||||||
|
;;; lang/text/packages.el
|
||||||
|
|
||||||
|
(@package markdown-mode)
|
||||||
|
(@package markdown-toc)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue