[layouts] Fix error in switch-to-prev-buffer when persp-mode is excluded#17196
Open
bcc32 wants to merge 3 commits into
Open
[layouts] Fix error in switch-to-prev-buffer when persp-mode is excluded#17196bcc32 wants to merge 3 commits into
bcc32 wants to merge 3 commits into
Conversation
Use set-default-toplevel-value to match the default setter's behavior w.r.t. let-binding. Update the docstring to remove mention of the deleted macro. Avoid an unnecessary extra variable to store the old value by simply reading the variable before setting it.
cda97e3 to
df900db
Compare
fnussbaum
reviewed
Dec 21, 2025
Comment on lines
89
to
98
| :type '(repeat function) | ||
| :set (lambda (_ value) | ||
| (dolist (fn spacemacs--old-layouts-restricted-functions) | ||
| (advice-remove fn 'spacemacs-layouts//advice-with-persp-buffer-list)) | ||
| (setq spacemacs--old-layouts-restricted-functions value | ||
| spacemacs-layouts-restricted-functions value) | ||
| (dolist (fn spacemacs-layouts-restricted-functions) | ||
| :set (lambda (var new-value) | ||
| (ignore-error void-variable | ||
| (let ((old-value (default-toplevel-value var))) | ||
| (dolist (fn old-value) | ||
| (advice-remove fn 'spacemacs-layouts//advice-with-persp-buffer-list)))) | ||
| (set-default-toplevel-value var new-value) | ||
| (dolist (fn new-value) | ||
| (advice-add fn :around 'spacemacs-layouts//advice-with-persp-buffer-list)))) |
Collaborator
There was a problem hiding this comment.
When reloading the configuration, the custom set function is run after the value is already set to the new-value (if the variable is set as a layer variable in dotspacemacs-configuration-layers). Hence in this case, with this change, the advice will not be removed correctly. (I should have added a comment here.)
Collaborator
Author
There was a problem hiding this comment.
That's pretty confusing, but good catch. How about instead of trying to handle the case where the variable is set but the :setter isn't run, in the :setter---which seems really hard in the general case---we just make Spacemacs call the setter (if any) for layer variables set by :variables?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the
persp-modepackage is excluded bydotspacemacs-excluded-packages, and thespacemacs-layoutslayer isstill enabled---as it is by default---the advice around functions
listed in
spacemacs-layouts-restricted-functionscan error, causingthe user to be unable to kill buffers, etc.
This PR just makes the advice check whether
persp-contain-buffer-pis actually defined before attempting to potentially call it around
buffer-list.This PR also:
callsite
variable, and also correctly use
set-default-toplevel-valuetoavoid issues if the variable is currently let-bound.