Browse Source

Publishing: Fix bug with finding project for a file.

Ian Barton writes:

>
> This has been happening for a while. I suspect it's something in my
> settings, but I can't work out what. When I publish a single file, I
> get the following error:
>
> Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
>  file-truename(nil)
> org-publish-file("/home/ian/nfs/firewall/Documents/org/holiday/holiday.org")
>  org-publish-current-file(nil)
>  call-interactively(org-publish-current-file)
>  org-export(nil)
>  call-interactively(org-export)
>
> Publishing a whole project works fine.

This was caused by an attempt of the publishing code to always find
the top enclosing project.  While this makes sense when publishing a
project, for a single file we want just the smallest enclosing
project.  This commit makes sure that this difference is treated
correctly.
Carsten Dominik 16 years ago
parent
commit
b4455950e3
2 changed files with 10 additions and 5 deletions
  1. 4 0
      lisp/ChangeLog
  2. 6 5
      lisp/org-publish.el

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2009-02-26  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-publish.el (org-publish-get-project-from-filename): New
+	optional argument UP.  Only find the top project if UP is set.
+	(org-publish-current-project): Find the top encloding project.
+
 	* org-agenda.el (org-agenda-before-write-hook)
 	(org-agenda-add-entry-text-maxlines): New options.
 	(org-write-agenda): Run the new hook in the temporary buffer.

+ 6 - 5
lisp/org-publish.el

@@ -469,13 +469,14 @@ matching filenames."
 	  include-list)
     org-publish-temp-files))
 
-(defun org-publish-get-project-from-filename (filename)
+(defun org-publish-get-project-from-filename (filename &optional up)
   "Return the project FILENAME belongs."
   (let* ((project-name (cdr (assoc (expand-file-name filename)
 				   org-publish-files-alist))))
-    (dolist (prj org-publish-project-alist)
-      (if (member project-name (plist-get (cdr prj) :components))
-	  (setq project-name (car prj))))
+    (when up
+      (dolist (prj org-publish-project-alist)
+	(if (member project-name (plist-get (cdr prj) :components))
+	    (setq project-name (car prj)))))
     (assoc project-name org-publish-project-alist)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -742,7 +743,7 @@ the project."
   (interactive "P")
   (org-publish-initialize-files-alist)
   (save-window-excursion
-    (let ((project (org-publish-get-project-from-filename (buffer-file-name)))
+    (let ((project (org-publish-get-project-from-filename (buffer-file-name) 'up))
 	  (org-publish-use-timestamps-flag
 	   (if force nil org-publish-use-timestamps-flag)))
       (if (not project)