punassuming / ranger.el

Bringing the goodness of ranger to dired!
699 stars 52 forks source link

do not open files with the right arrow #153

Open jmburgos opened 7 years ago

jmburgos commented 7 years ago

Hi ralesi,

I like ranger.el a lot. But there is something that is a bit annoying when using it: when you are on a file and press the right key, ranger opens that file and closes itself. It happens to me frequently that I am navigating deeply into a folder structure (using mostly the arrow keys), I accidentally press the right key, open a file I am not interested in, and I loose my "place" in the folder structure. I understand that the fact that ranger closes itself after opening a file is by design, but it would be possible for the right key not to open the selected file? Many thanks,

Julian

alphapapa commented 7 years ago

Can you just unbind the key?

jmburgos commented 7 years ago

No. The right key is bound to the ranger-find-file function, which opens the file and exists ranger if the target is a file, or opens the directory in ranger if the target is a directory ("Enter" is also bound to this function). On the other hand, the left key is bound to the "ranger-up-directory" function, which goes up one level in the directory regardless if the target file is a file or a directory. I guess what I would like is to have a new function, "ranger-down-directory" which would only open the next directory if the target is a directory, and would do nothing if the target is a file. Then I would bound right to that function, and use Enter to open the file if I want to. I will try to code this, but my elisp habilities are minimal.

jmburgos commented 7 years ago

Wow... actually was very easy. I just copied the ranger-find-file function and removed the second part after the if statement, so nothing happens if the target is a file. I renamed this as ranger-down-directory, and bound the right key to it.

alphapapa commented 7 years ago

Great! Now maybe you submit as PR? =)

punassuming commented 7 years ago

So you would like this as an option? Currently this behaviour is consistent with rangerfm, correct? Also are you concerned about the right key in addition to "l"?

jmburgos commented 7 years ago

It would be nice to have this as an option (I mean separating the "folder navigation" and "file opening" functionality), both in relation with the "l" and right arrow keys. Maybe the option would be to use these keys only for folder navigation, and use "Enter" for file opening?