Skip to content

Instantly share code, notes, and snippets.

@leoliu
Created May 2, 2012 12:43
Show Gist options
  • Save leoliu/2576300 to your computer and use it in GitHub Desktop.
Save leoliu/2576300 to your computer and use it in GitHub Desktop.
support pymacs-load-history
From dfd03260f9d0862f2b02fe0ab46fd12cee4a2447 Mon Sep 17 00:00:00 2001
From: Leo Liu <sdl.web@gmail.com>
Date: Wed, 2 May 2012 10:45:45 +0800
Subject: [PATCH] support pymacs-load-history
---
pymacs.el.in | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/pymacs.el.in b/pymacs.el.in
index 4e5a9f2f..e3b24a73 100644
--- a/pymacs.el.in
+++ b/pymacs.el.in
@@ -138,6 +138,8 @@ Possible values are nil, t or ask.")
"If zombies should trigger hard errors, whenever they get called.
If `nil', calling a zombie will merely produce a diagnostic message.")
+(defvar pymacs-load-history nil "Pymacs loading history.")
+
;;;###autoload
(defun pymacs-load (module &optional prefix noerror)
"Import the Python module named MODULE into Emacs.
@@ -155,6 +157,10 @@ If NOERROR is not nil, do not raise error when the module is not found."
(message "Pymacs loading %s..." module)
(let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix)))
(cond (lisp-code (let ((result (eval lisp-code)))
+ (add-to-list 'pymacs-load-history
+ (list module prefix noerror)
+ ;; append so that order is kept
+ 'append)
(message "Pymacs loading %s...done" module)
result))
(noerror (message "Pymacs loading %s...failed" module) nil)
@@ -656,7 +662,12 @@ The timer is used only if `post-gc-hook' is not available.")
(add-hook 'post-gc-hook 'pymacs-schedule-gc)
(setq pymacs-gc-timer (run-at-time 20 20 'pymacs-schedule-gc))))
;; If nothing failed, only then declare that Pymacs has started!
- (setq pymacs-transit-buffer buffer)))
+ (setq pymacs-transit-buffer buffer)
+ (when (and pymacs-load-history
+ (yes-or-no-p "Reload modules in previous session? "))
+ (mapc (lambda (args)
+ (apply 'pymacs-load args))
+ pymacs-load-history))))
(defun pymacs-terminate-services ()
;; This function is mainly provided for documentation purposes.
--
1.7.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment