branch: elpa/projectile
commit 490067591660e0901358656152066a5c5221ff5c
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Wrap add-dir-local-variable in save-selected-window in toggle-read-only
add-dir-local-variable switches to the .dir-locals.el buffer.
Without save-selected-window, kill-buffer and the subsequent
buffer-file-name check operated on unpredictable buffers. This
matches the pattern already used in projectile-add-dir-local-variable.
---
projectile.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/projectile.el b/projectile.el
index 65b38eeeb0..7c2b0f799e 100644
--- a/projectile.el
+++ b/projectile.el
@@ -2671,9 +2671,10 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache
first."
(let ((inhibit-read-only t)
(val (not buffer-read-only))
(default-directory (projectile-acquire-root)))
- (add-dir-local-variable nil 'buffer-read-only val)
- (save-buffer)
- (kill-buffer)
+ (save-selected-window
+ (add-dir-local-variable nil 'buffer-read-only val)
+ (save-buffer)
+ (kill-buffer))
(when buffer-file-name
(read-only-mode (if val +1 -1))
(message "[%s] read-only-mode is %s" (projectile-project-name) (if val
"on" "off")))))