Skip to content

Commit

Permalink
[Interface] Create command to start treemacs on boot.
Browse files Browse the repository at this point in the history
Fixes #1111
  • Loading branch information
Alexander-Miller committed Jul 17, 2024
1 parent 54ef590 commit 6d235c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Deprecated ~treemacs-window-background-color~ in favour of ~treemacs-window-background-face~ and
~treemacs-hl-line-face~
- Added ~treemacs-copy-absolute-path-at-point~
- Added ~treemacs-start-on-boot~
- Made it possible to disable workspace with a ~COMMENT~ directive
- Added option to sort alphabetic-numerically (as with ~string-version-lessp~)
- Added ~:on-expand~ and ~:on-collapse~ options to treelib nodes
Expand Down
2 changes: 2 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ discoverability.
:after (treemacs)
:ensure t
:config (treemacs-set-scope-type 'Tabs))

(treemacs-start-on-boot)
#+END_SRC

* Configuration
Expand Down
14 changes: 14 additions & 0 deletions src/elisp/treemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ visiting a file or Emacs cannot find any tags for the current file."
(setq treemacs-window (selected-window)))
(treemacs--do-follow-tag index treemacs-window buffer-file project))))

;;;###autoload
(defun treemacs-start-on-boot (&optional focus-treemacs)
"Initializer specifically to start treemacs as part of your init file.
Ensures that all visual elements are present which might otherwise be missing
because their setup requires an interactive command or a post-command hook.
FOCUS-TREEMACS indicates whether the treemacs window should be selected."
(-let [initial-window (selected-window)]
(treemacs)
(hl-line-highlight)
(redisplay)
(unless focus-treemacs (select-window initial-window))))

;;;###autoload
(defun treemacs-select-window (&optional arg)
"Select the treemacs window if it is visible.
Expand Down

0 comments on commit 6d235c9

Please sign in to comment.