Working with dired
Posted on Sat 07 April 2018 in geek
I've been making a lot more use of dired recently. One use case is copying files from my remote server to my home machine. Doing this directly from dired, even with the power of tramp, is a little too time consuming and potentially locks up your session for large files. While browsing reddit r/emacs I found a reference to this post <https://vxlabs.com/2018/03/30/asynchronous-rsync-with-emacs-dired-and-tramp/> that spurred me to look at spawning rsync from dired some more.
:: r/emacs: http://reddit.com/r/emacs
Unfortunately the solution is currently sitting in a pull-request to what looks like an orphaned package. I also ran into some other problems with the handling of where rsync needs to be run from so rather than unpicking some unfamiliar code I decided to re-implement everything in my own package <https://github.com/stsquad/dired-rsync>.
I've still got some debugging to do to get it to cleanly handle multiple sessions as well as a more detailed mode-line status. Once I'm happy I'll tag a 0.1 and get it submitted to MELPA.
While getting more familiar with dired I also came up with this little helper:
(defun my-dired-frame (directory) "Open up a dired frame which closes on exit." (interactive) (switch-to-buffer (dired directory)) (local-set-key (kbd "C-x C-c") (lambda () (interactive) (kill-this-buffer) (save-buffers-kill-terminal 't))))
Which is paired with a simple alias in my shell setup:
alias dired="emacsclient -a '' -t -e '(my-dired-frame default-directory)'"
This works really nicely for popping up a dired frame in your terminal window and cleaning itself up when you exit.