emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-preview-latex-fragment in indirect buffers
@ 2011-04-29  0:46 Darlan Cavalcante Moreira
  2011-05-10 21:19 ` Darlan Cavalcante Moreira
  0 siblings, 1 reply; 3+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-04-29  0:46 UTC (permalink / raw)
  To: Orgmode Mailing List


Hello,

I frequently use indirect buffers with org but org-preview-latex-fragment
does not work when in an indirect buffer. The reason is that
org-preview-latex-fragment uses "buffer-file-name" to get the name of the
file associated with the current buffer, but this is nil for indirect
buffers.

To solve this, all its necessary is to define the function below

--8<---------------cut here---------------start------------->8---
(defun org-buffer-file-name ()
  "Similar to buffer-file-name, but also work on indirect buffers."
  (buffer-file-name (buffer-base-buffer))
  )
--8<---------------cut here---------------end--------------->8---

and replace "buffer-file-name" in the org-preview-latex-fragment by
"(org-buffer-file-name)". This works in both: "normal" buffers and indirect
buffers.

--
Darlan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] org-preview-latex-fragment in indirect buffers
  2011-04-29  0:46 [PATCH] org-preview-latex-fragment in indirect buffers Darlan Cavalcante Moreira
@ 2011-05-10 21:19 ` Darlan Cavalcante Moreira
  2011-05-13 12:45   ` [Accepted] " Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-05-10 21:19 UTC (permalink / raw)
  To: Orgmode Mailing List, darcamo

[-- Attachment #1: Type: text/plain, Size: 228 bytes --]


This is a rather small change in org.el. Since I didn't get a response
(even rejected) I suspect this is because I didn't attached a proper patch
so that the patchwork server can get it.

The patch is attached now.

--
Darlan


[-- Attachment #2: org.el.diff --]
[-- Type: text/plain, Size: 1020 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index acbb261..eb95efa 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16151,6 +16151,11 @@ Revert to the normal definition outside of these fragments."
   (mapc 'delete-overlay org-latex-fragment-image-overlays)
   (setq org-latex-fragment-image-overlays nil))
 
+(defun org-buffer-file-name ()
+  "Similar to buffer-file-name, but also works on indirect buffers."
+  (buffer-file-name (buffer-base-buffer))
+  )
+
 (defun org-preview-latex-fragment (&optional subtree)
   "Preview the LaTeX fragment at point, or all locally or globally.
 If the cursor is in a LaTeX fragment, create the image and overlay
@@ -16189,7 +16194,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
 	(org-format-latex
 	 (concat "ltxpng/" (file-name-sans-extension
 			    (file-name-nondirectory
-			     buffer-file-name)))
+			     (org-buffer-file-name))))
 	 default-directory 'overlays msg at 'forbuffer 'dvipng)
       (message msg "done.  Use `C-c C-c' to remove images.")))))
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Accepted]  org-preview-latex-fragment in indirect buffers
  2011-05-10 21:19 ` Darlan Cavalcante Moreira
@ 2011-05-13 12:45   ` Carsten Dominik
  0 siblings, 0 replies; 3+ messages in thread
From: Carsten Dominik @ 2011-05-13 12:45 UTC (permalink / raw)
  To: emacs-orgmode

Patch 800 (http://patchwork.newartisans.com/patch/800/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C4dc9abe5.61adec0a.2a56.0767%40mx.google.com%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] org-preview-latex-fragment in indirect buffers
> Date: Wed, 11 May 2011 02:19:29 -0000
> From: Darlan Cavalcante Moreira <darcamo@gmail.com>
> X-Patchwork-Id: 800
> Message-Id: <4dc9abe5.61adec0a.2a56.0767@mx.google.com>
> To: Orgmode Mailing List <emacs-orgmode@gnu.org>, darcamo@gmail.com
> 
> This is a rather small change in org.el. Since I didn't get a response
> (even rejected) I suspect this is because I didn't attached a proper patch
> so that the patchwork server can get it.
> 
> The patch is attached now.
> 
> ---
> Darlan
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index acbb261..eb95efa 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -16151,6 +16151,11 @@ Revert to the normal definition outside of these fragments."
>    (mapc 'delete-overlay org-latex-fragment-image-overlays)
>    (setq org-latex-fragment-image-overlays nil))
>  
> +(defun org-buffer-file-name ()
> +  "Similar to buffer-file-name, but also works on indirect buffers."
> +  (buffer-file-name (buffer-base-buffer))
> +  )
> +
>  (defun org-preview-latex-fragment (&optional subtree)
>    "Preview the LaTeX fragment at point, or all locally or globally.
>  If the cursor is in a LaTeX fragment, create the image and overlay
> @@ -16189,7 +16194,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
>  	(org-format-latex
>  	 (concat "ltxpng/" (file-name-sans-extension
>  			    (file-name-nondirectory
> -			     buffer-file-name)))
> +			     (org-buffer-file-name))))
>  	 default-directory 'overlays msg at 'forbuffer 'dvipng)
>        (message msg "done.  Use `C-c C-c' to remove images.")))))
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-13 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29  0:46 [PATCH] org-preview-latex-fragment in indirect buffers Darlan Cavalcante Moreira
2011-05-10 21:19 ` Darlan Cavalcante Moreira
2011-05-13 12:45   ` [Accepted] " Carsten Dominik

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).