1 ;;; org-track.el --- Track the most recent Org-mode version available.
3 ;; Copyright (C) 2009-2014
4 ;; Free Software Foundation, Inc.
6 ;; Author: Bastien Guerry <bzg@gnu.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 ;; This program 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 ;; This program 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
74 (defcustom org-track-directory
(concat user-emacs-directory
"org/lisp")
75 "Directory where your org-mode/ directory lives.
76 If that directory does not exist, it will be created."
79 (defcustom org-track-compile-sources t
80 "If `nil', never compile org-sources.
81 Org will only create the autoloads file `org-loaddefs.el' for
82 you then. If `t', compile the sources, too.
83 Note, that emacs preferes compiled elisp files over
87 (defcustom org-track-org-url
"http://orgmode.org/"
88 "The URL where the package to download can be found.
89 Please append a slash."
92 (defcustom org-track-org-package
"org-latest.tar.gz"
93 "The basename of the package you use.
94 Defaults to the development version of Org-mode.
95 This should be a *.tar.gz package, since emacs provides all
96 you need to unpack it."
99 (defcustom org-track-remove-package nil
100 "Remove org-latest.tar.gz after updates?"
107 (defun org-track-update ()
108 "Update to current Org-mode version.
109 Also, generate autoloads and evtl. compile the sources."
111 (let* ((base (file-truename org-track-directory
))
112 (org-exists (file-exists-p
114 (concat base
"/org-mode/lisp/org.el"))))
115 (nobase (not (file-directory-p
116 (file-truename org-track-directory
)))))
119 (format "Directory %s does not exist. Create it?" base
))
120 (make-directory base t
)
123 (message "Not creating %s - giving up." org-track-directory
)
126 (org-track-fetch-package)
127 (org-track-compile-org))
128 (error (message "%s" (error-message-string err
)))))))
132 ;;; tar related functions
134 ;; `url-retrieve-synchronously' fetches files synchronously. How can we ensure
135 ;; that? If the maintainers of that package decide, that an assynchronous
136 ;; download might be better??? (used by `url-file-local-copy')
139 (defun org-track-fetch-package (&optional directory
)
140 "Fetch Org package depending on `org-track-fetch-package-extension'.
141 If DIRECTORY is defined, unpack the package there, i.e. add the
142 subdirectory org-mode/ to DIRECTORY."
143 (interactive "Dorg-track directory: ")
145 (if (string-match "/$" org-track-org-url
)
147 (concat org-track-org-url
"/"))
148 org-track-org-package
))
150 (or directory org-track-directory
)))
151 (target (file-truename
152 (concat base
"/" org-track-org-package
)))
153 url download tarbuff
)
154 (message "Fetching to %s - this might take some time..." base
)
155 (setq url
(url-generic-parse-url pack
))
156 (setq download
(url-file-local-copy url
)) ;; errors if fail
157 (copy-file download target t
)
158 (delete-file download
)
159 ;; (tar-mode) leads to dubious errors. We use the auto-mode-alist to
160 ;; ensure tar-mode is used:
161 (add-to-list 'auto-mode-alist
'("org-latest\\.tar\\.gz\\'" . tar-mode
))
162 (setq tarbuff
(find-file target
))
163 (with-current-buffer tarbuff
;; with-temp-buffer does not work with tar-mode??
165 (kill-buffer tarbuff
)
166 (if org-track-remove-package
167 (delete-file target
))))
171 ;;; Compile Org-mode sources
175 (defun org-track-compile-org (&optional directory
)
176 "Compile all *.el files that come with org-mode.
177 Generate the autoloads file `org-loaddefs.el'.
179 DIRECTORY is where the directory org-mode/ lives (i.e. the
180 parent directory of your local repo."
182 ;; file-truename expands the filename and removes double slash, if exists:
183 (setq directory
(file-truename
186 (file-truename (concat org-track-directory
"/org-mode/lisp")))
188 (add-to-list 'load-path directory
)
189 (let ((list-of-org-files (file-expand-wildcards (concat directory
"*.el"))))
190 ;; create the org-loaddefs file
192 (setq esf
/org-install-file
(concat directory
"org-loaddefs.el"))
193 (find-file esf
/org-install-file
)
196 (generate-file-autoloads x
))
198 (insert "\n(provide (quote org-loaddefs))\n")
201 (byte-compile-file esf
/org-install-file t
)
204 (if (file-exists-p (concat f
"c"))
205 (delete-file (concat f
"c"))))
207 (if org-track-compile-sources
208 (mapc (lambda (f) (byte-compile-file f
)) list-of-org-files
))))
212 ;;; org-track.el ends here