doomemacs/modules/ui/treemacs/autoload.el
Henrik Lissner 53fe7a1f04 Refactor Project API to reflect changes upstream
projectile-project-root no longer returns `default-directory` if not in
a project (it returns nil). As such, doom-project-* functions (and their
uses) have been refactored.

+ doom-project-p & doom-project-root are aliases for
  projectile-project-p & projectile-project-root.
+ doom-project-{p,root,name,expand} now has a DIR argument (for
  consistency, since projectile-project-name and
  projectile-project-expand do not).
+ The nocache parameter is no longer necessary, as projectile's caching
  behavior is now more sane.
+ Removed some projectile advice/hacks that are no longer necessary.
+ Updated unit tests
2018-09-28 21:13:27 -04:00

40 lines
1.3 KiB
EmacsLisp

;;; 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))
(doom-project-name))
(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.
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)))
(+treemacs--init)
(with-current-buffer origin-buffer
(treemacs-find-file arg))))