2016-10-17 00:51:53 +00:00
|
|
|
|
;;; funcs.el --- Spacemacs Purpose Layer functions File
|
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2016-10-17 00:51:53 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Bar Magal
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; eyebrowse integration
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/window-purpose-sync-eyebrowse ()
|
|
|
|
|
"Synchronize window-purpose layer with eyebrowse.
|
|
|
|
|
Set `eyebrowse-new-workspace' value depending on the state of `purpose-mode'."
|
|
|
|
|
(defvar spacemacs--window-purpose-eyebrowse-new-workspace
|
|
|
|
|
eyebrowse-new-workspace
|
|
|
|
|
"Internal backup of `eyebrowse-new-workspace'.")
|
2017-09-26 04:40:51 +00:00
|
|
|
|
(require 'window-purpose)
|
2016-10-17 00:51:53 +00:00
|
|
|
|
(if purpose-mode
|
|
|
|
|
(setq eyebrowse-new-workspace #'spacemacs//window-purpose-new-workspace)
|
|
|
|
|
(setq eyebrowse-new-workspace
|
|
|
|
|
spacemacs--window-purpose-eyebrowse-new-workspace)))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//window-purpose-new-workspace ()
|
|
|
|
|
"Create a new eyebrowse workspace.
|
|
|
|
|
Replacement for `eyebrowse-new-workspace' that handles purpose-dedicated
|
|
|
|
|
windows correctly."
|
|
|
|
|
;; call original `eyebrowse-new-workspace' (partially copied from
|
|
|
|
|
;; `eyebrowse-switch-to-window-config')
|
|
|
|
|
(cond
|
|
|
|
|
((stringp spacemacs--window-purpose-eyebrowse-new-workspace)
|
|
|
|
|
(switch-to-buffer (get-buffer-create
|
|
|
|
|
spacemacs--window-purpose-eyebrowse-new-workspace)))
|
|
|
|
|
((functionp spacemacs--window-purpose-eyebrowse-new-workspace)
|
|
|
|
|
(funcall spacemacs--window-purpose-eyebrowse-new-workspace))
|
|
|
|
|
(t (switch-to-buffer "*scratch*")))
|
|
|
|
|
|
|
|
|
|
;; in case opening the new buffer splitted the frame (e.g.
|
|
|
|
|
;; `eyebrowse-switch-to-window-config' was called from a purpose-dedicated
|
|
|
|
|
;; buffer)
|
|
|
|
|
(delete-other-windows))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Popwin integration
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/window-purpose-sync-popwin ()
|
|
|
|
|
"Synchronize window-purpose layer with popwin.
|
|
|
|
|
Enable or disable advices to popwin, according to the state of `purpose-mode'."
|
2017-09-26 04:40:51 +00:00
|
|
|
|
(require 'window-purpose)
|
2016-10-17 00:51:53 +00:00
|
|
|
|
(if purpose-mode
|
|
|
|
|
(progn
|
|
|
|
|
(ad-enable-advice 'popwin:create-popup-window
|
|
|
|
|
'before 'window-purpose/save-dedicated-windows)
|
|
|
|
|
(ad-enable-advice 'popwin:create-popup-window
|
|
|
|
|
'after 'window-purpose/restore-dedicated-windows)
|
|
|
|
|
(ad-update 'popwin:create-popup-window)
|
|
|
|
|
(ad-activate 'popwin:create-popup-window))
|
|
|
|
|
(ad-disable-advice 'popwin:create-popup-window
|
|
|
|
|
'before 'window-purpose/save-dedicated-windows)
|
|
|
|
|
(ad-disable-advice 'popwin:create-popup-window
|
|
|
|
|
'after 'window-purpose/restore-dedicated-windows)
|
|
|
|
|
(ad-update 'popwin:create-popup-window)))
|