From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: [PATCH] Remove unecesssary invocations of org-mode in ox-publish Date: Tue, 29 Jul 2014 10:03:21 -0500 Message-ID: <87zjfsnsyf.fsf@fastmail.fm> References: <87mwbsn40z.fsf@fastmail.fm> <871tt4fggm.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC8w8-00014h-SM for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 11:03:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XC8vz-0007o9-9z for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 11:03:32 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:40679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC8vy-0007nt-SA for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 11:03:23 -0400 In-Reply-To: <871tt4fggm.fsf@bzg.ath.cx> (Bastien's message of "Tue, 29 Jul 2014 15:21:45 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: Org Mode Bastien writes: > Hi Matt, > > Matt Lundin writes: > >> This patch fixes a bug in which org-publish makes the following call... >> (let ((org-inhibit-startup t) (org-mode))) > > Applied, thanks! Oops... I see now that org-publish-find-date and org-publish-find-title call org-export-get-environment. This in turn relies on org-set-local to set #+BIND: variables, which requires the buffer to be writable. I have an org-mode-hook that sets some of my web publishing files read-only (so as to prevent accidental editing). Without org-inhibit-startup, these buffers remain read-only, causing the following error message: --8<---------------cut here---------------start------------->8--- org-export--get-global-options: Buffer is read-only: # --8<---------------cut here---------------end--------------->8--- This could be solved by wrapping org-export-get-environment withing those functions with (let ((buffer-read-only nil)) ...). However, I think the fundamental problem is that org-export-get-environment should be called on a copy of the buffer. That, at least, is how it is used in org-export-as (see lines 3084 - 3107 of ox.el). When org-publish-find-title and org-publish-call-date calls it in a buffer that is already open, it does so on the original copy of the buffer. This has the effect of setting the #+BIND variables within the live buffer, which could (theoretically) be dangerous, since, AFAICT, they should only be set in a temporary copy of the buffer. So to be safe, we could do the following in org-publish-find-date and org-publish-find-title... (org-export-with-buffer-copy (org-export-get-environment)) What do you think? Best, Matt