Skip to content

Commit 01b4254

Browse files
committed
Rewrite hinter: use eldoc instead
Use `message` in `post-command-hook` causes the text blinks whenever you type in a latex fragment. So we switch to eldoc.
1 parent 11481d0 commit 01b4254

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

org-edit-latex.el

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@
9999
(advice-add #'org-edit-special :around #'org-edit-latex--wrap-maybe)
100100
(advice-add #'org-edit-src-exit :around #'org-edit-latex--unwrap-maybe)
101101
(when org-edit-latex-show-hint
102-
(add-hook 'post-command-hook #'org-edit-latex-smart-hint t t))
102+
(setq-local eldoc-documentation-function 'org-edit-latex-hinter))
103103
(org-edit-latex-create-master-maybe)
104104
(add-hook 'org-src-mode-hook #'org-edit-latex--set-TeX-master))
105105
(advice-remove #'org-edit-special #'org-edit-latex--wrap-maybe)
106106
(advice-remove #'org-edit-src-exit #'org-edit-latex--unwrap-maybe)
107-
(remove-hook 'post-command-hook #'org-edit-latex-smart-hint t)
107+
(setq-local eldoc-documentation-function 'org-eldoc-documentation-function)
108108
(remove-hook 'org-src-mode-hook #'org-edit-latex--set-TeX-master)))
109109

110110

@@ -309,14 +309,19 @@ latex-environment."
309309
(apply oldfun args)))
310310
(apply oldfun args)))
311311

312-
;;;###autoload
313-
(defun org-edit-latex-smart-hint ()
314-
"Show a hint message in echo-area when user is in LaTeX environment."
315-
(if (and (equal major-mode 'org-mode)
316-
(member (car (org-element-context))
317-
'(latex-fragment latex-environment)))
318-
(message (substitute-command-keys
319-
"Enter edit buffer with `\\[org-edit-special]'."))))
312+
(defun org-edit-latex-hinter ()
313+
"An Eldoc documentation function used as a replacement of the
314+
default one in Org mode."
315+
(or (org-eldoc-documentation-function)
316+
(org-edit-latex-eldoc-function)))
317+
318+
(defun org-edit-latex-eldoc-function ()
319+
"Eldoc function used to generate a hint when cursor on latex."
320+
(let ((ele-type (org-element-type (org-element-context))))
321+
(when (or (eq ele-type 'latex-fragment)
322+
(eq ele-type 'latex-environment))
323+
(substitute-command-keys
324+
"Enter edit buffer with `\\[org-edit-special]'."))))
320325

321326

322327
(provide 'org-edit-latex)

0 commit comments

Comments
 (0)