io12 / org-fragtog

Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
MIT License
397 stars 14 forks source link

Question: avoid creation of new buffer with dvipng message #8

Closed nettoyoussef closed 4 years ago

nettoyoussef commented 4 years ago

Hi, first of all, thanks for the awesome package! I use it daily.

My question is the following: every time we have to compile a new equation, org-fragtog calls org-latex-preview which converts the latex to an image that appears on the Emacs buffer.

Unfortunately, every time a new equation is inserted, org-latex-preview calls dvipng which opens a new buffer with the message:

"This is dvipng 1.16 Copyright 2002-2015, 2019 Jan-Ake Larsson [1] ".

Is there a way to suppress this buffer to open in the first place, or to make it open only when there is an error? When you are creating lots of equations in a row this gets in the way and stops the flow.

Thanks!

io12 commented 4 years ago

It doesn't open a new buffer for me, and i have org-preview-latex-default-process set to dvipng. Maybe there is some other setting or package causing this?

nettoyoussef commented 4 years ago

Hi io12!

It seems that frames-only-mode is causing the issue. I tried the package without it and it works perfectly. So I guess you can close this issue.

I am a beginner emacser. Would you know how would I create a hook or advice to kill the window automatically afterward?

I crafted this function, but it only works when I call it. The hook doesn't work and I am not sure why.

(defun kill-latex-preview-window ()
  (interactive
  (let ((buffer "*Org Preview LaTeX Output*"))
    (if (get-buffer buffer)
        (progn
        (delete-frame (select-frame-by-name buffer))
        (kill-buffer buffer)
        )
     )
   )
  )
)

(add-hook 'post-command-hook 'kill-latex-preview-window )
io12 commented 4 years ago

This sounds like a frames-only-mode bug. About the hook issue you're having, I think it can be fixed by making the function not interactive.

nettoyoussef commented 4 years ago

Hi @io12, thanks for your concern!

Unfortunately, removing the (interactive) clause didn't solve it.

I opened an issue in the frames-only-mode repo.