;; -*- Emacs-Lisp -*- ;; ;; Interactively run RSYNC command in background. ;; Copyright (c) 2002-2005, Hiroyuki Ohsaki. ;; All rights reserved. ;; ;; $Id: rsync.el,v 1.11 2024/04/19 13:01:11 ohsaki Exp $ ;; ;; This code is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY. No author or distributor ;; accepts responsibility to anyone for the consequences of using it ;; or for whether it serves any particular purpose or works at all, ;; unless he says so in writing. Refer to the GNU Emacs General Public ;; License for full details. ;; Everyone is granted permission to copy, modify and redistribute ;; this code, but only under the conditions described in the ;; GNU Emacs General Public License. A copy of this license is ;; supposed to have been given to you along with GNU Emacs so you ;; can know your rights and responsibilities. It should be in a ;; file named COPYING. Among other things, the copyright notice ;; and this notice must be preserved on all copies. ;; usage: ;; add the following lines to your ~/.emacs. ;; (autoload 'rsync "rsync" nil t) ;; (global-set-key "\C-cR" 'rsync) ;; (global-set-key "\C-cP" 'insert-rsync-path) (eval-when-compile (require 'thingatpt)) (defvar rsync-default-dst-path "/var/tmp") (defvar rsync-default-src-host "fserv") (defvar rsync-command "rsync -avz --partial --delete") (defun rsync (src-path dst-path) (interactive (list (read-string "Run rsync from: " (directory-file-name (thing-at-point 'filename))) (read-file-name "Run rsync to: " rsync-default-dst-path nil nil ""))) (if (and (not (string= src-path "")) (not (string= dst-path ""))) (shell-command (format "%s %s %s &" rsync-command src-path dst-path)) (error "Invalid source/destination path."))) (defun insert-rsync-path (src-path) (interactive "F") (if (string-match "^.*/home/\\(ohsaki/.+\\)" src-path) (setq src-path (concat "~" (match-string 1 src-path)))) (insert rsync-default-src-host ":" src-path))