diff --git a/workgroups-commands-minibuffer.el b/workgroups-commands-minibuffer.el new file mode 100644 index 0000000000000000000000000000000000000000..9264742817e069d8d2cbefb6f5417acd3fb261d0 --- /dev/null +++ b/workgroups-commands-minibuffer.el @@ -0,0 +1,58 @@ +;;; wg-minibuffer-mode commands + +(defun wg-next-buffer-list-filter () + "Trigger a switch to the next buffer-list-filter." + (interactive) + (throw 'wg-action (list 'next (minibuffer-contents)))) + +(defun wg-previous-buffer-list-filter () + "Trigger a switch to the previous buffer-list-filter." + (interactive) + (throw 'wg-action (list 'prev (minibuffer-contents)))) + +(defun wg-backward-char-or-next-buffer-list-filter () + "Call `backward-char' unless `point' is right after the prompt, +in which case call `wg-next-buffer-list-filter'." + (interactive) + (if (> (point) (minibuffer-prompt-end)) (backward-char) + (wg-next-buffer-list-filter))) + +(defun wg-backward-char-or-previous-buffer-list-filter (&optional num) + "Call `backward-char' unless `point' is right after the prompt, +in which case call `wg-previous-buffer-list-filter'." + (interactive) + (if (> (point) (minibuffer-prompt-end)) (backward-char) + (wg-previous-buffer-list-filter))) + +(defun wg-dissociate-first-match () + "Dissociate the first match from current workgroup." + (interactive) + (wg-when-let + ((mode (wg-read-buffer-mode)) + (buffer (wg-current-match mode)) + (pos (position buffer (wg-filtered-buffer-list t) :test 'equal))) + (wg-workgroup-dissociate-bufobj (wg-current-workgroup) buffer) + (wg-set-current-matches + (wg-rotate-list (wg-filtered-buffer-list t) pos) mode))) + +(defun wg-associate-first-match () + "Associate the first match with or update it in the current workgroup." + (interactive) + (wg-when-let + ((mode (wg-read-buffer-mode)) + (buffer (wg-current-match mode)) + (pos (position buffer (wg-filtered-buffer-list t) :test 'equal))) + (wg-workgroup-associate-bufobj (wg-current-workgroup) buffer) + (wg-set-current-matches + (wg-rotate-list (wg-filtered-buffer-list t) pos) mode))) + +(defun wg-minibuffer-mode-dissociate-weakly-associated-buffers () + "Dissociate weakly associated buffers and update the current matches." + (interactive) + (wg-workgroup-dissociate-weakly-associated-buffers (wg-current-workgroup)) + (wg-set-current-matches + (let ((remaining (wg-filtered-buffer-list t))) + (remove-if-not (lambda (match) (member match remaining)) + (wg-current-matches))))) + +(provide 'workgroups-commands-minibuffer)