emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Lundin <mdl@imapmail.org>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Remove unecesssary invocations of org-mode in ox-publish
Date: Tue, 29 Jul 2014 00:10:52 -0500	[thread overview]
Message-ID: <87mwbsn40z.fsf@fastmail.fm> (raw)

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

This patch fixes a bug in which org-publish makes the following call...

(let ((org-inhibit-startup t) (org-mode)))

...in buffers that are already open. This often happens, for instance,
when publishing a sitemap. But there is no need to call org-mode again
in these open buffers. Moreover calling org-mode with
org-inhibit-startup set to t destroys crucial information in open
buffers, such as dir-locals variables. This can interfere rather
seriously with web publishing, causing website files I am editing to
lose the following crucial settings after I call org-publish:

((org-mode .
	   ((org-link-file-path-type . relative)
	    (org-display-custom-times . t))))

Thanks,
Matt


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Remove-unnecessary-invocations-of-org-mode.patch --]
[-- Type: text/x-diff, Size: 2030 bytes --]

From 05410ec611fdf8483053e2905df9a52ea9c53551 Mon Sep 17 00:00:00 2001
From: Matt Lundin <mdl@imapmail.org>
Date: Mon, 28 Jul 2014 23:56:42 -0500
Subject: [PATCH] Remove unnecessary invocations of org-mode

* lisp/ox-publish.el: (org-publish-find-title) (org-publish-find-date)
  Fix unnecessary invocations of org-mode with
  org-inhibit-startup.

The functions above call org-mode with org-inhibit-startup in org
buffers that are already open. The result is that these open buffers
lose some crucial local variables during publishing. For instance,
an open buffer will lose its dir-local-variables-alist setting
during publishing. There is no need to call org-mode here, because
org-mode is a) either already initialized in the buffer or b)
initialized via earlier call to find-file-no-select.

This looks to me like a relic of some past time when these functions were
called in temporary buffers that contained copies of the file's contents.
---
 lisp/ox-publish.el | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index be208df..94f12e9 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -806,11 +806,9 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
   "Find the title of FILE in project."
   (or
    (and (not reset) (org-publish-cache-get-file-property file :title nil t))
-   (let* ((org-inhibit-startup t)
-	  (visiting (find-buffer-visiting file))
+   (let* ((visiting (find-buffer-visiting file))
 	  (buffer (or visiting (find-file-noselect file))))
      (with-current-buffer buffer
-       (org-mode)
        (let ((title
 	      (let ((property (plist-get (org-export-get-environment) :title)))
 		(if property
@@ -831,7 +829,6 @@ time in `current-time' format."
 	   (file-buf (or visiting (find-file-noselect file nil)))
 	   (date (plist-get
 		  (with-current-buffer file-buf
-		    (let ((org-inhibit-startup t)) (org-mode))
 		    (org-export-get-environment))
 		  :date)))
       (unless visiting (kill-buffer file-buf))
-- 
2.0.2


             reply	other threads:[~2014-07-29  5:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-29  5:10 Matt Lundin [this message]
2014-07-29 13:21 ` [PATCH] Remove unecesssary invocations of org-mode in ox-publish Bastien
2014-07-29 15:03   ` Matt Lundin
2014-07-29 15:10     ` Matt Lundin
2014-07-29 15:13       ` Bastien
2014-07-29 16:04         ` Matt Lundin
2014-07-29 21:33           ` Bastien
2014-07-29 15:12     ` Matt Lundin
2014-07-29 15:13     ` Bastien
2014-07-29 15:45       ` Matt Lundin
2014-07-29 18:55         ` Matt Lundin
2014-07-29 21:33           ` Bastien
2014-07-30 16:55           ` Nicolas Goaziou
2014-07-30 19:33             ` Matt Lundin
2014-07-30 20:59               ` Nicolas Goaziou

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=87mwbsn40z.fsf@fastmail.fm \
    --to=mdl@imapmail.org \
    --cc=emacs-orgmode@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/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).