Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neo-enter-hook on moving #312

Open
Nondv opened this issue Dec 7, 2018 · 2 comments
Open

neo-enter-hook on moving #312

Nondv opened this issue Dec 7, 2018 · 2 comments

Comments

@Nondv
Copy link

Nondv commented Dec 7, 2018

Hello,

From #77 I found out about neo-enter-hook and used it like this:

(defun neotree-hide-if-file (type & rest) (if (equal type 'file) (neotree-hide)))
(add-hook 'neo-enter-hook 'neotree-hide-if-file)

Though it is being triggered even by moving in neotree buffer via n or p.

Arguments are the same as when using RET:

Debugger entered--entering a function:
* neotree-hide-if-file(file "/Users/nondv/my-configs/.emacs" nil)

Is this expected behavior?

@Nondv
Copy link
Author

Nondv commented Dec 7, 2018

This is what I found in the package

(defun neo-buffer--execute (arg &optional file-fn dir-fn)
  "Define the behaviors for keyboard event.
ARG is the parameter for command.
If FILE-FN is non-nil, it will executed when a file node.
If DIR-FN is non-nil, it will executed when a dir node."
  (interactive "P")
  (let* ((btn-full-path (neo-buffer--get-filename-current-line))
         is-file-p
         enter-fn)
    (unless (null btn-full-path)
      (setq is-file-p (not (file-directory-p btn-full-path))
            enter-fn (if is-file-p file-fn dir-fn))
      (unless (null enter-fn)
        (funcall enter-fn btn-full-path arg)
        (run-hook-with-args
         'neo-enter-hook
         (if is-file-p 'file 'directory)
         btn-full-path
         arg)))
    btn-full-path))

I guess the described behavior is expected but confusing. Is there a hook for opening files?

@Abdisalan
Copy link
Collaborator

Yea looks like the behavior is expected. I think the intention with this one is if you click on a file with your mouse then it'll auto hide neotree.

You do bring up a good point that neotree could use a hook for opening files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants