Mercurial > emacs
comparison lisp/shadowfile.el @ 85973:d3e87ee5aa0e
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-923
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 09 Nov 2007 09:45:30 +0000 |
parents | 04fb80d58b60 15ad52029dc2 |
children | 107ccd98fa12 880960b70474 |
comparison
equal
deleted
inserted
replaced
85972:51aa47312c4b | 85973:d3e87ee5aa0e |
---|---|
101 :type 'boolean | 101 :type 'boolean |
102 :group 'shadow) | 102 :group 'shadow) |
103 | 103 |
104 (defcustom shadow-inhibit-overload nil | 104 (defcustom shadow-inhibit-overload nil |
105 "If non-nil, shadowfile won't redefine \\[save-buffers-kill-emacs]. | 105 "If non-nil, shadowfile won't redefine \\[save-buffers-kill-emacs]. |
106 Normally it overloads the function `save-buffers-kill-emacs' to check | 106 Normally it overloads the function `save-buffers-kill-emacs' to check for |
107 for files have been changed and need to be copied to other systems." | 107 files that have been changed and need to be copied to other systems." |
108 :type 'boolean | 108 :type 'boolean |
109 :group 'shadow) | 109 :group 'shadow) |
110 | 110 |
111 (defcustom shadow-info-file nil | 111 (defcustom shadow-info-file nil |
112 "File to keep shadow information in. | 112 "File to keep shadow information in. |
297 ;;; Filename manipulation | 297 ;;; Filename manipulation |
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
299 | 299 |
300 (defun shadow-parse-fullname (fullname) | 300 (defun shadow-parse-fullname (fullname) |
301 "Parse FULLNAME into \(site user path) list. | 301 "Parse FULLNAME into \(site user path) list. |
302 Leave it alone if it already is one. Returns nil if the argument is | 302 Leave it alone if it already is one. Return nil if the argument is |
303 not a full ange-ftp pathname." | 303 not a full ange-ftp pathname." |
304 (if (listp fullname) | 304 (if (listp fullname) |
305 fullname | 305 fullname |
306 (ange-ftp-ftp-name fullname))) | 306 (ange-ftp-ftp-name fullname))) |
307 | 307 |
390 | 390 |
391 (defun shadow-file-match (pattern file &optional regexp) | 391 (defun shadow-file-match (pattern file &optional regexp) |
392 "Return t if PATTERN matches FILE. | 392 "Return t if PATTERN matches FILE. |
393 If REGEXP is supplied and non-nil, the file part of the pattern is a regular | 393 If REGEXP is supplied and non-nil, the file part of the pattern is a regular |
394 expression, otherwise it must match exactly. The sites and usernames must | 394 expression, otherwise it must match exactly. The sites and usernames must |
395 match---see `shadow-same-site'. The pattern must be in full ange-ftp format, but | 395 match---see `shadow-same-site'. The pattern must be in full ange-ftp format, |
396 the file can be any valid filename. This function does not do any filename | 396 but the file can be any valid filename. This function does not do any |
397 expansion or contraction, you must do that yourself first." | 397 filename expansion or contraction, you must do that yourself first." |
398 (let* ((pattern-sup (shadow-parse-fullname pattern)) | 398 (let* ((pattern-sup (shadow-parse-fullname pattern)) |
399 (file-sup (shadow-parse-name file))) | 399 (file-sup (shadow-parse-name file))) |
400 (and (shadow-same-site pattern-sup file-sup) | 400 (and (shadow-same-site pattern-sup file-sup) |
401 (if regexp | 401 (if regexp |
402 (string-match (nth 2 pattern-sup) (nth 2 file-sup)) | 402 (string-match (nth 2 pattern-sup) (nth 2 file-sup)) |
410 (defun shadow-define-cluster (name) | 410 (defun shadow-define-cluster (name) |
411 "Edit \(or create) the definition of a cluster NAME. | 411 "Edit \(or create) the definition of a cluster NAME. |
412 This is a group of hosts that share directories, so that copying to or from | 412 This is a group of hosts that share directories, so that copying to or from |
413 one of them is sufficient to update the file on all of them. Clusters are | 413 one of them is sufficient to update the file on all of them. Clusters are |
414 defined by a name, the network address of a primary host \(the one we copy | 414 defined by a name, the network address of a primary host \(the one we copy |
415 files to), and a regular expression that matches the hostnames of all the sites | 415 files to), and a regular expression that matches the hostnames of all the |
416 in the cluster." | 416 sites in the cluster." |
417 (interactive (list (completing-read "Cluster name: " shadow-clusters () ()))) | 417 (interactive (list (completing-read "Cluster name: " shadow-clusters () ()))) |
418 (let* ((old (shadow-get-cluster name)) | 418 (let* ((old (shadow-get-cluster name)) |
419 (primary (read-string "Primary host: " | 419 (primary (read-string "Primary host: " |
420 (if old (shadow-cluster-primary old) | 420 (if old (shadow-cluster-primary old) |
421 name))) | 421 name))) |
467 ;;;###autoload | 467 ;;;###autoload |
468 (defun shadow-define-regexp-group () | 468 (defun shadow-define-regexp-group () |
469 "Make each of a group of files be shared between hosts. | 469 "Make each of a group of files be shared between hosts. |
470 Prompts for regular expression; files matching this are shared between a list | 470 Prompts for regular expression; files matching this are shared between a list |
471 of sites, which are also prompted for. The filenames must be identical on all | 471 of sites, which are also prompted for. The filenames must be identical on all |
472 hosts \(if they aren't, use `shadow-define-literal-group' instead of this function). | 472 hosts \(if they aren't, use `shadow-define-literal-group' instead of this |
473 Each site can be either a hostname or the name of a cluster \(see | 473 function). Each site can be either a hostname or the name of a cluster \(see |
474 `shadow-define-cluster')." | 474 `shadow-define-cluster')." |
475 (interactive) | 475 (interactive) |
476 (let ((regexp (read-string | 476 (let ((regexp (read-string |
477 "Filename regexp: " | 477 "Filename regexp: " |
478 (if (buffer-file-name) | 478 (if (buffer-file-name) |
637 (shadow-write-todo-file))) | 637 (shadow-write-todo-file))) |
638 nil) ; Return nil for write-file-functions | 638 nil) ; Return nil for write-file-functions |
639 | 639 |
640 (defun shadow-remove-from-todo (pair) | 640 (defun shadow-remove-from-todo (pair) |
641 "Remove PAIR from `shadow-files-to-copy'. | 641 "Remove PAIR from `shadow-files-to-copy'. |
642 PAIR must be (eq to) one of the elements of that list." | 642 PAIR must be `eq' to one of the elements of that list." |
643 (setq shadow-files-to-copy | 643 (setq shadow-files-to-copy |
644 (shadow-remove-if (function (lambda (s) (eq s pair))) | 644 (shadow-remove-if (function (lambda (s) (eq s pair))) |
645 shadow-files-to-copy))) | 645 shadow-files-to-copy))) |
646 | 646 |
647 (defun shadow-read-files () | 647 (defun shadow-read-files () |
648 "Visit and load `shadow-info-file' and `shadow-todo-file'. | 648 "Visit and load `shadow-info-file' and `shadow-todo-file'. |
649 Thus restores shadowfile's state from your last Emacs session. | 649 Thus restores shadowfile's state from your last Emacs session. |
650 Returns t unless files were locked; then returns nil." | 650 Return t unless files were locked; then return nil." |
651 (interactive) | 651 (interactive) |
652 (if (and (fboundp 'file-locked-p) | 652 (if (and (fboundp 'file-locked-p) |
653 (or (stringp (file-locked-p shadow-info-file)) | 653 (or (stringp (file-locked-p shadow-info-file)) |
654 (stringp (file-locked-p shadow-todo-file)))) | 654 (stringp (file-locked-p shadow-todo-file)))) |
655 (progn | 655 (progn |
721 | 721 |
722 (defun shadow-invalidate-hashtable () | 722 (defun shadow-invalidate-hashtable () |
723 (setq shadow-hashtable (make-vector 37 0))) | 723 (setq shadow-hashtable (make-vector 37 0))) |
724 | 724 |
725 (defun shadow-insert-var (variable) | 725 (defun shadow-insert-var (variable) |
726 "Prettily insert a `setq' command for VARIABLE, | 726 "Build a `setq' to restore VARIABLE. |
727 which, when later evaluated, will restore it to its current setting. | 727 Prettily insert a `setq' command which, when later evaluated, |
728 will restore VARIABLE to its current setting. | |
728 VARIABLE must be the name of a variable whose value is a list." | 729 VARIABLE must be the name of a variable whose value is a list." |
729 (let ((standard-output (current-buffer))) | 730 (let ((standard-output (current-buffer))) |
730 (insert (format "(setq %s" variable)) | 731 (insert (format "(setq %s" variable)) |
731 (cond ((consp (eval variable)) | 732 (cond ((consp (eval variable)) |
732 (insert "\n '(") | 733 (insert "\n '(") |