aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/session.tes
blob: 3ca5dd9b30cb8360646ae579a21f1802d62615d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
! Macros for saving and loading buffer sessions !

! Path of the session profile.
  Change this to save/load a custom profile.
  If empty or undefined, no session will be saved. !
EU[session.path]Q[$SCITECOCONFIG]/.teco_session

! Save current session to the file specified by "session.path" !
@[session.save]{
  :Q[session.path]-1"<  '
  Q*U.[curbuf]
  EJ<
    %.bEB ESGETFIRSTVISIBLELINEU.[fvline] ESGETXOFFSETU.[xoff] .U.[dot]
    :@EU.[session]{EBQ* \.[fvline]ESSETFIRSTVISIBLELINE \.[xoff]ESSETXOFFSET \.[dot]:J^M}
    :Q*"= -1U.u '
  >
  ! We always start with an unnamed file in the ring, so we may have to remove it: !
  Q.u"F :@EU.[session]{EB -EF^M} '
  :@EU.[session]{\.[curbuf]EB^M}

  E%.[session]Q[session.path]
  Q.[curbuf]EB
}

! Load session specified by "session.path" !
@[session.load]{
  EJ<-EF>
  ! now we have only one unnamed buffer !
  [_
    1:EN*Q[session.path]"S
      :EMQ[session.path]
    '
  ]_
}

! Call this to set up the session path unique to the
  Git repository of the current working directory (if there is one).
  This requires the Git command-line client in $PATH. !
@[session.git]{
  ! if there is no Git repository, session.path is left as it is !
  :EG[session.path]git rev-parse --show-toplevel"S
    [* EQ[session.path] ZJ -D I/.teco_session ]*
  '
}

! Call to set up the session path unique to the
  Mercurial repository of the current working directory.
  This requires the Mercurial command-line client in $PATH. !
@[session.hg]{
  ! if there is no Hg repository, session.path is left as it is !
  :EG[session.path]hg root"S
    [* EQ[session.path] ZJ -D I/.teco_session ]*
  '
}

! Call to set up the session path unique to the
  SVN working copy containing the current working directory.
  Requires the SVN client v1.7 or later in $PATH. !
@[session.svn]{
  ! if there is no SVN working copy, session.path is left as it is !
  :EG.isvn info --xml"S [*[_
    EQ.i
    :S<wcroot-abspath>"S
      .(S</.-2)X[session.path] :[session.path]/.teco_session
    '
  ]_]* '
}

! Call to set up the session path unique to the
  repository/working copy containing the current working directory
  (see above). !
@[session.vcs]{
  M[session.git]
  M[session.hg]
  M[session.svn]
}