emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Name of file being exported
@ 2009-04-13 21:33 Noufal Ibrahim
  0 siblings, 0 replies; 8+ messages in thread
From: Noufal Ibrahim @ 2009-04-13 21:33 UTC (permalink / raw)
  To: emacs-orgmode

Hello everyone,
    I'm a recent org-mode convert (after hearing the talk) and without 
question, it's one of the best things I've ever used. Thank you for 
making such a wonderful program.

    However, org-mode and emacs being what they are, I'm tempted to try 
and customise it to do more. :)

    I'm trying a simple trick to insert the version control history of 
my current file formatted as a table when I export the org file into 
HTML or ascii. I need this to track changes to design documents etc.

    I'm using dynamic blocks to do this and have a function defined to 
insert the output of

git log --pretty='format:|%ad|%s|' (buffer-file-name)

into the block.

    This works fine if I run org-update-all-dblocks from the org buffer 
itself manually. If I export it however, (buffer-file-name) returns a 
null string so I get the entire log of my repository which is not what I 
want.

    Is there a way to get the buffer/file which is being exported so 
that I can use that in the command rather than buffer-file-name?

    Thanks in advance and for such an awesome mode.


-- 
~noufal
http://nibrahim.net.in/

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

* Name of file being exported.
@ 2009-04-14  2:22 Noufal Ibrahim
  2009-04-14 10:32 ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Noufal Ibrahim @ 2009-04-14  2:22 UTC (permalink / raw)
  To: emacs-orgmode

[apologies if this is a repost. I was not on the list]

Hello everyone,
    I'm a recent org-mode convert (after hearing the talk) and without 
question, it's one of the best things I've ever used. Thank you for 
making such a wonderful program.

    However, org-mode and emacs being what they are, I'm tempted to try 
and customise it to do more. :)

    I'm trying a simple trick to insert the version control history of 
my current file formatted as a table when I export the org file into 
HTML or ascii. I need this to track changes to design documents etc.

    I'm using dynamic blocks to do this and have a function defined to 
insert the output of

git log --pretty='format:|%ad|%s|' (buffer-file-name)

into the block.

    This works fine if I run org-update-all-dblocks from the org buffer 
itself manually. If I export it however, (buffer-file-name) returns a 
null string so I get the entire log of my repository which is not what I 
want.

    Is there a way to get the buffer/file which is being exported so 
that I can use that in the command rather than buffer-file-name?

    Thanks in advance and for such an awesome mode.

-- 
~noufal
http://nibrahim.net.in/

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

* Re: Name of file being exported.
  2009-04-14  2:22 Name of file being exported Noufal Ibrahim
@ 2009-04-14 10:32 ` Carsten Dominik
  2009-04-14 14:58   ` Noufal Ibrahim
  0 siblings, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2009-04-14 10:32 UTC (permalink / raw)
  To: Noufal Ibrahim; +Cc: emacs-orgmode

Hi,

On Apr 14, 2009, at 4:22 AM, Noufal Ibrahim wrote:

> [apologies if this is a repost. I was not on the list]
>
> Hello everyone,
>   I'm a recent org-mode convert (after hearing the talk) and without  
> question, it's one of the best things I've ever used. Thank you for  
> making such a wonderful program.
>
>   However, org-mode and emacs being what they are, I'm tempted to  
> try and customise it to do more. :)
>
>   I'm trying a simple trick to insert the version control history of  
> my current file formatted as a table when I export the org file into  
> HTML or ascii. I need this to track changes to design documents etc.
>
>   I'm using dynamic blocks to do this and have a function defined to  
> insert the output of
>
> git log --pretty='format:|%ad|%s|' (buffer-file-name)
>
> into the block.
>
>   This works fine if I run org-update-all-dblocks from the org  
> buffer itself manually. If I export it however, (buffer-file-name)  
> returns a null string so I get the entire log of my repository which  
> is not what I want.

In what way are you calling the update of dblocks during export?  Have  
you added a function to this effect to a hook?  Which function?  To  
which hook?

- Carsten


>
>   Is there a way to get the buffer/file which is being exported so  
> that I can use that in the command rather than buffer-file-name?
>
>   Thanks in advance and for such an awesome mode.
>
> -- 
> ~noufal
> http://nibrahim.net.in/
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Name of file being exported.
  2009-04-14 10:32 ` Carsten Dominik
@ 2009-04-14 14:58   ` Noufal Ibrahim
  2009-04-14 16:20     ` Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: Noufal Ibrahim @ 2009-04-14 14:58 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik wrote:
[..]
> In what way are you calling the update of dblocks during export?  Have 
> you added a function to this effect to a hook?  Which function?  To 
> which hook?
[..]

Hello Carsten,
   I have done this
(add-hook 'org-export-preprocess-hook 'org-update-all-dblocks)

   Is this not the right hook to add the function to?

Thanks
-- 
~noufal
http://nibrahim.net.in/

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

* Re: Name of file being exported.
  2009-04-14 14:58   ` Noufal Ibrahim
@ 2009-04-14 16:20     ` Nick Dokos
  2009-04-14 16:39       ` Noufal Ibrahim
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2009-04-14 16:20 UTC (permalink / raw)
  To: Noufal Ibrahim; +Cc: emacs-orgmode

Noufal Ibrahim <noufal@nibrahim.net.in> wrote:

