Implementation guessing for scripts with #! ... guile
[geiser.git] / elisp / geiser-reload.el
bloba5c012546fe7d1c8882142a0faa5ef4fddbc4585
1 ;; geiser-reload.el -- unload/load geiser packages
3 ;; Copyright (C) 2009, 2010 Jose Antonio Ortega Ruiz
5 ;; This program is free software; you can redistribute it and/or
6 ;; modify it under the terms of the Modified BSD License. You should
7 ;; have received a copy of the license along with this program. If
8 ;; not, see <http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5>.
10 ;; Start date: Sat Aug 22, 2009 23:04
14 (require 'geiser-repl)
15 (require 'geiser-mode)
16 (require 'geiser-custom)
17 (require 'geiser-base)
18 (require 'geiser)
19 (require 'geiser-load nil t)
20 (require 'geiser-install nil t)
23 ;;; Reload:
25 (defmacro geiser--features-list ()
26 (quote '(
27 geiser-mode
28 geiser-repl
29 geiser-doc
30 geiser-xref
31 geiser-compile
32 geiser-debug
33 geiser-company
34 geiser-edit
35 geiser-completion
36 geiser-autodoc
37 geiser-eval
38 geiser-connection
39 geiser-syntax
40 geiser-menu
41 geiser-impl
42 geiser-custom
43 geiser-log
44 geiser-popup
45 geiser-base
46 geiser-version
47 geiser-install
48 geiser
49 )))
51 (defun geiser-unload ()
52 "Unload all Geiser modules."
53 (interactive)
54 (let ((fs (geiser--features-list)))
55 (unload-feature 'geiser-reload t)
56 (dolist (f fs)
57 (when (featurep f) (unload-feature f t)))))
59 (defun geiser-reload (&optional arg)
60 "Reload Geiser.
61 With prefix arg, prompts for the DIRECTORY from which Geiser should be
62 loaded again."
63 (interactive "P")
64 (let* ((old-dir geiser-elisp-dir)
65 (dir (or (and arg (read-directory-name "New Geiser elisp dir: "
66 old-dir old-dir t old-dir))
67 old-dir)))
68 (unless (or (file-exists-p (expand-file-name "geiser-reload.el" dir))
69 (file-exists-p (expand-file-name "geiser-reload.elc" dir)))
70 (error "%s does not contain Geiser!" dir))
71 (let ((memo (geiser-custom--memoized-state))
72 (repls (geiser-repl--repl-list))
73 (buffers (geiser-mode--buffers)))
74 (geiser-unload)
75 (setq load-path (remove old-dir load-path))
76 (add-to-list 'load-path dir)
77 (mapc (lambda (x) (set (car x) (cdr x))) memo)
78 (require 'geiser-reload)
79 (geiser-repl--restore repls)
80 (geiser-mode--restore buffers)
81 (message "Geiser reloaded!"))))
84 (provide 'geiser-reload)
85 ;;; geiser-reload.el ends here