Closed xieyuheng closed 8 years ago
here is the way I use it :
I add the following function to 'ranger.el'
(defun ranger-open ()
(interactive)
(let ((find-name (dired-get-file-for-visit)))
(cond ((file-directory-p find-name)
(message "can not open a directory, type <right> to enter the directory"))
(:else
(eshell-command (concatenate 'string
"rifle "
"'" find-name "'"))))))
and in
(defun ranger-define-maps () ...)
I do
(ranger-map (kbd "RET") 'ranger-open)
I will do a PR if you agree to not use 'ranger-key' anymore :)
I have a change coming in to use the default shell handler to open files, we can include rifle, but this will be shell specific and will not work in windows.
eshell can also be used under windows
yes I can not re-bind C-p by the following code ::
(add-to-list 'load-path "~/.emacs.d/ranger-git/")
(require 'ranger)
(setq ranger-cleanup-on-disable nil)
(setq ranger-cleanup-eagerly nil)
(setq ranger-parent-depth 2)
(setq ranger-show-literal t)
(setq ranger-ignored-extensions '("mkv" "iso" "mp4" "pdf" "djvu"))
(setq ranger-max-preview-size 1) ;; 1 MB
(add-hook 'ranger-mode-hook
(lambda ()
(local-set-key (kbd "C-t") 'isearch-forward)
(local-set-key (kbd "C-r") 'isearch-backward)
(local-set-key (kbd "<down>") 'ranger-next-file)
(local-set-key (kbd "<up>") 'ranger-prev-file)
(local-set-key (kbd "<left>") 'ranger-up-directory)
(local-set-key (kbd "<right>") 'ranger-find-file)
;; (local-set-key (kbd "<return>") 'ranger-open)
(local-set-key (kbd "C-n") 'ranger-next-file)
(local-set-key (kbd "C-p") 'ranger-prev-file)
))
;; (defun ranger-open ()
;; (interactive)
;; (let ((find-name (dired-get-file-for-visit)))
;; (cond ((file-directory-p find-name)
;; (message "can not open a directory, type <right> to enter the directory"))
;; (:else
;; (eshell-command (concatenate 'string
;; "rifle "
;; "'" find-name "'"))))))
I have to edit the source to delete the code about 'ranger-key' to re-bind C-p
I also added the function 'ranger-open' to the source and bind it to RET
I think it is that in emacs, key binding should not be handled by custom group.
when you do so, something wrong happens (at least in my emacs)
All you should need to do is setq ranger-key nil
before requiring ranger. I will go ahead though and work on keybindings using emacs style keys as an option though.
You are correct that eshell can work everywhere, but from what I can remember rifle is a python script that is part of ranger, so it will need to have an optional check.
Also what benefits do we have by using rifle as a file handler rather than the native OS?
I forgot that rifle is not avrilable on windows :P
do not use rifle, and implement a file handler in emacs, will be cool. now I think there is not good to depend on rifle.
before you implement this feature, I will use my little function for a while :)
FYI @xieyuheng, external app command added as we
.
here is a way to use rifle to open file by the help of eshell