org2blog/common/l2r-remote-url treats "file:///" prefix now
[org2blog.git] / dia-links.el
blob50737d91ea246f1e89f4bfe80fabad0a6a971cf7
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 and relocated to the
73 ;;respective image directory
74 (org2blog:convert-filename
75 path ".png" tehom-org-dia-image-path
76 tehom-org-dia-src-path)))
78 ;;Cause the image to be made if out of date.
79 (org2blog:make-target image-filename)
80 (org-html-make-link '()
81 "file" image-filename nil nil "" t))))
82 ;;;_ . Tests
84 ;;Can't automate testing this.
86 ;;;_. Footers
87 ;;;_ , Provides
89 (provide 'org2blog/dia-links)
91 ;;;_ * Local emacs vars.
92 ;;;_ + Local variables:
93 ;;;_ + mode: allout
94 ;;;_ + End:
96 ;;;_ , End
97 ;;; org2blog/dia-links.el ends here