From 53f5121a031fddf380df8f52f8aff323cbc8cde7 Mon Sep 17 00:00:00 2001 From: Boris Buliga Date: Thu, 11 Oct 2018 19:58:53 +0300 Subject: [PATCH] allow dynamic width lock setup for treemacs Following #11384 Right now treemacs-lock-width variable affects width lock only during treemacs initialisation. Any later modifications have no effect on treemacs behaviour. This commit changes it by moving evaluation of treemacs-lock-width to the treemacs-mode-hook. --- layers/+filetree/treemacs/funcs.el | 7 ++++--- layers/+filetree/treemacs/packages.el | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/layers/+filetree/treemacs/funcs.el b/layers/+filetree/treemacs/funcs.el index f45e746b7..be400dbff 100644 --- a/layers/+filetree/treemacs/funcs.el +++ b/layers/+filetree/treemacs/funcs.el @@ -21,8 +21,9 @@ (treemacs-do-add-project-to-workspace path name) (treemacs-select-window)))) -(defun spacemacs/treemacs-toggle-locked-width-off () - "Unlock the manual resizing of the treemacs window." +(defun spacemacs/treemacs-setup-width-lock () + "Setup the width lock of treemacs buffer based on +`treemacs-lock-width'." (interactive) - (when treemacs--width-is-locked + (when (xor treemacs--width-is-locked treemacs-lock-width) (treemacs-toggle-fixed-width))) diff --git a/layers/+filetree/treemacs/packages.el b/layers/+filetree/treemacs/packages.el index c83fca12b..9c02ec351 100644 --- a/layers/+filetree/treemacs/packages.el +++ b/layers/+filetree/treemacs/packages.el @@ -41,9 +41,8 @@ treemacs-never-persist nil treemacs-goto-tag-strategy 'refetch-index treemacs-collapse-dirs treemacs-use-collapsed-directories) - (unless treemacs-lock-width - (add-hook 'treemacs-mode-hook - 'spacemacs/treemacs-toggle-locked-width-off)) + (add-hook 'treemacs-mode-hook + #'spacemacs/treemacs-setup-width-lock) (spacemacs/set-leader-keys "ft" 'treemacs "fB" 'treemacs-bookmark