2016-01-29 02:07:20 -05:00
|
|
|
;;; core-sessions.el
|
2015-06-15 09:05:52 +02:00
|
|
|
|
2016-01-02 15:07:01 -05:00
|
|
|
;; I use workgroups to accomplish two things:
|
|
|
|
;; 1. Vim-like tab emulation (type :tabs to see a list of tabs -- maybe I'll add some
|
|
|
|
;; code to make a permanent frame header to display these some day)
|
|
|
|
;; 2. Session persistence
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(use-package workgroups2
|
2015-11-30 05:32:55 -05:00
|
|
|
:when (display-graphic-p)
|
2015-06-15 09:05:52 +02:00
|
|
|
:init
|
2015-11-30 05:32:55 -05:00
|
|
|
(setq-default
|
2016-03-15 23:33:52 -04:00
|
|
|
wg-session-file (expand-file-name "workgroups/last" narf-temp-dir)
|
2016-03-03 01:36:42 -05:00
|
|
|
wg-workgroup-directory (expand-file-name "workgroups/" narf-temp-dir)
|
2015-12-10 20:43:33 -05:00
|
|
|
wg-first-wg-name "*untitled*"
|
2016-03-15 23:33:52 -04:00
|
|
|
wg-session-load-on-start nil
|
2015-11-30 05:32:55 -05:00
|
|
|
wg-mode-line-display-on nil
|
2015-12-11 16:51:04 -05:00
|
|
|
wg-mess-with-buffer-list nil
|
2015-11-30 05:32:55 -05:00
|
|
|
wg-emacs-exit-save-behavior 'save ; Options: 'save 'ask nil
|
|
|
|
wg-workgroups-mode-exit-save-behavior 'save
|
|
|
|
wg-log-level 0
|
|
|
|
|
2016-03-15 23:33:52 -04:00
|
|
|
;; NOTE: Some of these make workgroup-restoration unstable
|
|
|
|
wg-restore-fringes t
|
|
|
|
wg-restore-margins t
|
|
|
|
wg-restore-scroll-bars t
|
|
|
|
wg-restore-frame-position t
|
|
|
|
wg-restore-remote-buffers t
|
|
|
|
wg-restore-mark t
|
|
|
|
wg-restore-point-max t
|
2015-12-29 23:14:24 -05:00
|
|
|
|
2015-12-10 20:43:33 -05:00
|
|
|
wg-list-display-decor-divider " "
|
|
|
|
wg-list-display-decor-left-brace ""
|
2015-12-11 16:51:04 -05:00
|
|
|
wg-list-display-decor-right-brace "| "
|
2015-12-10 20:43:33 -05:00
|
|
|
wg-list-display-decor-current-left ""
|
|
|
|
wg-list-display-decor-current-right ""
|
2015-11-30 05:32:55 -05:00
|
|
|
wg-list-display-decor-previous-left ""
|
|
|
|
wg-list-display-decor-previous-right "")
|
2015-06-15 09:05:52 +02:00
|
|
|
|
2016-03-01 02:05:04 -05:00
|
|
|
(add-hook! emacs-startup (workgroups-mode +1))
|
|
|
|
:config
|
2015-12-11 16:51:04 -05:00
|
|
|
(unless (file-exists-p wg-workgroup-directory)
|
|
|
|
(mkdir wg-workgroup-directory))
|
2015-11-08 17:57:41 -05:00
|
|
|
|
2015-12-21 05:44:44 -05:00
|
|
|
(defvar narf-wg-frames '()
|
|
|
|
"A list of all the frames opened as separate workgroups. See
|
2016-03-03 01:36:42 -05:00
|
|
|
defuns/defuns-workgroups.el.")
|
2015-12-21 05:44:44 -05:00
|
|
|
(defvar narf-wg-names '()
|
|
|
|
"A list of fixed names for workgroups. If a name is set, workgroup names aren't
|
2016-03-03 01:36:42 -05:00
|
|
|
automatically renamed to the project name.")
|
2015-12-21 05:44:44 -05:00
|
|
|
|
|
|
|
;; Remember the set names in between sessions
|
|
|
|
(add-to-list 'savehist-additional-variables 'narf-wg-names)
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(after! projectile
|
2015-11-14 02:41:53 -05:00
|
|
|
;; Create a new workgroup on switch-project
|
2015-06-15 09:05:52 +02:00
|
|
|
(setq projectile-switch-project-action 'narf/wg-projectile-switch-project))
|
|
|
|
|
2016-01-02 15:07:01 -05:00
|
|
|
;; Save the session every 20 minutes
|
|
|
|
(defvar narf-wg-autosave-interval 1200)
|
|
|
|
(narf|wg-autosave-enable)
|
2016-03-03 01:36:42 -05:00
|
|
|
(add-hook 'focus-out-hook 'narf|wg-autosave-disable)
|
|
|
|
(add-hook 'focus-in-hook 'narf|wg-autosave-enable)
|
2015-12-21 05:44:44 -05:00
|
|
|
|
|
|
|
;; Don't mess with the modeline!
|
|
|
|
(advice-add 'wg-change-modeline :override 'ignore)
|
2015-11-25 06:00:49 -05:00
|
|
|
|
2015-12-21 05:44:44 -05:00
|
|
|
;; Don't remember popup windows
|
2016-03-04 22:34:38 -05:00
|
|
|
(add-hook! kill-emacs
|
|
|
|
(narf/popup-close-all)
|
|
|
|
(when (and (featurep 'neotree) (neo-global--window-exists-p))
|
|
|
|
(neotree-hide)))
|
2015-12-29 23:37:43 -05:00
|
|
|
|
|
|
|
;; This helps abstract some of the underlying functions away, just in case I want to
|
|
|
|
;; switch to a different package in the future, like persp-mode, eyebrowse or wconf.
|
2016-01-27 20:42:48 -05:00
|
|
|
(defalias 'narf/tab-display 'narf/workgroup-display)
|
2015-12-29 23:37:43 -05:00
|
|
|
(defalias 'narf/helm-tabs 'narf:helm-wg)
|
|
|
|
(defalias 'narf/close-window-or-tab 'narf/close-window-or-workgroup)
|
|
|
|
(defalias 'narf:tab-create 'narf:workgroup-new)
|
|
|
|
(defalias 'narf:tab-rename 'narf:workgroup-rename)
|
|
|
|
(defalias 'narf:kill-tab 'narf:workgroup-delete)
|
|
|
|
(defalias 'narf:kill-other-tabs 'narf:kill-other-workgroups)
|
2016-01-27 20:42:48 -05:00
|
|
|
(defalias 'narf:switch-to-tab 'narf:switch-to-workgroup-at-index)
|
2015-12-29 23:37:43 -05:00
|
|
|
(defalias 'narf:switch-to-tab-left 'wg-switch-to-workgroup-left)
|
|
|
|
(defalias 'narf:switch-to-tab-right 'wg-switch-to-workgroup-right)
|
|
|
|
(defalias 'narf:switch-to-tab-last 'wg-switch-to-previous-workgroup))
|
2015-06-15 09:05:52 +02:00
|
|
|
|
2016-01-29 02:07:20 -05:00
|
|
|
(provide 'core-sessions)
|
|
|
|
;;; core-sessions.el ends here
|