> Carsten Dominik wrote:
> [..]
> > In what way are you calling the update of dblocks during export?
> > Have you added a function to this effect to a hook?  Which function?
> > To which hook?
> [..]
> 
> Hello Carsten,
>   I have done this
> (add-hook 'org-export-preprocess-hook 'org-update-all-dblocks)
> 
>   Is this not the right hook to add the function to?
> 

I don't know how Carsten will address this, but it seems that the running
of the org-export-preprocess-hook is done too late for your purposes (from
inside org-export-preprocess-string and inside a

       (with-current-buffer (get-buffer-create " org-mode-tmp")
          ...

construct, where there is no buffer file name).

Can you run org-update-all-dblocks by hand before doing the export?  That should
update the org file and the export should then have all the right
information, no? If so, you can even automate the process by advising
org-export, so that org-update-all-dblocks is run before org-export
proper is called. [1]

HTH,
Nick


[1] Disclaimer: I have not tried it, so no warranty...

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

* Re: Name of file being exported.
  2009-04-14 16:20     ` Nick Dokos
@ 2009-04-14 16:39       ` Noufal Ibrahim
  2009-04-14 18:26         ` Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: Noufal Ibrahim @ 2009-04-14 16:39 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

Hi Nick,

Nick Dokos wrote:
[..]
> 
> Can you run org-update-all-dblocks by hand before doing the export?  

That's possible. What I do now is to to add the org-update-all-dbblocks 
to write-file-hooks as suggested by the info pages.

This works for me but there are times when I export directly without 
saving and I'd like the block to get updated then too.

> If so, you can even automate the process by advising
> org-export, so that org-update-all-dblocks is run before org-export
> proper is called. [1]

This sounds better. I shall try this. Although I'm wondering if there 
isn't a hook that I can add a function to manage what I want.

-- 
~noufal
http://nibrahim.net.in/

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

* Re: Name of file being exported.
  2009-04-14 16:39       ` Noufal Ibrahim
@ 2009-04-14 18:26         ` Nick Dokos
  2009-04-15  5:02           ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2009-04-14 18:26 UTC (permalink / raw)
  To: Noufal Ibrahim; +Cc: emacs-orgmode

Noufal Ibrahim <noufal@nibrahim.net.in> wrote:

> Hi Nick,
> 
> Nick Dokos wrote:
> [..]
> >
> > Can you run org-update-all-dblocks by hand before doing the export?  
> 
> That's possible. What I do now is to to add the
> org-update-all-dbblocks to write-file-hooks as suggested by the info
> pages.
> 
> This works for me but there are times when I export directly without
> saving and I'd like the block to get updated then too.
> 
> > If so, you can even automate the process by advising
> > org-export, so that org-update-all-dblocks is run before org-export
> > proper is called. [1]
> 
> This sounds better. I shall try this. Although I'm wondering if there
> isn't a hook that I can add a function to manage what I want.
> 

Maybe this will work: the current buffer-file-name is saved in
org-export-as-html (and I assume in the other export routines) in a
dynamically scoped variable called org-current-export-file. The value of
that variable should be available in the hook as well. So instead of
(buffer-file-name), you probably want to say

        (or (buffer-file-name) org-current-export-file)

That way, your updater can be called both from inside and outside
the export functions.

HTH,
Nick

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

* Re: Name of file being exported.
  2009-04-14 18:26         ` Nick Dokos
@ 2009-04-15  5:02           ` Carsten Dominik
  0 siblings, 0 replies; 8+ messages in thread
From: Carsten Dominik @ 2009-04-15  5:02 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode


On Apr 14, 2009, at 8:26 PM, Nick Dokos wrote:

> Noufal Ibrahim <noufal@nibrahim.net.in> wrote:
>
>> Hi Nick,
>>
>> Nick Dokos wrote:
>> [..]
>>>
>>> Can you run org-update-all-dblocks by hand before doing the export?
>>
>> That's possible. What I do now is to to add the
>> org-update-all-dbblocks to write-file-hooks as suggested by the info
>> pages.
>>
>> This works for me but there are times when I export directly without
>> saving and I'd like the block to get updated then too.
>>
>>> If so, you can even automate the process by advising
>>> org-export, so that org-update-all-dblocks is run before org-export
>>> proper is called. [1]
>>
>> This sounds better. I shall try this. Although I'm wondering if there
>> isn't a hook that I can add a function to manage what I want.
>>
>
> Maybe this will work: the current buffer-file-name is saved in
> org-export-as-html (and I assume in the other export routines) in a
> dynamically scoped variable called org-current-export-file. The  
> value of
> that variable should be available in the hook as well. So instead of
> (buffer-file-name), you probably want to say
>
>        (or (buffer-file-name) org-current-export-file)
>
> That way, your updater can be called both from inside and outside
> the export functions.


Great solution.

We could also introduce a new hook which is run before export.  However,
for the functionality discussed here, I think that before-save-hook  
would
be a very good place too.

- Carsten




>
> HTH,
> Nick
>

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

end of thread, other threads:[~2009-04-15  5:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14  2:22 Name of file being exported Noufal Ibrahim
2009-04-14 10:32 ` Carsten Dominik
2009-04-14 14:58   ` Noufal Ibrahim
2009-04-14 16:20     ` Nick Dokos
2009-04-14 16:39       ` Noufal Ibrahim
2009-04-14 18:26         ` Nick Dokos
2009-04-15  5:02           ` Carsten Dominik
  -- strict thread matches above, loose matches on Subject: below --
2009-04-13 21:33 Noufal Ibrahim

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