From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou 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 Message-ID: <874l98vfxw.fsf@nicolasgoaziou.fr> References: <87bm3it0u9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:40380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtfsK-0004G4-BB for emacs-orgmode@gnu.org; Tue, 12 Feb 2019 16:45:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtfsJ-0002pb-Bf for emacs-orgmode@gnu.org; Tue, 12 Feb 2019 16:45:56 -0500 Received: from relay11.mail.gandi.net ([217.70.178.231]:55267) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtfsJ-0002im-4X for emacs-orgmode@gnu.org; Tue, 12 Feb 2019 16:45:55 -0500 In-Reply-To: (Carlos Pita's message of "Mon, 11 Feb 2019 20:15:36 -0300") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Carlos Pita Cc: emacs-orgmode@gnu.org Hello, Carlos Pita 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