forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-sessions.el
74 lines (62 loc) · 2.59 KB
/
init-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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;;; init-sessions.el --- Save and restore editor sessions between restarts -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; save a list of open files in ~/.emacs.d/.emacs.desktop
(setq desktop-path (list user-emacs-directory)
desktop-auto-save-timeout 600)
(desktop-save-mode 1)
(defun sanityinc/desktop-time-restore (orig &rest args)
(let ((start-time (current-time)))
(prog1
(apply orig args)
(message "Desktop restored in %.2fms"
(sanityinc/time-subtract-millis (current-time)
start-time)))))
(advice-add 'desktop-read :around 'sanityinc/desktop-time-restore)
(defun sanityinc/desktop-time-buffer-create (orig ver filename &rest args)
(let ((start-time (current-time)))
(prog1
(apply orig ver filename args)
(message "Desktop: %.2fms to restore %s"
(sanityinc/time-subtract-millis (current-time)
start-time)
(when filename
(abbreviate-file-name filename))))))
(advice-add 'desktop-create-buffer :around 'sanityinc/desktop-time-buffer-create)
;; Restore histories and registers after saving
(setq-default history-length 1000)
(add-hook 'after-init-hook 'savehist-mode)
(require-package 'session)
(setq session-save-file (locate-user-emacs-file ".session"))
(setq session-name-disable-regexp "\\(?:\\`'/tmp\\|\\.git/[A-Z_]+\\'\\)")
(setq session-save-file-coding-system 'utf-8)
(add-hook 'after-init-hook 'session-initialize)
;; save a bunch of variables to the desktop file
;; for lists specify the len of the maximal saved data also
(setq desktop-globals-to-save
'((comint-input-ring . 50)
(compile-history . 30)
desktop-missing-file-warning
(dired-regexp-history . 20)
(extended-command-history . 30)
(face-name-history . 20)
(file-name-history . 100)
(grep-find-history . 30)
(grep-history . 30)
(ivy-history . 100)
(magit-revision-history . 50)
(minibuffer-history . 50)
(org-clock-history . 50)
(org-refile-history . 50)
(org-tags-history . 50)
(query-replace-history . 60)
(read-expression-history . 60)
(regexp-history . 60)
(regexp-search-ring . 20)
register-alist
(search-ring . 20)
(shell-command-history . 50)
tags-file-name
tags-table-list))
(provide 'init-sessions)
;;; init-sessions.el ends here