Bugfix in org-publish.el.

Throw an error when `org-publish-current-file' is called on a file that
is not part of any project.  Publishing a single file that is not part
of a project is already done by simply exporting it, so the user should
be warned about this.
This commit is contained in:
Bastien Guerry 2008-03-10 11:39:01 +00:00
parent 06fb98f1e2
commit 9df93e8698
3 changed files with 23 additions and 11 deletions

View File

@ -1,5 +1,8 @@
2008-03-10 Bastien Guerry <bzg@altern.org>
* org-publish.el (org-publish-file): Send an error when file is
not part of any project.
* org.el (org-select-remember-template): Cleaned the code.
* org-publish.el (org-publish-before-export-hook)

View File

@ -66,21 +66,27 @@
*** New template option: pre-selection contexts
- Templates now allow six elements. The last element defines
the contexts in which the template should be offered. It
can be a list of major modes, a function, `t' or `nil'. If
it is a list of major-mode, the template will be available
only when `org-remember' is called from a buffer in one of
these modes. If it is a function, the template will be
offered only if the function returns `t' when called in the
current buffer. A value of `t' for this element means
select this template in any context. `nil' means use this
template by default, when other checks failed.
contexts in which the template should be offered.
A context is either a list of major modes or a function.
When calling `org-remember' from a buffer, if the buffer is
in one of the major modes listed in a template's context or
if a context-function returns `t' in the buffer, then the
template will be selected. Templates not associated with
any contexts will be *always* offered for selection. For
exemple:
(setq org-remember-templates
'(("Org" ?o "* %a\n\n%i%?" "~/org/bzg.org" "Org" my-defun)))
M-x org-remember RET will present this template only if
calling `my-defun' in the current buffer returns `nil'.
calling `my-defun' in the current buffer returns `t.
(setq org-remember-templates
'(("Org" ?o "* %a\n\n%i%?" "~/org/bzg.org" "Org" (org-mode))))
M-x org-remember RET will present this template only if
we are in an Org-mode buffer.
The (info "(org)Remember templates") for details.

View File

@ -516,7 +516,10 @@ FILENAME is the filename of the file to be published."
(defun org-publish-file (filename &optional project)
"Publish file FILENAME from PROJECT."
(when (org-publish-needed-p filename)
(let* ((project (or project (org-publish-get-project-from-filename filename)))
(let* ((project (or project
(or (org-publish-get-project-from-filename filename)
(error "File %s is not part of any known project"
filename))))
(project-plist (cdr project))
(publishing-function (or (plist-get project-plist :publishing-function)
'org-publish-org-to-html))