From 2023aac314f58271c5497e5009a8c2510372dd43 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 Jun 2018 03:10:55 +0200 Subject: [PATCH] Add +treemacs/toggle command --- modules/ui/treemacs/autoload.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 modules/ui/treemacs/autoload.el diff --git a/modules/ui/treemacs/autoload.el b/modules/ui/treemacs/autoload.el new file mode 100644 index 000000000..ba5814106 --- /dev/null +++ b/modules/ui/treemacs/autoload.el @@ -0,0 +1,22 @@ +;;; ui/treemacs/autoload.el -*- lexical-binding: t; -*- + +;;;###autoload +(defun +treemacs/toggle () + "Initialize or toggle treemacs. +* If the treemacs window is visible hide it. +* If a treemacs buffer exists, but is not visible show it. +* If no treemacs buffer exists for the current frame create and show it. +* If the workspace is empty additionally ask for the root path of the first + project to add." + (interactive) + (require 'treemacs) + (-pcase (treemacs--current-visibility) + ['visible (delete-window (treemacs--is-visible?))] + ['exists (treemacs-select-window)] + ['none + (let ((project-root (doom-project-root 'nocache))) + (when project-root + (unless (treemacs--find-project-for-path project-root) + (treemacs-add-project-at (treemacs--canonical-path project-root) + (doom-project-name 'nocache)))) + (treemacs--init project-root))]))