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: Wed, 13 Feb 2019 17:24:12 +0100 Message-ID: <87r2cbsllf.fsf@nicolasgoaziou.fr> References: <87bm3it0u9.fsf@gmail.com> <874l98vfxw.fsf@nicolasgoaziou.fr> <87va1otypx.fsf@nicolasgoaziou.fr> <87a7izu5n4.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:41076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtxLl-0000mM-L9 for emacs-orgmode@gnu.org; Wed, 13 Feb 2019 11:25:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtxLb-0002f6-Dk for emacs-orgmode@gnu.org; Wed, 13 Feb 2019 11:25:24 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:52727) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtxLV-0001qd-FU for emacs-orgmode@gnu.org; Wed, 13 Feb 2019 11:25:13 -0500 In-Reply-To: (Carlos Pita's message of "Wed, 13 Feb 2019 12:10:20 -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 Carlos Pita writes: >> C-c C-x C-l: as you defined it >> C-u C-c C-x C-l: preview document scope. >> C-- (or C-0) C-c C-x C-l: as you defined C-u C-c C-x C-l. >> C-- (or C-0) C-u C-c C-x C-l: unpreview document scope. > > Btw, I don't think that "preview the entire document" is such a rare > use case. Consider that you've taken some quick notes using embedded > latex (I need to do that often because my notes are almost exclusively > about mathematical stuff and unicode is far from enough). Now you open > the notes and you can i. export to pdf and preview using > docview/pdf-tools/external pdf reader or, alternatively, ii. preview > all fragments. I agree it's more usual to go to some section of > interest and then preview it, but nevertheless full preview has its > place. I don't want to remove the possibility to preview a full document. However, I prefer not binding it instead of binding it to an awfully long key sequence. For example, if the function responsible for previewing the full document is called `org-latex-preview-all', I'm sure I can fire `M-x org-latex-preview-all RET' at least as fast as `C-0 C-u C-c C-x C-l'. And if I need it often enough, I could bind it to, e.g., `C-c v' and be done with it. > This proposal makes more cumbersome to unpreview the entire document, > which I do think is barely necessary. But the other use cases are just > one modifier away from the base use case (toggle fragment). The > downside is that C-0 is assigned to an arguably less frequent use case > than C-u, because of the mnemonic argument. As I said, I dislike > swapping them, but if you prefer it that way I'm fine with it; in that > case what will result is your proposal plus two C-0 or something > variations for full document. Even if C-0 or C-- are good mnemonics, C-u is, in addition to being easier to type, the universal argument. For any given binding `B', one can reasonably expect to find the most usual alternative action bound to `C-u B'. Here, clearing previewing is much more useful than previewing the whole document. As a user, I would rather expect it under `C-u C-c C-x C-l`. On the implementation side, all previewing functions are just a wrapper away from `org-format-latex'. For example: (defun org--latex-preview-region (beg end) "Preview LaTeX fragments between BEG and END." (let ((file (buffer-file-name (buffer-base-buffer)))) (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end ;; Emacs cannot overlay images from remote hosts. Create ;; it in `temporary-file-directory' instead. (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays nil 'forbuffer org-preview-latex-default-process))) (defun org-latex-preview-all (&optional arg) "Preview all LaTeX fragments throughout the document. When optional argument ARG is non-nil, remove previews instead." (if arg (org-remove-latex-fragment-image-overlays) (org--latex-preview-region (point-min) (point-max)))) We can then re-use `org--latex-preview-region' for previewing a section, or only the LaTeX fragment at point.