[Conkeror] [PATCH] Session management: restore saved buffers from a JSON file.
Rohan Nicholls
rohan.nicholls at googlemail.com
Fri Sep 19 09:24:17 PDT 2008
On Fri, Sep 5, 2008 at 10:32 PM, Mark Eichin <eichin at gmail.com> wrote:
>>> 3. You must quit conkeror using C-x C-c, rather than through your window
>>> manager, if you want the session to be saved.
>
> I suggest supporting C-x C-s for "save right now" to work with our
> existing save-early-save-often emacs reflexes (and this is what my
> xmlhttprequest-based session-saving does too :-) Should be just a
> direct binding to session.save()...
> _______________________________________________
> Conkeror mailing list
> Conkeror at mozdev.org
> https://www.mozdev.org/mailman/listinfo/conkeror
>
Here is a patch that adds that. It does not bind the keys for you,
but it does create the command.
I shamelessly ripped off the code from the code that was already
there, but so far in my tests it works.
Btw. this is the first git format-patch I've done so I hope it is
correct.
Thanks again to David for implementing sessions, I am loving having
that functionality.
Rohan
Signed-off-by: Rohan <rohan dot nicholls at gmail dot com>
---
modules/session.js | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/modules/session.js b/modules/session.js
index af4bbe1..91a26dd 100644
--- a/modules/session.js
+++ b/modules/session.js
@@ -29,7 +29,7 @@ session_manager.prototype.get_session = function () {
}
});
return ar;
-}
+};
/**
* Encode a session to disk
@@ -41,6 +41,15 @@ session_manager.prototype.save = function () {
add_hook("quit_hook",
function () { if (typeof session != "undefined") session.save(); });
+function save_session(sess_file){
+ if (!conkeror.session){
+ return false;
+ //conkeror.session = new session_manager(sess_file);
+ }
+ conkeror.session.save();
+ return true;
+}
+
/**
* Restore from the session
*/
@@ -53,7 +62,7 @@ session_manager.prototype.restore = function () {
}
make_window(multiple_buffers_creator(creators), tag);
}
-}
+};
/**
* The main entry point. Load all the buffers from the session at `sess_file',
@@ -79,3 +88,14 @@ interactive(
$initial_value = profile_dir + "/session.json");
restore_session(sess_file);
});
+
+interactive(
+ "save-session",
+ "Prompt on the minibuffer for a session file to use for saving." +
+ "The default path is " + profile_dir + "/session.json",
+ function (I) {
+ var sess_file = yield I.minibuffer.read_file_path(
+ $prompt = "Session file:",
+ $initial_value = profile_dir + "/session.json");
+ save_session(sess_file);
+ });
--
1.5.4.3
More information about the Conkeror
mailing list