featurep! will be renamed modulep! in the future, so it's been deprecated. They have identical interfaces, and can be replaced without issue. featurep! was never quite the right name for this macro. It implied that it had some connection to featurep, which it doesn't (only that it was similar in purpose; still, Doom modules are not features). To undo such implications and be consistent with its namespace (and since we're heading into a storm of breaking changes with the v3 release anyway), now was the best opportunity to begin the transition.
34 lines
1.3 KiB
EmacsLisp
34 lines
1.3 KiB
EmacsLisp
;;; emacs/ibuffer/autoload/workspaces.el -*- lexical-binding: t; -*-
|
|
;;;###if (modulep! :ui workspaces)
|
|
|
|
;;;###autoload
|
|
(defun +ibuffer-workspace (workspace-name)
|
|
"Open an ibuffer window for a workspace"
|
|
(ibuffer nil (format "%s buffers" workspace-name)
|
|
(list (cons 'workspace-buffers (+workspace-get workspace-name)))))
|
|
|
|
;;;###autoload
|
|
(defun +ibuffer/open-for-current-workspace ()
|
|
"Open an ibuffer window for the current workspace"
|
|
(interactive)
|
|
(+ibuffer-workspace (+workspace-current-name)))
|
|
|
|
;;;###autoload
|
|
(defun +ibuffer/visit-workspace-buffer (&optional select-first)
|
|
"Visit buffer, but switch to its workspace if it exists."
|
|
(interactive "P")
|
|
(let ((buf (ibuffer-current-buffer t)))
|
|
(unless (buffer-live-p buf)
|
|
(user-error "Not a valid or live buffer: %s" buf))
|
|
(if-let (workspaces
|
|
(cl-loop for wk in (+workspace-list)
|
|
if (+workspace-contains-buffer-p buf wk)
|
|
collect wk))
|
|
(+workspace-switch
|
|
(if (and (not select-first) (cdr workspaces))
|
|
(or (completing-read "Select workspace: " (mapcar #'persp-name workspaces))
|
|
(user-error "Aborted"))
|
|
(persp-name (car workspaces))))
|
|
;; Or add the buffer to the current workspace
|
|
(persp-add-buffer buf))
|
|
(switch-to-buffer buf)))
|