I have a quick & dirty proof of concept for markdown-mode. Idea: keep track of the current line (similar to hl-line-mode). Use a font-lock rule to remove the markup hiding for the current line (markdown-mode seems to use display
and invisible
text properties, so remove those). Re-fontify the local area when moving from one line to another.
(defvar my/current-line '(0 . 0)
"(start . end) of current line in current buffer")
(make-variable-buffer-local 'my/current-line)
(defun my/unhide-current-line (limit)
"Font-lock function"
(let ((start (max (point) (car my/current-line)))
(end (min limit (cdr my/current-line))))
(when (< start end)
(remove-text-properties start end
'(invisible t display "" composition ""))
(goto-char limit)
t)))
(defun my/refontify-on-linemove ()
"Post-command-hook"
(let* ((start (line-beginning-position))
(end (line-beginning-position 2))
(needs-update (not (equal start (car my/current-line)))))
(setq my/current-line (cons start end))
(when needs-update
(font-lock-fontify-block 3))))
(defun my/markdown-unhighlight ()
"Install"
(markdown-toggle-markup-hiding 1)
(font-lock-add-keywords nil '((my/unhide-current-line)) t)
(add-hook 'post-command-hook #'my/refontify-on-linemove nil t))
(add-hook 'markdown-mode-hook #'my/markdown-unhighlight)
I don't know if this is the best way to do it. I'm seeing some occasional errors in the message area but it seems to be working ok so far.
Edit: also works in org mode with (add-hook 'org-mode-hook #'my/markdown-unhighlight)