sharkey-el/mfm/small.el

42 lines
1.7 KiB
EmacsLisp

(defvar sharkey/small-rx
;; this might display a bit weird... sorgy
(rx (group-n 1 "<small" ">")
(group-n 2 (+? (or "\n" any)))
(group-n 3 "</small" ">")))
(defun next-small-overlay (&optional limit)
"logic from `next-emoji-overlay' but for mfm <small></small> tag."
(while (re-search-forward sharkey/small-rx limit t)
(let* ((openr-beg (match-beginning 1))
(openr-end (match-end 1))
(text-beg (match-beginning 2))
(text-end (match-end 2))
(close-beg (match-beginning 3))
(close-end (match-end 3))
(placehoverlay (make-overlay openr-beg close-end))
(openr-ov (make-overlay openr-beg openr-end))
(close-ov (make-overlay close-beg close-end))
(text (buffer-substring text-beg text-end))
(text-ov (make-overlay text-beg text-end))
)
;; (overlay-put openr-ov 'display "")
;; (overlay-put close-ov 'display "")
;; (put-text-property openr-beg openr-end 'invisible t)
;; (put-text-property close-beg close-end 'invisible t)
;; (overlay-put text-ov 'help-echo text)
;; (put-text-property text-beg text-end 'display '(height 0.8))
(overlay-put placehoverlay 'display '(height 0.8))
(overlay-put placehoverlay 'mfm-tag "small")
(overlay-put placehoverlay 'modification-hooks
(list
'mir/remove-all-overlays
'org-display-inline-remove-overlay))
(overlay-put openr-ov 'modification-hooks
(list 'org-display-inline-remove-overlay))
(overlay-put close-ov 'modification-hooks
(list 'org-display-inline-remove-overlay))
;; (overlay-put openr-ov 'org-image-overlay t)
;; (overlay-put close-ov 'org-image-overlay t)
;; (overlay-put text-ov 'org-image-overlay t)
)))