diff options
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/session.tes | 42 | ||||
-rw-r--r-- | teco.ini | 29 |
3 files changed, 64 insertions, 9 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 8a2a3eb..fef26ef 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,5 +1,5 @@ -dist_scitecolib_DATA = color.tes lexer.tes fnkeys.tes +dist_scitecolib_DATA = color.tes lexer.tes session.tes fnkeys.tes dist_scitecolib_DATA += string.tes # Install and distribute entire directories 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 + ' +} @@ -4,13 +4,18 @@ EMQ[$SCITECOPATH]/color.tes :EMQ[$SCITECOPATH]/colors/terminal.tes -! Load lexer library ! +! Load lexer and buffer session libraries ! EMQ[$SCITECOPATH]/lexer.tes +EMQ[$SCITECOPATH]/session.tes -! Automatic lexing using ED hooks ! +! Uncomment to use a separate session per Git repository ! +! M[session.git] ! + +! Automatic lexing and session management using ED hooks ! @#ED{ Oadd,edit,close,quit !add! + ! Add code here to execute when a document is added ! M[lexer.auto] ! Set up margins ! 33ESTEXTWIDTH9U.w @@ -21,13 +26,16 @@ EMQ[$SCITECOPATH]/lexer.tes !edit! ! Add code here to execute when a document is edited ! + Oend !close! ! Add code here to execute when a document is closed ! + Oend !quit! ! Add code here to execute when SciTECO quits ! -} + M[session.save] +!end!} 0,32ED ! Keyboard macros ! @@ -35,8 +43,13 @@ EMQ[$SCITECOPATH]/fnkeys.tes ! Uncomment to enable default keyboard macros ! ! 0,64ED ! -! open all files specified on the commandline ! -[.f - <:L;R 0X.f EBQ.f EB L> -].f --EF +! open all files specified on the commandline + If no file is specified, load the last buffer session ! +Z"= + M[session.load] +| + [.f + <:L;R 0X.f EBQ.f EB L> + ].f + -EF +' |