org-publish.el 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. ;;; org-publish.el --- publish related org-mode files as a website
  2. ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
  3. ;; Author: David O'Toole <dto@gnu.org>
  4. ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
  5. ;; Keywords: hypermedia, outlines, wp
  6. ;; Version: 1.81
  7. ;; This file is part of GNU Emacs.
  8. ;;
  9. ;; GNU Emacs is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 3, or (at your option)
  12. ;; any later version.
  13. ;; GNU Emacs is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  19. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. ;; Boston, MA 02110-1301, USA.
  21. ;;; Commentary:
  22. ;; Requires at least version 4.27 of org.el
  23. ;; This program allow configurable publishing of related sets of
  24. ;; Org-mode files as a complete website.
  25. ;;
  26. ;; org-publish.el can do the following:
  27. ;;
  28. ;; + Publish all one's org-files to HTML or LaTeX
  29. ;; + Upload HTML, images, attachments and other files to a web server
  30. ;; + Exclude selected private pages from publishing
  31. ;; + Publish a clickable index of pages
  32. ;; + Manage local timestamps for publishing only changed files
  33. ;; + Accept plugin functions to extend range of publishable content
  34. ;;
  35. ;; Special thanks to the org-mode maintainer Carsten Dominik for his
  36. ;; ideas, enthusiasm, and cooperation.
  37. ;;; Installation:
  38. ;; Put org-publish.el in your load path, byte-compile it, and then add
  39. ;; the following lines to your emacs initialization file:
  40. ;; (autoload 'org-publish "org-publish" nil t)
  41. ;; (autoload 'org-publish "org-publish-all" nil t)
  42. ;; (autoload 'org-publish "org-publish-current-file" nil t)
  43. ;; (autoload 'org-publish "org-publish-current-project" nil t)
  44. ;; NOTE: When org-publish.el is included with org.el, those forms are
  45. ;; already in the file org-install.el, and hence don't need to be put
  46. ;; in your emacs initialization file in this case.
  47. ;;; Usage:
  48. ;;
  49. ;; The program's main configuration variable is
  50. ;; `org-publish-project-alist'. See below for example configurations
  51. ;; with commentary.
  52. ;; The main interactive functions are:
  53. ;;
  54. ;; M-x org-publish
  55. ;; M-x org-publish-all
  56. ;; M-x org-publish-current-file
  57. ;; M-x org-publish-current-project
  58. ;;;; Simple example configuration:
  59. ;; (setq org-publish-project-alist
  60. ;; (list
  61. ;; '("org" . (:base-directory "~/org/"
  62. ;; :base-extension "org"
  63. ;; :publishing-directory "~/public_html"
  64. ;; :with-section-numbers nil
  65. ;; :table-of-contents nil
  66. ;; :recursive t
  67. ;; :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">")))
  68. ;;;; More complex example configuration:
  69. ;; Imagine your *.org files are kept in ~/org, your images in
  70. ;; ~/images, and stylesheets in ~/other. Now imagine you want to
  71. ;; publish the files through an ssh connection to a remote host, via
  72. ;; Tramp-mode. To maintain relative links from *.org files to /images
  73. ;; and /other, we should replicate the same directory structure in
  74. ;; your web server account's designated html root (in this case,
  75. ;; assumed to be ~/html)
  76. ;; Once you've done created the proper directories, you can adapt the
  77. ;; following example configuration to your specific paths, run M-x
  78. ;; org-publish-all, and it should publish the files to the correct
  79. ;; directories on the web server, transforming the *.org files into
  80. ;; HTML, and leaving other files alone.
  81. ;; (setq org-publish-project-alist
  82. ;; (list
  83. ;; '("orgfiles" :base-directory "~/org/"
  84. ;; :base-extension "org"
  85. ;; :publishing-directory "/ssh:user@host:~/html/notebook/"
  86. ;; :publishing-function org-publish-org-to-html
  87. ;; :exclude "PrivatePage.org" ;; regexp
  88. ;; :headline-levels 3
  89. ;; :with-section-numbers nil
  90. ;; :table-of-contents nil
  91. ;; :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">"
  92. ;; :auto-preamble t
  93. ;; :auto-postamble nil)
  94. ;; ("images" :base-directory "~/images/"
  95. ;; :base-extension "jpg\\|gif\\|png"
  96. ;; :publishing-directory "/ssh:user@host:~/html/images/"
  97. ;; :publishing-function org-publish-attachment)
  98. ;; ("other" :base-directory "~/other/"
  99. ;; :base-extension "css"
  100. ;; :publishing-directory "/ssh:user@host:~/html/other/"
  101. ;; :publishing-function org-publish-attachment)
  102. ;; ("website" :components ("orgfiles" "images" "other"))))
  103. ;; For more information, see the documentation for the variable
  104. ;; `org-publish-project-alist'.
  105. ;; Of course, you don't have to publish to remote directories from
  106. ;; within emacs. You can always just publish to local folders, and
  107. ;; then use the synchronization/upload tool of your choice.
  108. ;;; List of user-visible changes since version 1.27
  109. ;; 1.78: Allow list-valued :publishing-function
  110. ;; 1.77: Added :preparation-function, this allows you to use GNU Make etc.
  111. ;; 1.65: Remove old "composite projects". They're redundant.
  112. ;; 1.64: Allow meta-projects with :components
  113. ;; 1.57: Timestamps flag is now called "org-publish-use-timestamps-flag"
  114. ;; 1.52: Properly set default for :index-filename
  115. ;; 1.48: Composite projects allowed.
  116. ;; :include keyword allowed.
  117. ;; 1.43: Index no longer includes itself in the index.
  118. ;; 1.42: Fix "function definition is void" error
  119. ;; when :publishing-function not set in org-publish-current-file.
  120. ;; 1.41: Fixed bug where index isn't published on first try.
  121. ;; 1.37: Added interactive function "org-publish". Prompts for particular
  122. ;; project name to publish.
  123. ;; 1.34: Added force-publish option to all interactive functions.
  124. ;; 1.32: Fixed "index.org has changed on disk" error during index publishing.
  125. ;; 1.30: Fixed startup error caused by (require 'em-unix)
  126. ;;; Code:
  127. (eval-when-compile
  128. (require 'cl))
  129. (require 'dired-aux)
  130. (defgroup org-publish nil
  131. "Options for publishing a set of Org-mode and related files."
  132. :tag "Org Publishing"
  133. :group 'org)
  134. (defcustom org-publish-project-alist nil
  135. "Association list to control publishing behavior.
  136. Each element of the alist is a publishing 'project.' The CAR of
  137. each element is a string, uniquely identifying the project. The
  138. CDR of each element is in one of the following forms:
  139. (:property value :property value ... )
  140. OR,
  141. (:components (\"project-1\" \"project-2\" ...))
  142. When the CDR of an element of org-publish-project-alist is in
  143. this second form, the elements of the list after :components are
  144. taken to be components of the project, which group together files
  145. requiring different publishing options. When you publish such a
  146. project with M-x org-publish, the components all publish.
  147. When a property is given a value in org-publish-project-alist, its
  148. setting overrides the value of the corresponding user variable
  149. (if any) during publishing. However, options set within a file
  150. override everything.
  151. Most properties are optional, but some should always be set:
  152. :base-directory Directory containing publishing source files
  153. :base-extension Extension (without the dot!) of source files.
  154. This can be a regular expression.
  155. :publishing-directory Directory (possibly remote) where output
  156. files will be published
  157. The :exclude property may be used to prevent certain files from
  158. being published. Its value may be a string or regexp matching
  159. file names you don't want to be published.
  160. The :include property may be used to include extra files. Its
  161. value may be a list of filenames to include. The filenames are
  162. considered relative to the publishing directory.
  163. When both :include and :exclude properties are given values, the
  164. exclusion step happens first.
  165. One special property controls which back-end function to use for
  166. publishing files in the project. This can be used to extend the
  167. set of file types publishable by org-publish, as well as the set
  168. of output formats.
  169. :publishing-function Function to publish file. The default is
  170. org-publish-org-to-html, but other
  171. values are possible. May also be a
  172. list of functions, in which case
  173. each function in the list is invoked
  174. in turn.
  175. Another property allows you to insert code that prepares a
  176. project for publishing. For example, you could call GNU Make on a
  177. certain makefile, to ensure published files are built up to date.
  178. :preparation-function Function to be called before publishing
  179. this project.
  180. Some properties control details of the Org publishing process,
  181. and are equivalent to the corresponding user variables listed in
  182. the right column. See the documentation for those variables to
  183. learn more about their use and default values.
  184. :language org-export-default-language
  185. :headline-levels org-export-headline-levels
  186. :section-numbers org-export-with-section-numbers
  187. :table-of-contents org-export-with-toc
  188. :emphasize org-export-with-emphasize
  189. :sub-superscript org-export-with-sub-superscripts
  190. :TeX-macros org-export-with-TeX-macros
  191. :fixed-width org-export-with-fixed-width
  192. :tables org-export-with-tables
  193. :table-auto-headline org-export-highlight-first-table-line
  194. :style org-export-html-style
  195. :convert-org-links org-export-html-link-org-files-as-html
  196. :inline-images org-export-html-inline-images
  197. :expand-quoted-html org-export-html-expand
  198. :timestamp org-export-html-with-timestamp
  199. :publishing-directory org-export-publishing-directory
  200. :preamble org-export-html-preamble
  201. :postamble org-export-html-postamble
  202. :auto-preamble org-export-html-auto-preamble
  203. :auto-postamble org-export-html-auto-postamble
  204. :author user-full-name
  205. :email user-mail-address
  206. The following properties may be used to control publishing of an
  207. index of files or summary page for a given project.
  208. :auto-index Whether to publish an index during
  209. org-publish-current-project or org-publish-all.
  210. :index-filename Filename for output of index. Defaults
  211. to 'index.org' (which becomes 'index.html')
  212. :index-title Title of index page. Defaults to name of file.
  213. :index-function Plugin function to use for generation of index.
  214. Defaults to 'org-publish-org-index', which
  215. generates a plain list of links to all files
  216. in the project."
  217. :group 'org-publish
  218. :type 'alist)
  219. (defcustom org-publish-use-timestamps-flag t
  220. "When non-nil, use timestamp checking to publish only changed files.
  221. When nil, do no timestamp checking and always publish all
  222. files."
  223. :group 'org-publish
  224. :type 'boolean)
  225. (defcustom org-publish-timestamp-directory "~/.org-timestamps/"
  226. "Name of directory in which to store publishing timestamps."
  227. :group 'org-publish
  228. :type 'directory)
  229. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  230. ;;; Timestamp-related functions
  231. (defun org-publish-timestamp-filename (filename)
  232. "Return path to timestamp file for filename FILENAME."
  233. (while (string-match
  234. (if (eq system-type 'windows-nt) "~\\|/\\|:" "~\\|/") filename)
  235. (setq filename (replace-match "_" nil t filename)))
  236. (concat org-publish-timestamp-directory filename ".timestamp"))
  237. (defun org-publish-needed-p (filename)
  238. "Return `t' if FILENAME should be published."
  239. (if org-publish-use-timestamps-flag
  240. (if (file-exists-p org-publish-timestamp-directory)
  241. ;; first handle possible wrong timestamp directory
  242. (if (not (file-directory-p org-publish-timestamp-directory))
  243. (error "Org publish timestamp: %s is not a directory"
  244. org-publish-timestamp-directory)
  245. ;; there is a timestamp, check if FILENAME is newer
  246. (file-newer-than-file-p
  247. filename (org-publish-timestamp-filename filename))))
  248. ;; don't use timestamps, always return t
  249. t))
  250. (defun org-publish-update-timestamp (filename)
  251. "Update publishing timestamp for file FILENAME.
  252. If there is no timestamp, create one."
  253. (let ((timestamp-file (org-publish-timestamp-filename filename))
  254. newly-created-timestamp)
  255. (if (not (file-exists-p timestamp-file))
  256. ;; create timestamp file if needed
  257. (with-temp-buffer
  258. (make-directory (file-name-directory timestamp-file) t)
  259. (write-file timestamp-file)
  260. (setq newly-created-timestamp t)))
  261. ;; Emacs 21 doesn't have `set-file-times'
  262. (if (and (fboundp 'set-file-times)
  263. (not newly-created-timestamp))
  264. (set-file-times timestamp-file)
  265. (call-process "touch" nil 0 nil timestamp-file))))
  266. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  267. ;;; Mapping files to project names
  268. (defvar org-publish-files-alist nil
  269. "Alist of files and their parent project.
  270. Each element of this alist is of the form:
  271. (file-name . project-name)")
  272. (defun org-publish-initialize-files-alist (&optional refresh)
  273. "Set `org-publish-files-alist' if it is not set.
  274. Also set it if the optional argument REFRESH is non-nil."
  275. (when (or (not org-publish-files-alist) refresh)
  276. (setq org-publish-files-alist
  277. (org-publish-get-files org-publish-project-alist))))
  278. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  279. ;;; Getting project information out of org-publish-project-alist
  280. (defun org-publish-get-files (projects-alist &optional no-exclusion)
  281. "Return the list of all publishable files for PROJECTS-ALIST.
  282. If NO-EXCLUSION is non-nil, don't exclude files."
  283. (let (all-files)
  284. ;; add all projects
  285. (mapc
  286. (lambda(p)
  287. (let* ((exclude (plist-get p :exclude))
  288. (files (org-publish-get-base-files p exclude)))
  289. ;; add all files from this project
  290. (mapc (lambda(f)
  291. (add-to-list 'all-files
  292. (cons (file-truename f) (car p))))
  293. files)))
  294. (org-publish-expand-projects projects-alist))
  295. all-files))
  296. (defun org-publish-expand-projects (projects-alist)
  297. "Expand projects contained in PROJECTS-ALIST."
  298. (let (without-component with-component)
  299. (mapc (lambda(p)
  300. (add-to-list
  301. (if (plist-get (cdr p) :components)
  302. 'with-component 'without-component) p))
  303. projects-alist)
  304. (delete-dups
  305. (append without-component
  306. (car (mapcar (lambda(p) (org-publish-expand-components p))
  307. with-component))))))
  308. (defun org-publish-expand-components (project)
  309. "Expand PROJECT into an alist of its components."
  310. (let* ((components (plist-get (cdr project) :components)))
  311. (delete-dups
  312. (mapcar (lambda(c) (assoc c org-publish-project-alist))
  313. components))))
  314. (defun org-publish-get-base-files (project &optional exclude-regexp)
  315. "Return a list of all files in PROJECT.
  316. If EXCLUDE-REGEXP is set, this will be used to filter out
  317. matching filenames."
  318. (let* ((project-plist (cdr project))
  319. (base-dir (file-name-as-directory
  320. (plist-get project-plist :base-directory)))
  321. (include-list (plist-get project-plist :include))
  322. (recursive-p (plist-get project-plist :recursive))
  323. (extension (or (plist-get project-plist :base-extension) "org"))
  324. (regexp (concat "^[^\\.].*\\.\\(" extension "\\)$"))
  325. alldirs allfiles files dir)
  326. ;; Get all files and directories in base-directory
  327. (setq files (dired-files-attributes base-dir))
  328. ;; Get all subdirectories if recursive-p
  329. (setq alldirs
  330. (if recursive-p
  331. (delq nil (mapcar (lambda(f) (if (caaddr f) (cadr f))) files))
  332. (list base-dir)))
  333. (while (setq dir (pop alldirs))
  334. (setq files (directory-files dir t regexp))
  335. ;; Exclude files
  336. (setq files
  337. (if (not exclude-regexp)
  338. files
  339. (delq nil
  340. (mapcar (lambda (x)
  341. (if (string-match exclude-regexp x) nil x))
  342. files))))
  343. ;; Include extra files
  344. (let (inc)
  345. (while (setq inc (pop include-list))
  346. (setq files (cons (expand-file-name inc dir) files))))
  347. (setq allfiles (append allfiles files)))
  348. allfiles))
  349. (defun org-publish-get-project-from-filename (filename)
  350. "Return the project FILENAME belongs."
  351. (let* ((project-name (cdr (assoc (file-truename filename)
  352. org-publish-files-alist))))
  353. (assoc project-name org-publish-project-alist)))
  354. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  355. ;;; Pluggable publishing back-end functions
  356. (defun org-publish-org-to (format plist filename pub-dir)
  357. "Publish an org file to FORMAT.
  358. PLIST is the property list for the given project.
  359. FILENAME is the filename of the org file to be published.
  360. PUB-DIR is the publishing directory."
  361. (require 'org)
  362. (unless (file-exists-p pub-dir)
  363. (make-directory pub-dir t))
  364. (find-file filename)
  365. (funcall (intern (concat "org-export-as-" format))
  366. (plist-get plist :headline-levels)
  367. nil plist nil nil pub-dir)
  368. (kill-buffer (current-buffer)))
  369. (defun org-publish-org-to-latex (plist filename pub-dir)
  370. "Publish an org file to LaTeX.
  371. See `org-publish-org-to' to the list of arguments."
  372. (org-publish-org-to "latex" plist filename pub-dir))
  373. (defun org-publish-org-to-html (plist filename pub-dir)
  374. "Publish an org file to HTML.
  375. See `org-publish-org-to' to the list of arguments."
  376. (org-publish-org-to "html" plist filename pub-dir))
  377. (defun org-publish-attachment (plist filename)
  378. "Publish a file with no transformation of any kind.
  379. PLIST is the property list for the given project.
  380. FILENAME is the filename of the file to be published."
  381. ;; make sure eshell/cp code is loaded
  382. (eval-and-compile
  383. (require 'eshell)
  384. (require 'esh-maint)
  385. (require 'em-unix))
  386. (let ((destination (file-name-as-directory
  387. (plist-get plist :publishing-directory))))
  388. (eshell/cp filename destination)))
  389. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  390. ;;; Publishing files, sets of files, and indices
  391. (defun org-publish-file (filename &optional project)
  392. "Publish file FILENAME from PROJECT."
  393. (when (org-publish-needed-p filename)
  394. (let* ((project (or project (org-publish-get-project-from-filename filename)))
  395. (project-plist (cdr project))
  396. (publishing-function (or (plist-get project-plist :publishing-function)
  397. 'org-publish-org-to-html))
  398. (base-dir (file-truename (plist-get project-plist :base-directory)))
  399. (pub-dir (file-truename (plist-get project-plist :publishing-directory)))
  400. tmp-pub-dir)
  401. (if (not project) (error "File %s is not part of any known project" filename))
  402. (setq tmp-pub-dir
  403. (file-name-directory
  404. (concat pub-dir
  405. (and (string-match (regexp-quote base-dir) filename)
  406. (substring filename (match-end 0))))))
  407. (if (listp publishing-function)
  408. ;; allow chain of publishing functions
  409. (mapc (lambda (f)
  410. (funcall f project-plist filename tmp-pub-dir))
  411. publishing-function)
  412. (funcall publishing-function project-plist filename tmp-pub-dir))
  413. (org-publish-update-timestamp filename))))
  414. (defun org-publish-projects (projects)
  415. "Publish all files belonging to the PROJECTS alist.
  416. If :auto-index is set, publish the index too."
  417. (mapc
  418. (lambda (project)
  419. (let* ((project-plist (cdr project))
  420. (exclude-regexp (plist-get project-plist :exclude))
  421. (index-p (plist-get project-plist :auto-index))
  422. (index-filename (or (plist-get project-plist :index-filename)
  423. "index.org"))
  424. (index-function (or (plist-get project-plist :index-function)
  425. 'org-publish-org-index))
  426. (preparation-function (plist-get project-plist :preparation-function))
  427. (files (org-publish-get-base-files project exclude-regexp)) file)
  428. (when preparation-function (funcall preparation-function))
  429. (if index-p (funcall index-function project index-filename))
  430. (while (setq file (pop files))
  431. (org-publish-file file project))))
  432. (org-publish-expand-projects projects)))
  433. (defun org-publish-org-index (project &optional index-filename)
  434. "Create an index of pages in set defined by PROJECT.
  435. Optionally set the filename of the index with INDEX-FILENAME.
  436. Default for INDEX-FILENAME is 'index.org'."
  437. (let* ((project-plist (cdr project))
  438. (dir (file-name-as-directory
  439. (plist-get project-plist :base-directory)))
  440. (exclude-regexp (plist-get project-plist :exclude))
  441. (files (org-publish-get-base-files project exclude-regexp))
  442. (index-filename (concat dir (or index-filename "index.org")))
  443. (index-buffer (find-buffer-visiting index-filename))
  444. (ifn (file-name-nondirectory index-filename))
  445. file)
  446. ;; if buffer is already open, kill it to prevent error message
  447. (if index-buffer
  448. (kill-buffer index-buffer))
  449. (with-temp-buffer
  450. (while (setq file (pop files))
  451. (let ((fn (file-name-nondirectory file)))
  452. (unless (string= fn ifn) ;; index shouldn't index itself
  453. (insert (concat " + [[file:" fn "]["
  454. (file-name-sans-extension fn)
  455. "]]\n")))))
  456. (write-file index-filename)
  457. (kill-buffer (current-buffer)))))
  458. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  459. ;;; Interactive publishing functions
  460. ;;;###autoload
  461. (defun org-publish (project-name &optional force)
  462. "Publish the project named PROJECT-NAME."
  463. (interactive
  464. (list (progn (completing-read
  465. "Project name: " org-publish-project-alist nil t))
  466. current-prefix-arg))
  467. (save-window-excursion
  468. (let ((org-publish-use-timestamps-flag
  469. (if force nil org-publish-use-timestamps-flag)))
  470. (org-publish-projects
  471. (list (assoc project-name org-publish-project-alist))))))
  472. ;;;###autoload
  473. (defun org-publish-all (&optional force)
  474. "Publish all projects.
  475. With prefix argument, force publish all files."
  476. (interactive "P")
  477. (org-publish-initialize-files-alist)
  478. (save-window-excursion
  479. (let ((org-publish-use-timestamps-flag
  480. (if force nil org-publish-use-timestamps-flag)))
  481. (org-publish-projects org-publish-project-alist))))
  482. ;;;###autoload
  483. (defun org-publish-current-file (&optional force)
  484. "Publish the current file.
  485. With prefix argument, force publish the file."
  486. (interactive "P")
  487. (org-publish-initialize-files-alist)
  488. (save-window-excursion
  489. (let ((org-publish-use-timestamps-flag
  490. (if force nil org-publish-use-timestamps-flag)))
  491. (org-publish-file (buffer-file-name)))))
  492. ;;;###autoload
  493. (defun org-publish-current-project (&optional force)
  494. "Publish the project associated with the current file.
  495. With a prefix argument, force publishing of all files in
  496. the project."
  497. (interactive "P")
  498. (org-publish-initialize-files-alist)
  499. (save-window-excursion
  500. (let ((project (org-publish-get-project-from-filename (buffer-file-name)))
  501. (org-publish-use-timestamps-flag
  502. (if force nil org-publish-use-timestamps-flag)))
  503. (if (not project)
  504. (error "File %s is not part of any known project" (buffer-file-name)))
  505. (org-publish project))))
  506. (provide 'org-publish)
  507. ;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
  508. ;;; org-publish.el ends here