2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/markdown/autoload.el -*- lexical-binding: t; -*-
|
2017-02-11 07:07:26 -05:00
|
|
|
|
|
|
|
;; Implement strike-through formatting
|
2017-06-08 11:47:56 +02:00
|
|
|
(defvar +markdown--regex-del
|
2017-02-11 07:07:26 -05:00
|
|
|
"\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)")
|
|
|
|
|
|
|
|
;;;###autoload
|
2017-02-19 18:57:16 -05:00
|
|
|
(defun +markdown/insert-del ()
|
2017-02-11 07:07:26 -05:00
|
|
|
"Surround region in github strike-through delimiters."
|
|
|
|
(interactive)
|
|
|
|
(let ((delim "~~"))
|
|
|
|
(if (markdown-use-region-p)
|
|
|
|
;; Active region
|
2017-06-25 02:04:50 +02:00
|
|
|
(cl-destructuring-bind (beg end)
|
2017-06-08 11:47:56 +02:00
|
|
|
(markdown-unwrap-things-in-region
|
|
|
|
(region-beginning) (region-end)
|
|
|
|
+markdown--regex-del 2 4)
|
|
|
|
(markdown-wrap-or-insert delim delim nil beg end))
|
2017-02-11 07:07:26 -05:00
|
|
|
;; Bold markup removal, bold word at point, or empty markup insertion
|
2017-06-08 11:47:56 +02:00
|
|
|
(if (thing-at-point-looking-at +markdown--regex-del)
|
2017-02-11 07:07:26 -05:00
|
|
|
(markdown-unwrap-thing-at-point nil 2 4)
|
|
|
|
(markdown-wrap-or-insert delim delim 'word nil nil)))))
|
2019-02-26 16:46:26 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +markdown-flyspell-word-p ()
|
|
|
|
"Return t if point is on a word that should be spell checked.
|
|
|
|
|
|
|
|
Return nil if on a link url, markup, html, or references."
|
|
|
|
(let ((faces (doom-enlist (get-text-property (point) 'face))))
|
|
|
|
(or (and (memq 'font-lock-comment-face faces)
|
|
|
|
(memq 'markdown-code-face faces))
|
|
|
|
(not (cl-loop with unsafe-faces = '(markdown-reference-face
|
|
|
|
markdown-url-face
|
|
|
|
markdown-markup-face
|
|
|
|
markdown-comment-face
|
|
|
|
markdown-html-attr-name-face
|
|
|
|
markdown-html-attr-value-face
|
|
|
|
markdown-html-tag-name-face
|
|
|
|
markdown-code-face)
|
|
|
|
for face in faces
|
|
|
|
if (memq face unsafe-faces)
|
|
|
|
return t)))))
|