* Ignored in-buffer settings and after-export hook
@ 2013-08-25 12:10 Daniel Gerber
2013-08-26 11:45 ` Nicolas Goaziou
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Gerber @ 2013-08-25 12:10 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1598 bytes --]
Hi,
Two difficulties in exporting to html5:
1. With the current master branch, some in-buffer settings are ignored:
#+TITLE: Trying to export to html5
#+DESCRIPTION: this won't appear in the exported document...
#+KEYWORDS: html5 exporter meta
#+HTML_DOCTYPE: html5
#+AUTHOR: me
is exported to
<!DOCTYPE html>
<html>
<head>
<title>Trying to export to html5</title>
<meta charset="utf-8">
<meta name="generator" content="Org-mode">
<style type="text/css">
This problem is not present in maint (8.0.7) (but neither is the html5
doctype):
<?xml version="1.0" encoding="utf-8"?>
html5
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Trying to export to html5</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="generator" content="Org-mode"/>
<meta name="author" content="me"/>
<meta name="description" content="this won't appear in the exported
document..."/>
<meta name="keywords" content="html5 exporter meta"/>
<style type="text/css">
2. Is the after-export hook gone with the new exporter framework? I used
this to get the list of a project's exported files:
(setq html-files-list ()
org-publish-after-export-hook
(lambda () (add-to-list 'html-files-list
(buffer-file-name
(current-buffer)))))
(org-publish the-org-project t)
(print html-files-list)
but in 8.0.7 maint the hook is ignored altogether.
Best regards,
Daniel
[-- Attachment #2: Type: text/html, Size: 2689 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-08-25 12:10 Ignored in-buffer settings and after-export hook Daniel Gerber
@ 2013-08-26 11:45 ` Nicolas Goaziou
2013-08-26 13:48 ` Daniel Gerber
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2013-08-26 11:45 UTC (permalink / raw)
To: Daniel Gerber; +Cc: emacs-orgmode
Hello,
Daniel Gerber <daniel.g.gerber@gmail.com> writes:
> 2. Is the after-export hook gone with the new exporter framework? I used
> this to get the list of a project's exported files:
>
> (setq html-files-list ()
> org-publish-after-export-hook
> (lambda () (add-to-list 'html-files-list
> (buffer-file-name
> (current-buffer)))))
> (org-publish the-org-project t)
> (print html-files-list)
>
> but in 8.0.7 maint the hook is ignored altogether.
`org-publish-before-export-hook' and `org-publish-after-export-hook' are
not present in Org 8+, indeed. Can't you simply use
`org-export-before-parsing-hook' instead?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-08-26 11:45 ` Nicolas Goaziou
@ 2013-08-26 13:48 ` Daniel Gerber
2013-08-28 19:42 ` Nicolas Goaziou
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Gerber @ 2013-08-26 13:48 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hi,
On 26/08/2013 13:45, Nicolas Goaziou wrote:
> Hello,
>
> Daniel Gerber <daniel.g.gerber@gmail.com> writes:
>
>> 2. Is the after-export hook gone with the new exporter framework? I used
>> this to get the list of a project's exported files:
>>
>> (setq html-files-list ()
>> org-publish-after-export-hook
>> (lambda () (add-to-list 'html-files-list
>> (buffer-file-name
>> (current-buffer)))))
>> (org-publish the-org-project t)
>> (print html-files-list)
>>
>> but in 8.0.7 maint the hook is ignored altogether.
> `org-publish-before-export-hook' and `org-publish-after-export-hook' are
> not present in Org 8+, indeed. Can't you simply use
> `org-export-before-parsing-hook' instead?
I guess I can, but it means re-doing the mapping sources to exported
file names.
By the way, the manual points to
http://orgmode.org/worg/org-configs/org-hooks.html which still lists the
older hooks.
Thanks for your answer!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-08-26 13:48 ` Daniel Gerber
@ 2013-08-28 19:42 ` Nicolas Goaziou
2013-08-29 10:01 ` Daniel Gerber
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2013-08-28 19:42 UTC (permalink / raw)
To: Daniel Gerber; +Cc: emacs-orgmode
Hello,
Daniel Gerber <daniel.g.gerber@gmail.com> writes:
> I guess I can, but it means re-doing the mapping sources to exported
> file names.
AFAICT, there is only one place where both the source and the output
name are known: in `org-publish-file', right after a file has been
published.
We may add a hook there. Since, at that time, the current buffer can be
anything, both file names need to be passed as arguments to the hook.
Also, files skipped during the publishing process won't trigger it.
What do you think?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-08-28 19:42 ` Nicolas Goaziou
@ 2013-08-29 10:01 ` Daniel Gerber
2013-10-24 18:05 ` Nicolas Goaziou
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Gerber @ 2013-08-29 10:01 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hello,
>> I guess I can, but it means re-doing the mapping sources to exported
>> file names.
> AFAICT, there is only one place where both the source and the output
> name are known: in `org-publish-file', right after a file has been
> published.
>
> We may add a hook there. Since, at that time, the current buffer can be
> anything, both file names need to be passed as arguments to the hook.
> Also, files skipped during the publishing process won't trigger it.
>
> What do you think?
It would be fine!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-08-29 10:01 ` Daniel Gerber
@ 2013-10-24 18:05 ` Nicolas Goaziou
2013-12-03 8:52 ` Daniel Gerber
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2013-10-24 18:05 UTC (permalink / raw)
To: Daniel Gerber; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 686 bytes --]
Hello,
Daniel Gerber <daniel.g.gerber@gmail.com> writes:
> Hello,
>>> I guess I can, but it means re-doing the mapping sources to exported
>>> file names.
>> AFAICT, there is only one place where both the source and the output
>> name are known: in `org-publish-file', right after a file has been
>> published.
>>
>> We may add a hook there. Since, at that time, the current buffer can be
>> anything, both file names need to be passed as arguments to the hook.
>> Also, files skipped during the publishing process won't trigger it.
>>
>> What do you think?
> It would be fine!
It has been a long time, but would you mind testing the following patch?
Regards,
--
Nicolas Goaziou
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-publish-Introduce-org-publish-after-publishing-ho.patch --]
[-- Type: text/x-diff, Size: 3576 bytes --]
From 5b54cd3f1cef9ca4385da5d6e1d9b9d076847d3e Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Tue, 27 Aug 2013 10:12:41 +0200
Subject: [PATCH] ox-publish: Introduce `org-publish-after-publishing-hook'
* lisp/ox-publish.el (org-publish-after-publishing-hook): New variable.
(org-publish-file): Call hook with file name and output file name as
arguments. Small refactoring.
(org-publish-attachment): Return output file.
---
lisp/ox-publish.el | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index cfa7967..36cc790 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -54,6 +54,12 @@
"This will cache timestamps and titles for files in publishing projects.
Blocks could hash sha1 values here.")
+(defvar org-publish-after-publishing-hook nil
+ "Hook run each time a file is published.
+Every function in this hook will be called with two arguments:
+the name of the original file and the name of the file
+produced.")
+
(defgroup org-publish nil
"Options for publishing a set of Org-mode and related files."
:tag "Org Publishing"
@@ -600,11 +606,12 @@ publishing directory.
Return output file name."
(unless (file-directory-p pub-dir)
(make-directory pub-dir t))
- (or (equal (expand-file-name (file-name-directory filename))
- (file-name-as-directory (expand-file-name pub-dir)))
- (copy-file filename
- (expand-file-name (file-name-nondirectory filename) pub-dir)
- t)))
+ (let ((output (expand-file-name (file-name-nondirectory filename) pub-dir)))
+ (or (equal (expand-file-name (file-name-directory filename))
+ (file-name-as-directory (expand-file-name pub-dir)))
+ (copy-file filename output t))
+ ;; Return file name.
+ output))
\f
@@ -625,8 +632,10 @@ See `org-publish-projects'."
(project-plist (cdr project))
(ftname (expand-file-name filename))
(publishing-function
- (or (plist-get project-plist :publishing-function)
- (error "No publishing function chosen")))
+ (let ((fun (plist-get project-plist :publishing-function)))
+ (cond ((null fun) (error "No publishing function chosen"))
+ ((listp fun) fun)
+ (t (list fun)))))
(base-dir
(file-name-as-directory
(expand-file-name
@@ -648,19 +657,14 @@ See `org-publish-projects'."
(concat pub-dir
(and (string-match (regexp-quote base-dir) ftname)
(substring ftname (match-end 0))))))
- (if (listp publishing-function)
- ;; allow chain of publishing functions
- (mapc (lambda (f)
- (when (org-publish-needed-p
- filename pub-dir f tmp-pub-dir base-dir)
- (funcall f project-plist filename tmp-pub-dir)
- (org-publish-update-timestamp filename pub-dir f base-dir)))
- publishing-function)
- (when (org-publish-needed-p
- filename pub-dir publishing-function tmp-pub-dir base-dir)
- (funcall publishing-function project-plist filename tmp-pub-dir)
- (org-publish-update-timestamp
- filename pub-dir publishing-function base-dir)))
+ ;; Allow chain of publishing functions.
+ (dolist (f publishing-function)
+ (when (org-publish-needed-p filename pub-dir f tmp-pub-dir base-dir)
+ (let ((output (funcall f project-plist filename tmp-pub-dir)))
+ (org-publish-update-timestamp filename pub-dir f base-dir)
+ (run-hook-with-args 'org-publish-after-publishing-hook
+ filename
+ output))))
(unless no-cache (org-publish-write-cache-file))))
(defun org-publish-projects (projects)
--
1.8.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-10-24 18:05 ` Nicolas Goaziou
@ 2013-12-03 8:52 ` Daniel Gerber
2013-12-03 20:12 ` Nicolas Goaziou
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Gerber @ 2013-12-03 8:52 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hello,
On 24/10/2013 20:05, Nicolas Goaziou wrote:
>>>> I guess I can, but it means re-doing the mapping sources to exported
>>>> file names.
>>> AFAICT, there is only one place where both the source and the output
>>> name are known: in `org-publish-file', right after a file has been
>>> published.
>>>
>>> We may add a hook there. Since, at that time, the current buffer can be
>>> anything, both file names need to be passed as arguments to the hook.
>>> Also, files skipped during the publishing process won't trigger it.
>>>
>>> What do you think?
>> It would be fine!
> It has been a long time, but would you mind testing the following patch?
Yes it works for me.
Thanks!
Daniel Gerber
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Ignored in-buffer settings and after-export hook
2013-12-03 8:52 ` Daniel Gerber
@ 2013-12-03 20:12 ` Nicolas Goaziou
0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2013-12-03 20:12 UTC (permalink / raw)
To: Daniel Gerber; +Cc: emacs-orgmode
Hello,
Daniel Gerber <daniel.g.gerber@gmail.com> writes:
> On 24/10/2013 20:05, Nicolas Goaziou wrote:
>>>>> I guess I can, but it means re-doing the mapping sources to exported
>>>>> file names.
>>>> AFAICT, there is only one place where both the source and the output
>>>> name are known: in `org-publish-file', right after a file has been
>>>> published.
>>>>
>>>> We may add a hook there. Since, at that time, the current buffer can be
>>>> anything, both file names need to be passed as arguments to the hook.
>>>> Also, files skipped during the publishing process won't trigger it.
>>>>
>>>> What do you think?
>>> It would be fine!
>> It has been a long time, but would you mind testing the following patch?
> Yes it works for me.
Applied then. Thank you for reporting back.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-12-03 20:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-25 12:10 Ignored in-buffer settings and after-export hook Daniel Gerber
2013-08-26 11:45 ` Nicolas Goaziou
2013-08-26 13:48 ` Daniel Gerber
2013-08-28 19:42 ` Nicolas Goaziou
2013-08-29 10:01 ` Daniel Gerber
2013-10-24 18:05 ` Nicolas Goaziou
2013-12-03 8:52 ` Daniel Gerber
2013-12-03 20:12 ` Nicolas Goaziou
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).