mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-23 19:47:58 +01:00
Factor out prompt for workspace
* exwm-workspace.el (exwm-workspace--prompt-for-workspace): New function to interactively ask the user for a workspace. (exwm-workspace-switch, exwm-workspace-move-window): Use it.
This commit is contained in:
parent
07120a0562
commit
2de2d42586
1 changed files with 14 additions and 21 deletions
|
@ -92,6 +92,18 @@ NIL if FRAME is not a workspace"
|
|||
(defvar exwm-workspace--switch-history-outdated nil
|
||||
"Non-nil to indicate `exwm-workspace--switch-history' is outdated.")
|
||||
|
||||
(defun exwm-workspace--prompt-for-workspace ()
|
||||
"Prompt for a workspace, returning the workspace frame."
|
||||
(exwm-workspace--update-switch-history)
|
||||
(let* ((current-idx (exwm-workspace--position exwm-workspace--current))
|
||||
(history-add-new-input nil) ;prevent modifying history
|
||||
(history-idx (read-from-minibuffer
|
||||
"Workspace: " (elt exwm-workspace--switch-history current-idx)
|
||||
exwm-workspace--switch-map nil
|
||||
`(exwm-workspace--switch-history . ,(1+ current-idx))))
|
||||
(workspace-idx (cl-position history-idx exwm-workspace--switch-history :test #'equal)))
|
||||
(elt exwm-workspace--list workspace-idx)))
|
||||
|
||||
(defun exwm-workspace--update-switch-history ()
|
||||
"Update the history for switching workspace to reflect the latest status."
|
||||
(when exwm-workspace--switch-history-outdated
|
||||
|
@ -317,15 +329,7 @@ The optional FORCE option is for internal use only."
|
|||
(interactive
|
||||
(list
|
||||
(unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
|
||||
(exwm-workspace--update-switch-history)
|
||||
(let* ((current-idx (exwm-workspace--position exwm-workspace--current))
|
||||
(history-add-new-input nil) ;prevent modifying history
|
||||
(history-idx (read-from-minibuffer
|
||||
"Workspace: " (elt exwm-workspace--switch-history current-idx)
|
||||
exwm-workspace--switch-map nil
|
||||
`(exwm-workspace--switch-history . ,(1+ current-idx))))
|
||||
(workspace-idx (cl-position history-idx exwm-workspace--switch-history :test #'equal)))
|
||||
(elt exwm-workspace--list workspace-idx)))))
|
||||
(exwm-workspace--prompt-for-workspace))))
|
||||
(let* ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
|
||||
(index (exwm-workspace--position frame))
|
||||
(workspace (frame-parameter frame 'exwm-workspace))
|
||||
|
@ -419,18 +423,7 @@ The optional FORCE option is for internal use only."
|
|||
;;;###autoload
|
||||
(defun exwm-workspace-move-window (frame-or-index &optional id)
|
||||
"Move window ID to workspace FRAME-OR-INDEX."
|
||||
(interactive
|
||||
(list
|
||||
(progn
|
||||
(exwm-workspace--update-switch-history)
|
||||
(let* ((current-idx (exwm-workspace--position exwm-workspace--current))
|
||||
(history-add-new-input nil) ;prevent modifying history
|
||||
(history-idx (read-from-minibuffer
|
||||
"Workspace: " (elt exwm-workspace--switch-history current-idx)
|
||||
exwm-workspace--switch-map nil
|
||||
`(exwm-workspace--switch-history . ,(1+ current-idx))))
|
||||
(workspace-idx (cl-position history-idx exwm-workspace--switch-history :test #'equal)))
|
||||
(elt exwm-workspace--list workspace-idx)))))
|
||||
(interactive (list (exwm-workspace--prompt-for-workspace)))
|
||||
(let ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index)))
|
||||
(unless id (setq id (exwm--buffer->id (window-buffer))))
|
||||
(with-current-buffer (exwm--id->buffer id)
|
||||
|
|
Loading…
Reference in a new issue