-
Notifications
You must be signed in to change notification settings - Fork 1
/
sessions.el
53 lines (37 loc) · 1.14 KB
/
sessions.el
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
(setq-default sessions-path "~/.emacs.d/sessions")
(setq-default sessions-name nil)
(defun sessions-dir ()
(concat sessions-path "/" sessions-name))
(defun sessions-list ()
(seq-remove (lambda (x) (or (string= x ".") (string= x ".."))) (directory-files sessions-path)))
(defun sessions ()
(interactive)
(message "Available sessions: %s" (sessions-list)))
(defun sessions-set-name (name)
(interactive
(list
(completing-read "Enter session name: " (sessions-list))))
(setq sessions-name name))
(defun sessions-name ()
(interactive)
(message "name: %s" sessions-name))
(defun sessions-save ()
(interactive)
(when (null sessions-name)
(call-interactively 'sessions-set-name))
(let ((dir (sessions-dir)))
(mkdir dir t)
(desktop-save dir))
(sessions-name))
(defun sessions-close ()
(interactive)
(when (and sessions-name
(y-or-n-p (concat "Save current session '" sessions-name "'?")))
(call-interactively 'sessions-save)))
(defun sessions-open ()
(interactive)
(when sessions-name
(call-interactively 'sessions-close))
(call-interactively 'sessions-set-name)
(desktop-change-dir (sessions-dir)))
(provide 'sessions)