mirror of
https://github.com/SqrtMinusOne/perspective-exwm.el.git
synced 2025-12-10 12:53:02 +03:00
fix: correct perspective name after exwm-workspace-add
This commit is contained in:
parent
3a4d382a74
commit
c6e99b8457
1 changed files with 22 additions and 2 deletions
|
|
@ -245,6 +245,11 @@ frame."
|
||||||
(unless (and (derived-mode-p 'exwm-mode) exwm--floating-frame)
|
(unless (and (derived-mode-p 'exwm-mode) exwm--floating-frame)
|
||||||
(apply fun args)))
|
(apply fun args)))
|
||||||
|
|
||||||
|
(defvar perspective-exwm--override-current-index nil
|
||||||
|
"The true index of the workspace under creation.
|
||||||
|
|
||||||
|
Overrides the index in `perspective-exwm--init-frame-around'.")
|
||||||
|
|
||||||
(defun perspective-exwm--init-frame-around (fun &rest args)
|
(defun perspective-exwm--init-frame-around (fun &rest args)
|
||||||
"An advice around `persp-init-frame'.
|
"An advice around `persp-init-frame'.
|
||||||
|
|
||||||
|
|
@ -259,7 +264,8 @@ length of that list if it's not yet there. This approach seems
|
||||||
to work best, e.g. when doing `exwm-workspace-switch-create' and
|
to work best, e.g. when doing `exwm-workspace-switch-create' and
|
||||||
creating multiple workspaces at once."
|
creating multiple workspaces at once."
|
||||||
(let* ((workspace-index
|
(let* ((workspace-index
|
||||||
(or (cl-position (car args) exwm-workspace--list)
|
(or perspective-exwm--override-current-index
|
||||||
|
(cl-position (car args) exwm-workspace--list)
|
||||||
(length exwm-workspace--list)))
|
(length exwm-workspace--list)))
|
||||||
(persp-initial-frame-name
|
(persp-initial-frame-name
|
||||||
(or
|
(or
|
||||||
|
|
@ -268,11 +274,21 @@ creating multiple workspaces at once."
|
||||||
(format "main-%s" (funcall exwm-workspace-index-map workspace-index)))))
|
(format "main-%s" (funcall exwm-workspace-index-map workspace-index)))))
|
||||||
(apply fun args)))
|
(apply fun args)))
|
||||||
|
|
||||||
|
(defun perspective-exwm--workspace-add-around (fun &rest args)
|
||||||
|
"An advice around `exwm-workspace-add'.
|
||||||
|
|
||||||
|
This is necessary because `exwm-workspace-add' first calls
|
||||||
|
`make-frame' and only then moves it to the right index,
|
||||||
|
i.e. there is no way to determine the true index of workspace
|
||||||
|
under creation `persp-init-frame'."
|
||||||
|
(let ((perspective-exwm--override-current-index (car args)))
|
||||||
|
(apply fun args)))
|
||||||
|
|
||||||
(defun perspective-exwm--after-exwm-init ()
|
(defun perspective-exwm--after-exwm-init ()
|
||||||
"Create perspectives in workspaces.
|
"Create perspectives in workspaces.
|
||||||
|
|
||||||
`perspective-exwm-override-initial-name' determines initial names
|
`perspective-exwm-override-initial-name' determines initial names
|
||||||
of perspectives..
|
of perspectives.
|
||||||
|
|
||||||
The function is meant to be run from `exwm-init-hook'."
|
The function is meant to be run from `exwm-init-hook'."
|
||||||
(cl-loop for workspace-index from 0 to (exwm-workspace--count)
|
(cl-loop for workspace-index from 0 to (exwm-workspace--count)
|
||||||
|
|
@ -415,6 +431,8 @@ inital workspaces are created with the new perspective names."
|
||||||
:override #'perspective-exwm--persp-buffer-in-other-p)
|
:override #'perspective-exwm--persp-buffer-in-other-p)
|
||||||
(advice-add #'persp-set-buffer
|
(advice-add #'persp-set-buffer
|
||||||
:override #'perspective-exwm--persp-set-buffer-override)
|
:override #'perspective-exwm--persp-set-buffer-override)
|
||||||
|
(advice-add #'exwm-workspace-add
|
||||||
|
:around #'perspective-exwm--workspace-add-around)
|
||||||
(add-hook 'exwm-init-hook #'perspective-exwm--after-exwm-init))
|
(add-hook 'exwm-init-hook #'perspective-exwm--after-exwm-init))
|
||||||
(advice-remove #'persp-delete-frame
|
(advice-remove #'persp-delete-frame
|
||||||
#'perspective-exwm--delete-frame-around)
|
#'perspective-exwm--delete-frame-around)
|
||||||
|
|
@ -424,6 +442,8 @@ inital workspaces are created with the new perspective names."
|
||||||
#'perspective-exwm--persp-buffer-in-other-p)
|
#'perspective-exwm--persp-buffer-in-other-p)
|
||||||
(advice-remove #'persp-set-buffer
|
(advice-remove #'persp-set-buffer
|
||||||
#'perspective-exwm--persp-set-buffer-override)
|
#'perspective-exwm--persp-set-buffer-override)
|
||||||
|
(advice-remove #'exwm-workspace-add
|
||||||
|
#'perspective-exwm--workspace-add-around)
|
||||||
(remove-hook 'exwm-init-hook #'perspective-exwm--after-exwm-init))))
|
(remove-hook 'exwm-init-hook #'perspective-exwm--after-exwm-init))))
|
||||||
|
|
||||||
(provide 'perspective-exwm)
|
(provide 'perspective-exwm)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue