aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/session.tes
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2014-11-22 18:10:49 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-11-22 18:10:49 +0100
commitd38df4805e2c4b2a7b8aeee6e53d557bef5d67e3 (patch)
treefb3074e22b5e980831511293f541bf97d6428541 /lib/session.tes
parenta37daa872ce648f201d26d0d6c3deff2bb54c354 (diff)
downloadsciteco-d38df4805e2c4b2a7b8aeee6e53d557bef5d67e3.tar.gz
added a buffer session module (session.tes)
This is a simple and straight-forward implementation of buffer sessions in SciTECO. A session is merely a SciTECO script that opens files when executed (and restores properties). The current session is identified by this script's filename in Q-Register "session.path": ~/.teco_session by default. Users may set "session.path" to manage different profiles. An abstraction of session "names" is not provided. Users are expected to hack these on their own. For the common task of having one session per profile, the "session.git" macro is provided. It set's up the current session relative to the current Git repository. This will create ".teco_session" files in the root of Git repositories, that may be added to a global ignore pattern (or they may even be versioned!)
Diffstat (limited to 'lib/session.tes')
-rw-r--r--lib/session.tes42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/session.tes b/lib/session.tes
new file mode 100644
index 0000000..d038db5
--- /dev/null
+++ b/lib/session.tes
@@ -0,0 +1,42 @@
+! Macros for saving and loading buffer sessions !
+
+! Path of the session profile.
+ Change this to save/load a custom profile !
+EQ[session.path] IQ[$HOME]/.teco_session 1EB
+
+@[session.save]{
+ Q*U.[curbuf]
+ EJ<
+ %.bEB ESGETFIRSTVISIBLELINEU.[fvline] ESGETXOFFSETU.[xoff] .U.[dot]
+ EQ.[session]
+ @I{EBQ* \.[fvline]ESSETFIRSTVISIBLELINE \.[xoff]ESSETXOFFSET \.[dot]:J^M}
+ EQ* Z"= -1U.u '
+ >
+ EQ.[session]
+ Q.u"F @I{EB -EF^M} '
+ @I{\.[curbuf]EB^M}
+
+ EBQ[session.path]
+ HK G.[session] EW EF
+}
+
+@[session.load]{
+ EJ<-EF>
+ EQ.x ENQ[session.path]
+ Z"=
+ 1EB
+ |
+ :EMQ[session.path]
+ '
+}
+
+! Call this to set up the session path unique to
+ the current Git repository (if there is one) !
+@[session.git]{
+ ! if there is no Git repository, session.path is left as it is !
+ :EG[session.path]git rev-parse --show-toplevel"S
+ Q*U.#cb
+ EQ[session.path] ZJ -D I/.teco_session
+ Q.#cbEB
+ '
+}