You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to create a function to add files to a perspective, only if belonging to a project or a list of projects. I thought that the best way to introduce this custom feature would have been persp-add-buffer-on-after-change-major-mode, as according to its documentation it would support a custom function.
As a workaround, instead of using persp-add-buffer-on-after-change-major-mode-filter-functions, which exlcudes buffers
Additional filters to know which buffers we dont want to add to
the current perspective after the after-change-major-mode-hook is fired.
you can implement a hook similar to persp-after-change-major-mode-h, which is what persp-add-buffer-on-after-change-major-mode enables when set.
This is what I use:
(defcustommigue/persp-major-mode-change-functionsnil"List of functions to run when changing major-modes. If they return true, add the buffer to the currentperspective.":group'persp-mode:type'hook
)
(defunmigue/persp-major-mode-check ()
"Check functions in `migue/persp-major-mode-change-functions', if they return true, add them to thecurrent perspective."
(let ((buf (current-buffer)))
(when (cl-find-if (lambda (filter)
(if (functionp filter)
(funcall filter buf)
))
migue/persp-major-mode-change-functions)
(persp-add-buffer buf (get-current-persp) nilnil)
)
)
)
(add-hook'after-change-major-mode-hook#'migue/persp-major-mode-check)
It's all basically a stripped down version of persp-after-change-major-mode-h, like I said, and persp-buffer-filtered-out-p; but it allows you to choose what types of buffers you want on a case-by-case basis.
I don't think this would be too hard to implement, but my way is probably lacking in some way, which is why I haven't refined it and made a pull request 😅.
Hello,
I wanted to create a function to add files to a perspective, only if belonging to a project or a list of projects. I thought that the best way to introduce this custom feature would have been
persp-add-buffer-on-after-change-major-mode
, as according to its documentation it would support a custom function.Though in the implementation it does not look like it.
Is this intended? Am I missing something?
As a workaround I am currently implementing my functionality as a
persp-add-buffer-on-after-change-major-mode-filter-functions
function.The text was updated successfully, but these errors were encountered: