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

Remove . and .. entires in helm-find-files #1863

Closed
syl20bnr opened this issue Jun 5, 2015 · 13 comments
Closed

Remove . and .. entires in helm-find-files #1863

syl20bnr opened this issue Jun 5, 2015 · 13 comments

Comments

@syl20bnr
Copy link
Owner

syl20bnr commented Jun 5, 2015

Or put them at the end.
It prevents quick navigation in a tree where there are some directories with only one sub-directory.

@nashamri
Copy link
Contributor

nashamri commented Jun 5, 2015

👍 to that!

@TheBB
Copy link
Collaborator

TheBB commented Jun 17, 2015

Apparently it's not recommended, and in fact explicitly worked around in Helm, although the maintainer seems unable to explain why, precisely. emacs-helm/helm#924

Can we advice helm-ff-sort-candidates? I played with it a bit, but must be doing something wrong.

@syl20bnr
Copy link
Owner Author

I agree, if these entries are mandatory then at least we can try put them out of the way for quicker navigation.

Other possibility instead of sorting could be to automatically select the 3rd entry. I think this is the behavior of dired, I cannot check for now.

@syl20bnr
Copy link
Owner Author

Oh I agreed with myself it seems :-D

@Peaker
Copy link

Peaker commented Jul 14, 2015

I hacked helm files to allow ignoring /. /.. after all and now find-files is sooo much nicer! :-)

@zilongshanren
Copy link
Contributor

cool @Peaker could you send a PR?

@TheBB
Copy link
Collaborator

TheBB commented Jul 15, 2015

Yes, please share how you did it.

@Peaker
Copy link

Peaker commented Jul 15, 2015

I can't make a PR because I did it as a complete hack:

Peaker/helm@1b55412

  • adding "/.$" "/..$" to helm-boring-file-regexp-list in my custom.el

@TheBB
Copy link
Collaborator

TheBB commented Jul 19, 2015

Thanks @Peaker, even if you can't make a PR doesn't mean it's not helpful. It's actually possible to do with function advice without hacking Helm (or rather, the Helm source). I made a layer for it.

If desired I can put together a PR for Spacemacs. I didn't because I'm not sure how serious emacs-helm/helm#924 is, even though I haven't come across that problem myself yet.

@StreakyCobra
Copy link
Contributor

As nobody asked for this functionality last 4 months, upstream are not going to do anything on this, and the only existing solution is too hacky, it's a wontfix. People really wanting this can try @TheBB solution. I'm closing this issue then.

@CeleritasCelery
Copy link
Contributor

@TheBB your link for the layer that addresses this is broken. Could you provide an updated one? I would love to address this issue.

@nixmaniack
Copy link
Contributor

@CeleritasCelery
Copy link
Contributor

CeleritasCelery commented Nov 16, 2017

I have been messing around with this and made a solution that keeps the current directory hardlink at the bottom and removes the parent directory hardlink. Based on @TheBB's solution.

(defun cel/helm-ff-not-hardlink-p (file)
  (not (s-ends-with? ".." file)))

(defun cel/helm-ff-up-one-level (fcn &rest args)
  (flet ((helm-file-completion-source-p (&rest _) t))
    (apply fcn args)))

(defun cel/helm-ff-dots-at-bottom (ret-val)
  (if (listp ret-val)
      (-rotate (- (--count (s-ends-with? "." it) (-take 2 ret-val)))
               ret-val)
    ret-val))

(with-eval-after-load 'helm-files
  (advice-add 'helm-ff-filter-candidate-one-by-one
              :before-while 'cel/helm-ff-not-hardlink-p)
  (advice-add 'helm-find-files-up-one-level
              :around 'cel/helm-ff-up-one-level)
  (advice-add 'helm-find-files-get-candidates
              :filter-return 'cel/helm-ff-dots-at-bottom))

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

8 participants