1

I like to automatically publish my org files using a cron job once an hour. I therefore run a cron job that executes the following script:

;;; Load everything ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'org)
(org-babel-load-file
 (expand-file-name "emacs-init.org"
                   user-emacs-directory))

;;; Publish ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(org-publish-project "org-notes")

Please note that my org-notes project uses the org-html-publish-to-html publishing function.

However, if this job runs while I'm visiting an unsaved file in another Emacs instance the script hangs with a message like this:

...foo.org locked by tom@pam... (pid 12320): (s, q, p, ?)?

Based on the Emacs interlocking help page it looks like I should get an error like this is I try to edit a file that contains unsaved edits that were made by another Emacs instance. However, I don't see why org-publish-project would try to edit any org files. It was my impression that it just read the org files from the disk and then converted them into HTML.

Why would org-html-publish-to-html actually try to edit an org file?

1 Answer 1

0

I've done a bit of additional research on this and it looks like the org-html-publish-to-html function just doesn't work with files that are being edited. I found one workaround, but it requires that your files be checked into a git repo. This would ensure that none of your files are in the process of being edited when the publish function runs, but it's also not something that I'm interested in for this particular site.

I guess I'll just have to use org to remind me to periodically publish my site manually :-)

1
  • In batch mode, Emacs reads input from stdin for prompts in the minibuffer. Assuming that the only prompt Emacs is making is about the locks, then you might be able to get away with yes p | your-emacs-command. The p tells Emacs it can proceed. The problem is almost certainly that somewhere Emacs is doing a find-file and tripping over the lock; publishing won't actually change the file.
    – Win
    Nov 25, 2017 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.