emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Carlos Pita <carlosjosepita@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: 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	[thread overview]
Message-ID: <874l98vfxw.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAELgYhfzeXubb-1r-5Oi8Qh4++t20D65_rrkCj4f8GYt-0+0aA@mail.gmail.com> (Carlos Pita's message of "Mon, 11 Feb 2019 20:15:36 -0300")

Hello,

Carlos Pita <carlosjosepita@gmail.com> 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	other threads:[~2019-02-12 21:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11 22:30 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/)] Carlos Pita
2019-02-11 22:33 ` Carlos Pita
2019-02-11 22:51 ` Carlos Pita
2019-02-11 23:15   ` Carlos Pita
2019-02-12 21:45     ` Nicolas Goaziou [this message]
2019-02-12 22:00       ` Carlos Pita
2019-02-12 22:43         ` Nicolas Goaziou
2019-02-12 23:23           ` Carlos Pita
2019-02-13 14:25             ` Nicolas Goaziou
2019-02-13 14:53               ` Carlos Pita
2019-02-13 15:10                 ` Carlos Pita
2019-02-13 16:24                   ` Nicolas Goaziou
2019-02-13 16:43                     ` Carlos Pita
2019-02-13 19:38                       ` Carlos Pita
2019-02-14  0:23                         ` Nicolas Goaziou
2019-02-14  1:31                           ` Carlos Pita
2019-02-14 14:52                             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874l98vfxw.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=carlosjosepita@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).