-
Notifications
You must be signed in to change notification settings - Fork 2
/
org-auto-export.el
82 lines (69 loc) · 2.6 KB
/
org-auto-export.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;;; org-auto-export.el --- automatically and asynchronously export org to pdf by ox-latex
;; Copyright (C) 2016 by Zhe Lei.
;;
;; Author: Zhe Lei
;; Version: 0.1
;; Package-Version: 20160129
;; Package-Requires: ((org "8.3.3") (emacs "24.3"))
;;
;; This file is not part of GNU emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'org)
(require 'ox-latex)
(defvar-local org-auto-export-interval 600)
(defvar-local org-auto-export-timer nil)
(defcustom org-async-init-file
"c:/Users/lzhes/GoogleDrive/Git/Configurations/Emacs/.emacs.d/lisp/org-async-file.el"
"file used to loaded by asynchronous process"
:type 'file)
(defun org-async-export ()
(require 'async)
(async-start
;; What to do in the child process
`(lambda ()
(let ((file ,(buffer-file-name)))
(require 'package)
(package-initialize)
(load-file "c:/Users/admin/GoogleDrive/Git/org-auto-export/org-auto-export.el")
(load-file org-async-init-file)
(find-file file)
(org-latex-export-to-pdf))
,(file-name-nondirectory (buffer-file-name)))
;; What to do when it finishes
(lambda (result)
(message "%s exported sucessfully" result))))
;;;###autoload
(define-minor-mode org-auto-export-mode
"Minor mode to export current org file automatically."
:init-value nil
:global t
:variable org-auto-export-mode
:lighter " AE"
:group 'org
(if (and (derived-mode-p 'org-mode) org-auto-export-mode)
(setq org-auto-export-timer
(run-at-time nil org-auto-export-interval
'org-async-export))
(when org-auto-export-timer
(cancel-timer org-auto-export-timer)
(setq org-auto-export-timer nil)
(user-error "Org auto export mode off!")))
(when (and (called-interactively-p 'interactive)
org-auto-export-mode)
(run-with-idle-timer 0 nil 'message
(format
"Org file exported every %s sec."
org-auto-export-interval))))
(provide 'org-auto-export)
;;; org-auto-export.el ends here