emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@gnu.org>
To: nicholas.dokos@hp.com
Cc: Achim Gratz <Stromeko@nexgo.de>, emacs-orgmode@gnu.org
Subject: Re: possible org bug
Date: Fri, 10 Aug 2012 13:06:13 +0200	[thread overview]
Message-ID: <87pq6z80re.fsf@gnu.org> (raw)
In-Reply-To: <3374.1343242848@alphaville> (Nick Dokos's message of "Wed, 25 Jul 2012 15:00:48 -0400")

[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]

Hi Nick,

Nick Dokos <nicholas.dokos@hp.com> writes:

> Re: the relative vs. absolute pathnames - David Maus had fixed a problem
> with symlinks but was trying to avoid carrying the default directory
> context. See this thread:
>
>     http://thread.gmane.org/gmane.emacs.orgmode/40645
>
> I just wanted to make sure that anybody who takes a look at this, keeps
> in mind the symlink case(s) as well.
>
> But I also wanted to add a plug for the exemplary bug report that the OP
> put together: if all bug reports were as complete as this one, life
> would be much easier. I usually complain about bad bug reports, so this
> was my chance to praise a good one: thanks!
>
> Nick
>
> PS. I had got to the cache problem (but not as far as the font-lock
> problem that Achim traced it to), ran out of time, wanted to get back to
> it but never got the chance. I might be able to take another look at it
> this weekend, but if anybody beats me to it, I will *not* complain...

Here is another chance.  :)

Please test the attached patch and see if this fixes the issue.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-publish.el-Fix-problem-with-org-publish-cache-ct.patch --]
[-- Type: text/x-patch, Size: 5184 bytes --]

From 55f1cf816d65b1c98044ae82a42da84b5613c5bd Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Fri, 10 Aug 2012 13:04:55 +0200
Subject: [PATCH] org-publish.el: Fix problem with
 `org-publish-cache-ctime-of-src' not expanding from the
 correct directory

* org-publish.el (org-publish-needed-p)
(org-publish-update-timestamp, org-publish-file)
(org-publish-cache-file-needs-publishing): New argument
`base-dir'.
(org-publish-cache-ctime-of-src): Use the new argument to make
sure we find the file according to :base-directory.
---
 lisp/org-publish.el |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index cb496ff..3225495 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -315,7 +315,7 @@ You could use brackets to delimit on what part the link will be.
 			 (format "%s" (or pub-func ""))))
   (concat "X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
 
-(defun org-publish-needed-p (filename &optional pub-dir pub-func true-pub-dir)
+(defun org-publish-needed-p (filename &optional pub-dir pub-func true-pub-dir base-dir)
   "Return t if FILENAME should be published in PUB-DIR using PUB-FUNC.
 TRUE-PUB-DIR is where the file will truly end up.  Currently we are not using
 this - maybe it can eventually be used to check if the file is present at
@@ -325,7 +325,7 @@ function can still decide about that independently."
   (let ((rtn
 	 (if org-publish-use-timestamps-flag
 	     (org-publish-cache-file-needs-publishing
-	      filename pub-dir pub-func)
+	      filename pub-dir pub-func base-dir)
 	   ;; don't use timestamps, always return t
 	   t)))
     (if rtn
@@ -334,11 +334,11 @@ function can still decide about that independently."
 	(message   "Skipping unmodified file %s" filename)))
     rtn))
 
-(defun org-publish-update-timestamp (filename &optional pub-dir pub-func)
+(defun org-publish-update-timestamp (filename &optional pub-dir pub-func base-dir)
   "Update publishing timestamp for file FILENAME.
 If there is no timestamp, create one."
   (let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
-	(stamp (org-publish-cache-ctime-of-src filename)))
+	(stamp (org-publish-cache-ctime-of-src filename base-dir)))
     (org-publish-cache-set key stamp)))
 
 (defun org-publish-remove-all-timestamps ()
@@ -705,15 +705,14 @@ See `org-publish-projects'."
     (if (listp publishing-function)
 	;; allow chain of publishing functions
 	(mapc (lambda (f)
-		(when (org-publish-needed-p filename pub-dir f tmp-pub-dir)
+		(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)))
+		  (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)
+      (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)))
+	 filename pub-dir publishing-function base-dir)))
     (unless no-cache (org-publish-write-cache-file))))
 
 (defun org-publish-projects (projects)
@@ -1103,7 +1102,7 @@ If FREE-CACHE, empty the cache."
       (clrhash org-publish-cache))
   (setq org-publish-cache nil))
 
-(defun org-publish-cache-file-needs-publishing (filename &optional pub-dir pub-func)
+(defun org-publish-cache-file-needs-publishing (filename &optional pub-dir pub-func base-dir)
   "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,
@@ -1123,12 +1122,12 @@ so that the file including them will be republished as well."
 	(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))))
+			 (org-publish-cache-ctime-of-src included-file base-dir) 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)))
+      (let ((ctime (org-publish-cache-ctime-of-src filename base-dir)))
 	(or (< pstamp ctime)
 	    (when included-files-ctime
 	      (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
@@ -1183,9 +1182,10 @@ Returns value on success, else nil."
       (error "`org-publish-cache-set' called, but no cache present"))
   (puthash key value org-publish-cache))
 
-(defun org-publish-cache-ctime-of-src (f)
+(defun org-publish-cache-ctime-of-src (f base-dir)
   "Get the FILENAME ctime as an integer."
-  (let ((attr (file-attributes (expand-file-name (or (file-symlink-p f) f)))))
+  (let ((attr (file-attributes
+	       (expand-file-name (or (file-symlink-p f) f) base-dir))))
     (+ (lsh (car (nth 5 attr)) 16)
        (cadr (nth 5 attr)))))
 
-- 
1.7.10.2


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

  reply	other threads:[~2012-08-10 11:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 20:27 possible org bug Robert Louis McIntyre
2012-07-25 18:17 ` Achim Gratz
2012-07-25 18:32   ` Achim Gratz
2012-07-25 19:00   ` Nick Dokos
2012-08-10 11:06     ` Bastien [this message]
2012-08-11 16:58       ` 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.orgmode.org/

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

  git send-email \
    --in-reply-to=87pq6z80re.fsf@gnu.org \
    --to=bzg@gnu.org \
    --cc=Stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=nicholas.dokos@hp.com \
    /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/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).