How to preview source file from treemacs in a project?

I’m using Doom Emacs with treemacs inside it.

When I look through each source file from side tree, I need to press Enter to open the file. How to view the file content without Enter but just move the cursor in the tree menu?

I think you have to bind those keys manually

(map! :map treemacs-mode-map
      "<down>" (lambda (&optional arg) (interactive)
                 (next-line arg)
                 (save-selected-window
                   (treemacs-RET-action)))
      "<up>" (lambda (&optional arg) (interactive)
               (previous-line arg)
               (save-selected-window
                 (treemacs-RET-action))))

Thank you. Where should I put this setting to? I put it into .doom.d/config.el but got this error when start Emacs:

Warning (initialization): An error occurred while loading ‘/Users/abc/.emacs.d/core/core-start.el’:

Error in private config: config.el, (end-of-file /Users/abc/.doom.d/config.el)

Were you sure to write the snippet without any missing parentheses? You can check your file.el for potentially missing ones with M-x check-parens.

I tried to delete all the spaces and reset the format again. It doesn’t work.

But press P in treemacs works.

Can you post that config.el here?

(setq doom-theme 'doom-one)

(setq display-line-numbers-type t)

(setq org-directory "~/org/")

(map! :map treemacs-mode-map
      "<down>" (lambda (&optional arg) (interactive)
                 (next-line arg)
                 (save-selected-window
                   (treemacs-RET-action)))
      "<up>" (lambda (&optional arg) (interactive)
               (previous-line arg)
               (save-selected-window
                 (treemacs-RET-action))))

Here it is.

I don’t see any error here at all, sorry.

Thank you all the same. At the moment, press P works well for me.

Oh, my fault, I didn’t know about P/treemacs-peek-mode, it’s definitely the better solution.

1 Like