emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Hook request and patch
@ 2008-12-30  4:22 Tom Breton (Tehom)
  2008-12-31  8:45 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Breton (Tehom) @ 2008-12-30  4:22 UTC (permalink / raw)
  To: emacs-orgmode

Motivating incident: I was exporting some files and I wanted to
process a file after I included it.  Using "#+INCLUDE" I could include
it and I could tell it to use "BEGIN_XXX" "END_XXX" so my code could
find it.

But I couldn't process it, because org-export-preprocess-string calls
`org-export-preprocess-hook' before it handles "#+INCLUDE".

I didn't want to move org-export-preprocess-hook because for all I
know there's a good reason it comes first.  Similarly for the timing
of "#+INCLUDE".

So I ask for a hook that is called after includes are handled.  Diffs
appended.

Another advantage: `org-update-all-dblocks' didn't seem to work in
org-export-preprocess-hook because the working buffer isn't yet in
org-mode when it's called, but works in the new hook.

Tom Breton (Tehom)

*** old-org-exp.el	2008-12-18 18:26:05.000000000 -0500
--- org-exp.el	2008-12-29 23:10:46.000000000 -0500
***************
*** 297,302 ****
--- 297,305 ----
  (defvar org-export-preprocess-hook nil
    "Hook for preprocessing an export buffer.
  Pretty much the first thing when exporting is running this hook.")
+ (defvar org-export-midprocess-hook nil
+   "Hook for processing an export buffer after file inclusions.
+ Run after file inclusions and tree exclusions.")

  (defgroup org-export-translation nil
    "Options for translating special ascii sequences for the export
backends."
***************
*** 1522,1527 ****
--- 1525,1532 ----
        ;; Find matches for radio targets and turn them into internal links
        (org-export-mark-radio-links)

+       (run-hooks 'org-export-midprocess-hook)
+
        ;; Find all links that contain a newline and put them into a
single line
        (org-export-concatenate-multiline-links)

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

* Re: Hook request and patch
  2008-12-30  4:22 Hook request and patch Tom Breton (Tehom)
@ 2008-12-31  8:45 ` Carsten Dominik
  2008-12-31 18:54   ` Tom Breton (Tehom)
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2008-12-31  8:45 UTC (permalink / raw)
  To: Tom Breton (Tehom); +Cc: emacs-orgmode

Hi Tom,

is there a reason why you did not put the hook right after
the include file moment?

- Carsten

On Dec 30, 2008, at 5:22 AM, Tom Breton (Tehom) wrote:

> Motivating incident: I was exporting some files and I wanted to
> process a file after I included it.  Using "#+INCLUDE" I could include
> it and I could tell it to use "BEGIN_XXX" "END_XXX" so my code could
> find it.
>
> But I couldn't process it, because org-export-preprocess-string calls
> `org-export-preprocess-hook' before it handles "#+INCLUDE".
>
> I didn't want to move org-export-preprocess-hook because for all I
> know there's a good reason it comes first.  Similarly for the timing
> of "#+INCLUDE".
>
> So I ask for a hook that is called after includes are handled.  Diffs
> appended.
>
> Another advantage: `org-update-all-dblocks' didn't seem to work in
> org-export-preprocess-hook because the working buffer isn't yet in
> org-mode when it's called, but works in the new hook.
>
> Tom Breton (Tehom)
>
> *** old-org-exp.el	2008-12-18 18:26:05.000000000 -0500
> --- org-exp.el	2008-12-29 23:10:46.000000000 -0500
> ***************
> *** 297,302 ****
> --- 297,305 ----
>  (defvar org-export-preprocess-hook nil
>    "Hook for preprocessing an export buffer.
>  Pretty much the first thing when exporting is running this hook.")
> + (defvar org-export-midprocess-hook nil
> +   "Hook for processing an export buffer after file inclusions.
> + Run after file inclusions and tree exclusions.")
>
>  (defgroup org-export-translation nil
>    "Options for translating special ascii sequences for the export
> backends."
> ***************
> *** 1522,1527 ****
> --- 1525,1532 ----
>        ;; Find matches for radio targets and turn them into internal  
> links
>        (org-export-mark-radio-links)
>
> +       (run-hooks 'org-export-midprocess-hook)
> +
>        ;; Find all links that contain a newline and put them into a
> single line
>        (org-export-concatenate-multiline-links)
>
>
>
>
>
>
>
> _______________________________________________
> 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] 4+ messages in thread

* Re: Hook request and patch
  2008-12-31  8:45 ` Carsten Dominik
@ 2008-12-31 18:54   ` Tom Breton (Tehom)
  2009-01-01  9:04     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Breton (Tehom) @ 2008-12-31 18:54 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

> Hi Tom,
>
> is there a reason why you did not put the hook right after
> the include file moment?
>
> - Carsten

Yes, two.  But of course your judgement should take precedence.

In order to make my change slightly less severe, I put it just before
operations of a similar nature, and it seemed to me that the various "find
links" operations were most like it - but perhaps that reflects on the
particular purpose I was using it for.

And it seemed to me that putting it after the various "protect" operations
was better than putting it before them.

Tom

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

* Re: Hook request and patch
  2008-12-31 18:54   ` Tom Breton (Tehom)
@ 2009-01-01  9:04     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2009-01-01  9:04 UTC (permalink / raw)
  To: Tom Breton (Tehom); +Cc: emacs-orgmode


On Dec 31, 2008, at 7:54 PM, Tom Breton (Tehom) wrote:

>> Hi Tom,
>>
>> is there a reason why you did not put the hook right after
>> the include file moment?
>>
>> - Carsten
>
> Yes, two.  But of course your judgement should take precedence.
>
> In order to make my change slightly less severe, I put it just before
> operations of a similar nature, and it seemed to me that the various  
> "find
> links" operations were most like it - but perhaps that reflects on the
> particular purpose I was using it for.
>
> And it seemed to me that putting it after the various "protect"  
> operations
> was better than putting it before them.


Hi Tom,

I had to change the name of the hook, "midprocess" does not do
it justice.  I'm not sure if you really want to do this after the
protection stuff, because it will limit the processing of your
include files.

I have now added a few more hooks at strategic locations in the
preprocessing code, please take your pick from the hooks I am listing
below.  If you do need the hook in the position where you put it,
let me know and I will add another one.

(defvar org-export-preprocess-hook nil
   "Hook for preprocessing an export buffer.
Pretty much the first thing when exporting is running this hook.")

(defvar org-export-preprocess-after-include-files-hook nil
   "Hook for preprocessing an export buffer.
This is run after the contents of included files have been inserted.")

(defvar org-export-preprocess-after-tree-selection-hook nil
   "Hook for preprocessing an export buffer.
This is run after selection of trees to be exported has happened.
This selection includes tags-based selection, as well as removal
of commented and archived trees.")

(defvar org-export-preprocess-before-backend-specifics-hook nil
   "Hook run before backend-specific functions are called during  
preprocessing.")

(defvar org-export-preprocess-final-hook nil
   "Hook for preprocessing an export buffer.
This is run as the last thing in the preprocessing buffer, just before
returning the buffer string to the backend.")


- Carsten

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

end of thread, other threads:[~2009-01-01  9:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-30  4:22 Hook request and patch Tom Breton (Tehom)
2008-12-31  8:45 ` Carsten Dominik
2008-12-31 18:54   ` Tom Breton (Tehom)
2009-01-01  9:04     ` 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).