mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-25 20:15:22 +00:00
Fix a giant, horrible bug in org-publish.
When publishing, org was more or less trying to export random files.
This commit is contained in:
parent
b4f50fc988
commit
337d2f2762
@ -1054,7 +1054,9 @@ value of `org-export-run-in-background'."
|
||||
(setq r2 (if (< r1 27) (+ r1 96) r1))
|
||||
(unless (setq ass (assq r2 cmds))
|
||||
(error "No command associated with key %c" r1))
|
||||
(if (and bg (nth 2 ass))
|
||||
(if (and bg (nth 2 ass)
|
||||
(not (buffer-base-buffer))
|
||||
(not (org-region-active-p)))
|
||||
;; execute in background
|
||||
(let ((p (start-process
|
||||
(concat "Exporting " (file-name-nondirectory (buffer-file-name)))
|
||||
|
@ -479,31 +479,35 @@ PUB-DIR is the publishing directory."
|
||||
(require 'org)
|
||||
(unless (file-exists-p pub-dir)
|
||||
(make-directory pub-dir t))
|
||||
(let* ((visiting (find-buffer-visiting filename))
|
||||
(plist (cons :buffer-will-be-killed (cons t plist)))
|
||||
(init-buf (or visiting (find-file filename)))
|
||||
(init-point (point))
|
||||
(init-buf-string (buffer-string)) export-buf-or-file)
|
||||
;; run hooks before exporting
|
||||
(run-hooks 'org-publish-before-export-hook)
|
||||
;; export the possibly modified buffer
|
||||
(setq export-buf-or-file
|
||||
(funcall (intern (concat "org-export-as-" format))
|
||||
(plist-get plist :headline-levels)
|
||||
nil plist nil nil pub-dir))
|
||||
(when (and (bufferp export-buf-or-file) (buffer-live-p export-buf-or-file))
|
||||
(set-buffer export-buf-or-file)
|
||||
;; run hooks after export and save export
|
||||
(and (run-hooks 'org-publish-after-export-hook)
|
||||
(if (buffer-modified-p) (save-buffer)))
|
||||
(kill-buffer export-buf-or-file))
|
||||
;; maybe restore buffer's content
|
||||
(set-buffer init-buf)
|
||||
(when (buffer-modified-p init-buf)
|
||||
(erase-buffer)
|
||||
(insert init-buf-string)
|
||||
(save-buffer)
|
||||
(goto-char init-point))
|
||||
(let ((visiting (find-buffer-visiting filename)))
|
||||
(save-excursion
|
||||
(switch-to-buffer (or visiting (find-file visiting)))
|
||||
(let* ((plist (cons :buffer-will-be-killed (cons t plist)))
|
||||
(init-buf (current-buffer))
|
||||
(init-point (point))
|
||||
(init-buf-string (buffer-string))
|
||||
export-buf-or-file)
|
||||
;; run hooks before exporting
|
||||
(run-hooks 'org-publish-before-export-hook)
|
||||
;; export the possibly modified buffer
|
||||
(setq export-buf-or-file
|
||||
(funcall (intern (concat "org-export-as-" format))
|
||||
(plist-get plist :headline-levels)
|
||||
nil plist nil nil pub-dir))
|
||||
(when (and (bufferp export-buf-or-file)
|
||||
(buffer-live-p export-buf-or-file))
|
||||
(set-buffer export-buf-or-file)
|
||||
;; run hooks after export and save export
|
||||
(and (run-hooks 'org-publish-after-export-hook)
|
||||
(if (buffer-modified-p) (save-buffer)))
|
||||
(kill-buffer export-buf-or-file))
|
||||
;; maybe restore buffer's content
|
||||
(set-buffer init-buf)
|
||||
(when (buffer-modified-p init-buf)
|
||||
(erase-buffer)
|
||||
(insert init-buf-string)
|
||||
(save-buffer)
|
||||
(goto-char init-point))))
|
||||
(unless visiting
|
||||
(kill-buffer init-buf))))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user