emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: org-toggle-latex-fragment doesn't work as documented [9.2.1


From: Nicolas Goaziou
Subject: Re: [O] Bug: org-toggle-latex-fragment doesn't work as documented [9.2.1 (release_9.2.1-60-gb0379f @ /home/carlos/local/stow/emacs/share/emacs/site-lisp/org/)]
Date: Tue, 12 Feb 2019 22:45:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello,

Carlos Pita <address@hidden> writes:

> A last suggestion. Incidentally the toggle returns nil when at least a
> fragment is unpreviewed and non-nil otherwise (as a side effect of
> message). This can be documented and made part of the interface, so
> that something like the following can be put together by the end user:
>
> (defun my-org-preview-latex (&optional arg)
>   (interactive "P")
>   (unless (org-toggle-latex-fragment arg)
>     (org-toggle-latex-fragment arg)))
> I insist on the importance of the use case "force preview" because
> it's very useful to quickly jot down a paragraph or part of a
> paragraph with many simple latex fragments like $x_i$, $f(x)$, etc.
> and then, afterwards, type C-c C-x C-l to preview the last entered
> part of the paragraph, instead of painfully entering C-c C-x C-l after
> any single $x$ or similar. Now, if the toggle prefers removing
> previews as it's the case, this won't work because, in general, you
> already have some preview in the same section or paragraph.

Here is my take on the issue.

First, I think the current behaviour is as it is because deleting
overlays is fast, whereas checking if some LaTeX fragments are not
previewed is slow. So, there is little overhead to first delete them: if
that is what you wanted, you win, if you wanted to preview more
fragments, you only need to hit `C-c C-x C-l` a second time. OTOH, if we
do the opposite, as you suggest, you gain one `C-c C-x C-l' -- or any
shorter binding -- in the latter case, but can waste a lot of time in
the former case, i.e., quitting preview is not fast anymore.

In any case, I agree the current behavior is slightly confusing. At
least, we could clean the overlapping between `C-u C-c C-x C-l' and `C-c
C-x C-l'. For example :

  - C-c C-x C-l :: Toggle preview on the fragment at point, *raise an
    error outside a fragment*
  - C-u C-c C-x C-l :: Toggle preview for current section
  - C-u C-u C-c C-x C-l :: Toggle preview for the whole document

Or, if we consider that previewing the whole document is not very useful
and can be given a more cumbersome binding,

  - C-c C-x C-l :: Toggle preview on the fragment at point, raise an
    error outside a fragment
  - C-u C-c C-x C-l :: *Preview* for current section, incrementally
    (what you suggest)
  - C-u C-u C-c C-x C-l :: *Clear preview* from the whole section
  - C-u 0 C-u C-c C-x C-l :: *Preview* the whole document
  - C-u - C-c C-x C-l :: *Clear preview* for the whole document

Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]