diff --git a/modules/lang/text/autoload.el b/modules/lang/text/autoload.el new file mode 100644 index 000000000..3b0312305 --- /dev/null +++ b/modules/lang/text/autoload.el @@ -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))))) + diff --git a/modules/lang/text/config.el b/modules/lang/text/config.el index ab1f4c2fa..6662fd441 100644 --- a/modules/lang/text/config.el +++ b/modules/lang/text/config.el @@ -1,15 +1,9 @@ -;;; module-text.el +;;; lang/text/config.el -(associate! text-mode :match "/LICENSE$") - -(use-package markdown-mode +(@def-package markdown-mode :mode ("\\.m\\(d\\|arkdown\\)$" "/README$" ("/README\\.md$" . gfm-mode)) :init - (add-hook! markdown-mode - (auto-fill-mode +1) - (setq line-spacing 2 - fill-column 70)) (setq markdown-enable-wiki-links t markdown-enable-math t markdown-italic-underscore t @@ -17,23 +11,27 @@ markdown-gfm-additional-languages '("sh")) :config - (def-electric! markdown-mode :chars ("+" "#")) + (@add-hook markdown-mode + (auto-fill-mode +1) + (setq line-spacing 2 + fill-column 70)) (sp-local-pair '(markdown-mode gfm-mode) "\`\`\`" "\`\`\`" :post-handlers '(("||\n" "RET"))) - (map! :map gfm-mode-map "`" 'self-insert-command) - (map! :map markdown-mode-map + (@set :electric-chars "+" "#") + (@map :map gfm-mode-map "`" 'self-insert-command) + (@map :map markdown-mode-map "" nil "" nil "" nil "M-*" 'markdown-insert-list-item "M-b" 'markdown-insert-bold "M-i" 'markdown-insert-italic - "M-`" 'doom/markdown-insert-del + "M-`" '+text/markdown-insert-del ;; 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 :n "[p" 'markdown-promote :n "]p" 'markdown-demote @@ -44,11 +42,11 @@ :nv "L" 'markdown-insert-reference-link-dwim :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) - :config (def-builder! rst-mode rst-compile-pdf-preview)) - -(provide 'module-text) -;;; module-text.el ends here + :config (@set :builder '(rst-mode rst-compile-pdf-preview))) diff --git a/modules/lang/text/packages.el b/modules/lang/text/packages.el new file mode 100644 index 000000000..250ee2d93 --- /dev/null +++ b/modules/lang/text/packages.el @@ -0,0 +1,6 @@ +;; -*- no-byte-compile: t; -*- +;;; lang/text/packages.el + +(@package markdown-mode) +(@package markdown-toc) +