.gitignore now ignores backups and .elc
[org2blog.git] / dia-links.el
blob1f8e5c0be28a5f5f17e968dd36d5b14451306fb8
1 ;;;_ org2blog/dia-links.el --- Dia links and general support, for org
3 ;;;_. Headers
4 ;;;_ , License
5 ;; Copyright (C) 2010 Tom Breton (Tehom)
7 ;; Author: Tom Breton (Tehom) <tehom@panix.com>
8 ;; Keywords: lisp, internal, outlines
10 ;; This file is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; This file is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;;_ , Commentary:
27 ;; $$MOVE ME to org-mode
30 ;;;_ , Requires
32 (require 'org2blog/for-org-html)
33 (require 'org2blog/make-target)
34 ;;;_. Body
36 ;;;_ , Dia links specifically
37 ;;;_ . Config
38 ;;In emacs 23, user may set these per directory using .dir-locals.
39 (defconst tehom-org-dia-src-path "diagrams/"
40 "Path to dia files" )
42 (defconst tehom-org-dia-image-path "images/"
43 "Path to dia images" )
45 ;;;_ . Set up dia links
47 (org-add-link-type "dia" 'tehom-org-dia-open 'tehom-org-dia-export)
49 ;;No store-link is possible because dia is outside emacs.
51 ;;;_ . tehom-org-dia-open
53 (defun tehom-org-dia-open (path)
54 "Open the diagram with dia"
56 (start-process-shell-command "dia" nil "dia"
57 (org2blog:convert-filename
58 path ".dia" tehom-org-dia-src-path)))
61 ;;;_ , Tests
63 ;;Can't automate testing this.
65 ;;;_ , tehom-org-dia-export
66 (defun tehom-org-dia-export (path desc format)
68 (when
69 (eq format 'html)
70 (let
71 ((image-filename
72 ;;Same base name, with "png" suffix
73 (org2blog:convert-filename
74 path ".png" tehom-org-dia-image-path)))
76 ;;Cause the image to be made if out of date.
77 (org2blog:make-target image-filename)
78 (org-html-make-link
79 "file" image-filename desc desc "" t))))
80 ;;;_ . Tests
82 ;;Can't automate testing this.
84 ;;;_. Footers
85 ;;;_ , Provides
87 (provide 'org2blog/dia-links)
89 ;;;_ * Local emacs vars.
90 ;;;_ + Local variables:
91 ;;;_ + mode: allout
92 ;;;_ + End:
94 ;;;_ , End
95 ;;; org2blog/dia-links.el ends here