unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Albert <ab.for.lists@gmail.com>
To: 11491@debbugs.gnu.org
Subject: bug#11491: 23.0.96; org-mode: in org-publish.el: #+INCLUDE: cannot deal with spaces in a filename, like this "file name.org"
Date: Wed, 16 May 2012 21:49:34 +0200	[thread overview]
Message-ID: <CAJs9Ju-4EfaDwq2wYjTKtGzmqKys1jdBjFVdZ-9ChQgoKNM6NQ@mail.gmail.com> (raw)

It showed up in a quite difficult set-up, but looking at the regexp
used it seems obvious
the code has problems with this:

in the function org-publish-cache-file-needs-publishing there is the
line (the only line in
org-publish containing the string "INCLUDE")

	(while (re-search-forward "^#\\+INCLUDE:[ \t]+\"?\\([^
\t\n\r\"]*\\)\"?[ \t]*.*$" nil t)

this tries to catch a filename, see #+INCLUDE in the org manual, if I
see it correctly
(and I have seen the result confirming this) the parentheses catch
everything from after
the first ", if there is one, up till the first space, tab, newline,
carriage return or second ".
Up till the first space is a problem.

If needed I can try to provide a simple recipe to reproduce my
problem, but I think the problem
is obvious.

I myself removed the ? 's after the " 's to make the " around the
filename mandatory and then
also removed the space after the ^, as in

	(while (re-search-forward "^#\\+INCLUDE:[ \t]+\"\\([^\t\n\r\"]*\\)\"[
\t]*.*$" nil t)

This solves my problem.

For easy reference I have included here the whole defun:

(defun org-publish-cache-file-needs-publishing (filename &optional
pub-dir pub-func)
  "Check the timestamp of the last publishing of FILENAME.
Return `t', if the file needs publishing.  The function also
checks if any included files have been more recently published,
so that the file including them will be republished as well."
  (unless org-publish-cache
    (error "%s" "`org-publish-cache-file-needs-publishing' called, but
no cache present"))
  (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
	 (pstamp (org-publish-cache-get key))
	 (visiting (find-buffer-visiting filename))
	 included-files-ctime buf)

    (when (equal (file-name-extension filename) "org")
      (setq buf (find-file (expand-file-name filename)))
      (with-current-buffer buf
	(goto-char (point-min))
	(while (re-search-forward "^#\\+INCLUDE:[ \t]+\"?\\([^
\t\n\r\"]*\\)\"?[ \t]*.*$" nil t)
	  (let* ((included-file (expand-file-name (match-string 1))))
	    (add-to-list 'included-files-ctime
			 (org-publish-cache-ctime-of-src included-file) t))))
      ;; FIXME don't kill current buffer
      (unless visiting (kill-buffer buf)))
    (if (null pstamp)
	t
      (let ((ctime (org-publish-cache-ctime-of-src filename)))
	(or (< pstamp ctime)
	    (when included-files-ctime
	      (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
					   included-files-ctime))))))))))

Best regards,
Albert.





             reply	other threads:[~2012-05-16 19:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 19:49 Albert [this message]
2012-05-18  2:27 ` bug#11491: 24.0.96 instead of 23.0.96 Albert
2012-05-18  2:33   ` Glenn Morris
     [not found]   ` <bclikqjk04.fsf@fencepost.gnu.org>
2012-05-18  7:20     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJs9Ju-4EfaDwq2wYjTKtGzmqKys1jdBjFVdZ-9ChQgoKNM6NQ@mail.gmail.com \
    --to=ab.for.lists@gmail.com \
    --cc=11491@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).