Cleanup my extra key bindings for dired code
This commit is contained in:
parent
95fd1a23ea
commit
f3b9f4a4fa
66
README.org
66
README.org
@ -447,42 +447,44 @@ by experienced Emacs users.
|
||||
#+name: lst:extra-dired-key-bindings
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'dired
|
||||
(define-key
|
||||
dired-mode-map (kbd "E")
|
||||
(defun my-dired-eww-find-file ()
|
||||
"Visit dired file with eww."
|
||||
(interactive)
|
||||
(eww-open-file (dired-get-file-for-visit))))
|
||||
(defun dired-eww-open-file ()
|
||||
"In Dired, open the regular file named on this line with eww"
|
||||
(interactive)
|
||||
(let ((file (dired-get-file-for-visit)))
|
||||
(if (file-regular-p file)
|
||||
(eww-open-file file)
|
||||
(error "Eww rejects `%s', since it is not a regular file" file))))
|
||||
|
||||
;; https://truongtx.me/tmtxt-dired-async.html
|
||||
(define-key
|
||||
dired-mode-map (kbd "Y")
|
||||
(defun my-dired-rsync (target)
|
||||
"Copy marked files with `rsync' to TARGET directory."
|
||||
(interactive
|
||||
(list (expand-file-name
|
||||
(read-file-name "Rsync to:" (dired-dwim-target-directory)))))
|
||||
;; Store all marked files into the `files' list and intialize
|
||||
;; the `rsync-command'.
|
||||
(let ((files (dired-get-marked-files nil current-prefix-arg))
|
||||
(rsync-command "rsync -av --progress "))
|
||||
;; Add all marked files as arguments to the `rsync-command'.
|
||||
(dolist (file files)
|
||||
(setq rsync-command
|
||||
(concat rsync-command
|
||||
(if (string-match "^/ssh:\\(.*\\)$" file)
|
||||
(format " -e ssh %s" (match-string 1 file))
|
||||
(shell-quote-argument file)) " ")))
|
||||
;; Append the destination directory to the `rsync-command'.
|
||||
(defun dired-rsync (target)
|
||||
"Copy marked files with `rsync' to TARGET directory."
|
||||
(interactive
|
||||
(list (expand-file-name
|
||||
(read-file-name "Rsync to:" (dired-dwim-target-directory)))))
|
||||
;; Store all marked files into the `files' list and intialize
|
||||
;; the `rsync-command'.
|
||||
(let ((files (dired-get-marked-files nil current-prefix-arg))
|
||||
(rsync-command "rsync -av --progress "))
|
||||
;; Add all marked files as arguments to the `rsync-command'.
|
||||
(dolist (file files)
|
||||
(setq rsync-command
|
||||
(concat rsync-command
|
||||
(if (string-match "^/ssh:\\(.*\\)$" target)
|
||||
(format " -e ssh %s" (match-string 1 target))
|
||||
(shell-quote-argument target))))
|
||||
;; Run the async shell command.
|
||||
(async-shell-command rsync-command)
|
||||
;; Finally, switch to that window.
|
||||
(other-window 1)))))
|
||||
(if (string-match "^/ssh:\\(.*\\)$" file)
|
||||
(format " -e ssh %s" (match-string 1 file))
|
||||
(shell-quote-argument file)) " ")))
|
||||
;; Append the destination directory to the `rsync-command'.
|
||||
(setq rsync-command
|
||||
(concat rsync-command
|
||||
(if (string-match "^/ssh:\\(.*\\)$" target)
|
||||
(format " -e ssh %s" (match-string 1 target))
|
||||
(shell-quote-argument target))))
|
||||
;; Run the async shell command.
|
||||
(async-shell-command rsync-command)
|
||||
;; Finally, switch to that window.
|
||||
(other-window 1)))
|
||||
|
||||
(define-key dired-mode-map (kbd "E") #'dired-eww-open-file)
|
||||
(define-key dired-mode-map (kbd "Y") #'dired-rsync))
|
||||
#+end_src
|
||||
|
||||
** [[info:elisp#Processes][Processes (info)]]
|
||||
|
Loading…
Reference in New Issue
Block a user