ui/treemacs: fix SPC o P (treemacs-find-file)
Would create a blank treemacs window when invoked before a treemacs window was first initialized.
This commit is contained in:
parent
be8eedc296
commit
cab0ee33d1
2 changed files with 30 additions and 18 deletions
|
@ -703,7 +703,7 @@
|
|||
:desc "Find file in project sidebar" :n "P" #'+neotree/find-this-file)
|
||||
(:when (featurep! :ui treemacs)
|
||||
:desc "Project sidebar" :n "p" #'+treemacs/toggle
|
||||
:desc "Find file in project sidebar" :n "P" #'treemacs-find-file)
|
||||
:desc "Find file in project sidebar" :n "P" #'+treemacs/find-file)
|
||||
:desc "Imenu sidebar" :nv "i" #'imenu-list-smart-toggle
|
||||
:desc "Terminal" :n "t" #'+term/open
|
||||
:desc "Terminal in popup" :n "T" #'+term/open-popup-in-project
|
||||
|
|
|
@ -1,27 +1,39 @@
|
|||
;;; ui/treemacs/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +treemacs--init ()
|
||||
(require 'treemacs)
|
||||
(let ((origin-buffer (current-buffer)))
|
||||
(cl-letf (((symbol-function 'treemacs-workspace->is-empty?)
|
||||
(symbol-function 'ignore)))
|
||||
(treemacs--init))
|
||||
(dolist (project (treemacs-workspace->projects (treemacs-current-workspace)))
|
||||
(treemacs-do-remove-project-from-workspace project))
|
||||
(with-current-buffer origin-buffer
|
||||
(treemacs-do-add-project-to-workspace
|
||||
(treemacs--canonical-path (doom-project-root 'nocache))
|
||||
(doom-project-name 'nocache))
|
||||
(setq treemacs--ready-to-follow t)
|
||||
(when (or treemacs-follow-after-init treemacs-follow-mode)
|
||||
(treemacs--follow)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +treemacs/toggle ()
|
||||
"Initialize or toggle treemacs.
|
||||
|
||||
Ensures that only the current project is present and all other projects have
|
||||
been removed."
|
||||
been removed.
|
||||
|
||||
Use `treemacs' command for old functionality."
|
||||
(interactive)
|
||||
(require 'treemacs)
|
||||
(pcase (treemacs-current-visibility)
|
||||
(`visible (delete-window (treemacs-get-local-window)))
|
||||
(_ (+treemacs--init))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +treemacs/find-file (arg)
|
||||
"Open treemacs (if necessary) and find current file."
|
||||
(interactive "P")
|
||||
(let ((origin-buffer (current-buffer)))
|
||||
(cl-letf (((symbol-function 'treemacs-workspace->is-empty?)
|
||||
(symbol-function 'ignore)))
|
||||
(treemacs--init))
|
||||
;;
|
||||
(dolist (project (treemacs-workspace->projects (treemacs-current-workspace)))
|
||||
(treemacs-do-remove-project-from-workspace project))
|
||||
;;
|
||||
(+treemacs--init)
|
||||
(with-current-buffer origin-buffer
|
||||
(treemacs-do-add-project-to-workspace
|
||||
(treemacs--canonical-path (doom-project-root 'nocache))
|
||||
(doom-project-name 'nocache)))
|
||||
;;
|
||||
(setq treemacs--ready-to-follow t)
|
||||
(when (or treemacs-follow-after-init treemacs-follow-mode)
|
||||
(with-current-buffer origin-buffer
|
||||
(treemacs--follow)))))
|
||||
(treemacs-find-file arg))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue