1 ;;; org-track.el --- Track the most recent Org-mode version available.
3 ;; Copyright (C) 2009-2012
4 ;; Free Software Foundation, Inc.
6 ;; Author: Bastien Guerry <bzg at altern dot org>
7 ;; Eric S Fraga <e.fraga at ucl.ac dot uk>
8 ;; Sebastian Rose <sebastian_rose at gmx dot de>
9 ;; The Worg people http://orgmode.org/worg/
10 ;; Keywords: outlines, hypermedia, calendar, wp
11 ;; Homepage: http://orgmode.org
14 ;; Released under the GNU General Public License version 3
15 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
17 ;; This file is not part of GNU Emacs.
19 ;; GNU Emacs is free software: you can redistribute it and/or modify
20 ;; it under the terms of the GNU General Public License as published by
21 ;; the Free Software Foundation, either version 3 of the License, or
22 ;; (at your option) any later version.
24 ;; GNU Emacs is distributed in the hope that it will be useful,
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;; GNU General Public License for more details.
29 ;; You should have received a copy of the GNU General Public License
30 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35 ;; WARNING: This library is obsolete, you should use the make targets
36 ;; to keep track of Org latest developments.
38 ;; Download the latest development tarball, unpack and optionally compile it
42 ;; (require 'org-track)
44 ;; ;; ... somewhere in your setup (use customize):
46 ;; (setq org-track-directory "~/test/")
47 ;; (setq org-track-compile-sources nil)
48 ;; (setq org-track-remove-package t)
50 ;; M-x org-track-update RET
53 (require 'url-handlers
)
54 (autoload 'url-file-local-copy
"url-handlers")
55 (autoload 'url-generic-parse-url
"url-parse")
61 (defgroup org-track nil
62 "Track the most recent Org-mode version available.
64 To use org-track, adjust `org-track-directory'.
65 Org will download the archived latest git version for you,
66 unpack it into that directory (i.e. a subdirectory
67 `org-mode/' is added), create the autoloads file
68 `org-loaddefs.el' for you and, optionally, compile the
70 All you'll have to do is call `M-x org-track-update' from
75 (defcustom org-track-directory
"~/.emacs.d/org/lisp"
76 "Directory where your org-mode/ directory lives.
77 If that directory does not exist, it will be created."
80 (defcustom org-track-compile-sources t
81 "If `nil', never compile org-sources.
82 Org will only create the autoloads file `org-loaddefs.el' for
83 you then. If `t', compile the sources, too.
84 Note, that emacs preferes compiled elisp files over
88 (defcustom org-track-org-url
"http://orgmode.org/"
89 "The URL where the package to download can be found.
90 Please append a slash."
93 (defcustom org-track-org-package
"org-latest.tar.gz"
94 "The basename of the package you use.
95 Defaults to the development version of Org-mode.
96 This should be a *.tar.gz package, since emacs provides all
97 you need to unpack it."
100 (defcustom org-track-remove-package nil
101 "Remove org-latest.tar.gz after updates?"
108 (defun org-track-update ()
109 "Update to current Org-mode version.
110 Also, generate autoloads and evtl. compile the sources."
112 (let* ((base (file-truename org-track-directory
))
113 (org-exists (file-exists-p
115 (concat base
"/org-mode/lisp/org.el"))))
116 (nobase (not (file-directory-p
117 (file-truename org-track-directory
)))))
120 (format "Directory %s does not exist. Create it?" base
))
121 (make-directory base t
)
124 (message "Not creating %s - giving up." org-track-directory
)
127 (org-track-fetch-package)
128 (org-track-compile-org))
129 (error (message "%s" (error-message-string err
)))))))
133 ;;; tar related functions
135 ;; `url-retrieve-synchronously' fetches files synchronously. How can we ensure
136 ;; that? If the maintainers of that package decide, that an assynchronous
137 ;; download might be better??? (used by `url-file-local-copy')
140 (defun org-track-fetch-package (&optional directory
)
141 "Fetch Org package depending on `org-track-fetch-package-extension'.
142 If DIRECTORY is defined, unpack the package there, i.e. add the
143 subdirectory org-mode/ to DIRECTORY."
144 (interactive "Dorg-track directory: ")
146 (if (string-match "/$" org-track-org-url
)
148 (concat org-track-org-url
"/"))
149 org-track-org-package
))
151 (or directory org-track-directory
)))
152 (target (file-truename
153 (concat base
"/" org-track-org-package
)))
154 url download tarbuff
)
155 (message "Fetching to %s - this might take some time..." base
)
156 (setq url
(url-generic-parse-url pack
))
157 (setq download
(url-file-local-copy url
)) ;; errors if fail
158 (copy-file download target t
)
159 (delete-file download
)
160 ;; (tar-mode) leads to dubious errors. We use the auto-mode-alist to
161 ;; ensure tar-mode is used:
162 (add-to-list 'auto-mode-alist
'("org-latest\\.tar\\.gz\\'" . tar-mode
))
163 (setq tarbuff
(find-file target
))
164 (with-current-buffer tarbuff
;; with-temp-buffer does not work with tar-mode??
166 (kill-buffer tarbuff
)
167 (if org-track-remove-package
168 (delete-file target
))))
172 ;;; Compile Org-mode sources
176 (defun org-track-compile-org (&optional directory
)
177 "Compile all *.el files that come with org-mode.
178 Generate the autoloads file `org-loaddefs.el'.
180 DIRECTORY is where the directory org-mode/ lives (i.e. the
181 parent directory of your local repo."
183 ;; file-truename expands the filename and removes double slash, if exists:
184 (setq directory
(file-truename
187 (file-truename (concat org-track-directory
"/org-mode/lisp")))
189 (add-to-list 'load-path directory
)
190 (let ((list-of-org-files (file-expand-wildcards (concat directory
"*.el"))))
191 ;; create the org-loaddefs file
193 (setq esf
/org-install-file
(concat directory
"org-loaddefs.el"))
194 (find-file esf
/org-install-file
)
197 (generate-file-autoloads x
))
199 (insert "\n(provide (quote org-loaddefs))\n")
202 (byte-compile-file esf
/org-install-file t
)
205 (if (file-exists-p (concat f
"c"))
206 (delete-file (concat f
"c"))))
208 (if org-track-compile-sources
209 (mapc (lambda (f) (byte-compile-file f
)) list-of-org-files
))))
213 ;;; org-track.el ends here