]> code.delx.au - gnu-emacs/blobdiff - lisp/shadowfile.el
Merge changes from emacs-23 branch
[gnu-emacs] / lisp / shadowfile.el
index ca06ace22146dc9f8dc2095cb56469c5071219fe..c88b55e964bc501cab60556b68928b4a6c1dc99e 100644 (file)
@@ -1,17 +1,16 @@
 ;;; shadowfile.el --- automatic file copying
 
-;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2011 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <boris@gnu.org>
 ;; Keywords: comm files
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +18,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
   :group 'files)
 
 (defcustom shadow-noquery nil
-  "*If t, always copy shadow files without asking.
+  "If t, always copy shadow files without asking.
 If nil \(the default), always ask.  If not nil and not t, ask only if there
 is no buffer currently visiting the file."
   :type '(choice (const t) (const nil) (other :tag "Ask if no buffer" maybe))
   :group 'shadow)
 
 (defcustom shadow-inhibit-message nil
-  "*If non-nil, do not display a message when a file needs copying."
+  "If non-nil, do not display a message when a file needs copying."
   :type 'boolean
   :group 'shadow)
 
 (defcustom shadow-inhibit-overload nil
   "If non-nil, shadowfile won't redefine \\[save-buffers-kill-emacs].
-Normally it overloads the function `save-buffers-kill-emacs' to check
-for files have been changed and need to be copied to other systems."
+Normally it overloads the function `save-buffers-kill-emacs' to check for
+files that have been changed and need to be copied to other systems."
   :type 'boolean
   :group 'shadow)
 
@@ -299,7 +296,7 @@ be matched against the primary of SITE2."
 
 (defun shadow-parse-fullname (fullname)
   "Parse FULLNAME into \(site user path) list.
-Leave it alone if it already is one.  Returns nil if the argument is
+Leave it alone if it already is one.  Return nil if the argument is
 not a full ange-ftp pathname."
   (if (listp fullname)
       fullname
@@ -392,9 +389,9 @@ local filename."
  "Return t if PATTERN matches FILE.
 If REGEXP is supplied and non-nil, the file part of the pattern is a regular
 expression, otherwise it must match exactly.  The sites and usernames must
-match---see `shadow-same-site'.  The pattern must be in full ange-ftp format, but
-the file can be any valid filename.  This function does not do any filename
-expansion or contraction, you must do that yourself first."
+match---see `shadow-same-site'.  The pattern must be in full ange-ftp format,
+but the file can be any valid filename.  This function does not do any
+filename expansion or contraction, you must do that yourself first."
  (let* ((pattern-sup (shadow-parse-fullname pattern))
        (file-sup (shadow-parse-name file)))
    (and (shadow-same-site pattern-sup file-sup)
@@ -412,8 +409,8 @@ expansion or contraction, you must do that yourself first."
 This is a group of hosts that share directories, so that copying to or from
 one of them is sufficient to update the file on all of them.  Clusters are
 defined by a name, the network address of a primary host \(the one we copy
-files to), and a regular expression that matches the hostnames of all the sites
-in the cluster."
+files to), and a regular expression that matches the hostnames of all the
+sites in the cluster."
   (interactive (list (completing-read "Cluster name: " shadow-clusters () ())))
   (let* ((old (shadow-get-cluster name))
         (primary (read-string "Primary host: "
@@ -469,8 +466,8 @@ specific hostnames, or names of clusters \(see `shadow-define-cluster')."
   "Make each of a group of files be shared between hosts.
 Prompts for regular expression; files matching this are shared between a list
 of sites, which are also prompted for.  The filenames must be identical on all
-hosts \(if they aren't, use `shadow-define-literal-group' instead of this function).
-Each site can be either a hostname or the name of a cluster \(see
+hosts \(if they aren't, use `shadow-define-literal-group' instead of this
+function).  Each site can be either a hostname or the name of a cluster \(see
 `shadow-define-cluster')."
   (interactive)
   (let ((regexp (read-string
@@ -512,7 +509,7 @@ Pending copies are stored in variable `shadow-files-to-copy', and in
 call it manually."
   (interactive "P")
   (if (not shadow-files-to-copy)
-      (if (interactive-p)
+      (if (called-interactively-p 'interactive)
          (message "No files need to be shadowed."))
     (save-excursion
       (map-y-or-n-p (function
@@ -575,13 +572,11 @@ site."
         (to (shadow-expand-cluster-in-file-name (cdr s))))
     (when buffer
       (set-buffer buffer)
-      (save-restriction
-       (widen)
-       (condition-case i
-           (progn
-             (write-region (point-min) (point-max) to)
-             (shadow-remove-from-todo s))
-         (error (message "Shadow %s not updated!" (cdr s))))))))
+      (condition-case i
+         (progn
+            (write-region nil nil to)
+            (shadow-remove-from-todo s))
+        (error (message "Shadow %s not updated!" (cdr s)))))))
 
 (defun shadow-shadows-of (file)
   "Return copy operations needed to update FILE.
@@ -639,7 +634,7 @@ Consider them as regular expressions if third arg REGEXP is true."
 
 (defun shadow-remove-from-todo (pair)
   "Remove PAIR from `shadow-files-to-copy'.
-PAIR must be (eq to) one of the elements of that list."
+PAIR must be `eq' to one of the elements of that list."
   (setq shadow-files-to-copy
        (shadow-remove-if (function (lambda (s) (eq s pair)))
                          shadow-files-to-copy)))
@@ -647,7 +642,7 @@ PAIR must be (eq to) one of the elements of that list."
 (defun shadow-read-files ()
   "Visit and load `shadow-info-file' and `shadow-todo-file'.
 Thus restores shadowfile's state from your last Emacs session.
-Returns t unless files were locked; then returns nil."
+Return t unless files were locked; then return nil."
   (interactive)
   (if (and (fboundp 'file-locked-p)
           (or (stringp (file-locked-p shadow-info-file))
@@ -711,8 +706,7 @@ With non-nil argument also saves the buffer."
 
 (defun shadow-save-todo-file ()
   (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer))
-      (save-excursion
-       (set-buffer shadow-todo-buffer)
+      (with-current-buffer shadow-todo-buffer
        (condition-case nil             ; have to continue even in case of
            (basic-save-buffer)         ; error, otherwise kill-emacs might
          (error                        ; not work!
@@ -723,8 +717,9 @@ With non-nil argument also saves the buffer."
   (setq shadow-hashtable (make-vector 37 0)))
 
 (defun shadow-insert-var (variable)
-  "Prettily insert a `setq' command for VARIABLE,
-which, when later evaluated, will restore it to its current setting.
+  "Build a `setq' to restore VARIABLE.
+Prettily insert a `setq' command which, when later evaluated,
+will restore VARIABLE to its current setting.
 VARIABLE must be the name of a variable whose value is a list."
   (let ((standard-output (current-buffer)))
     (insert (format "(setq %s" variable))
@@ -765,7 +760,7 @@ look for files that have been changed and need to be copied to other systems."
                                (buffer-list))))
           (yes-or-no-p "Modified buffers exist; exit anyway? "))
        (or (not (fboundp 'process-list))
-          ;; process-list is not defined on VMS.
+          ;; process-list is not defined on MSDOS.
           (let ((processes (process-list))
                 active)
             (while processes
@@ -808,10 +803,11 @@ look for files that have been changed and need to be copied to other systems."
            (file-name-as-directory (shadow-expand-file-name "~"))))
   (if (null shadow-info-file)
       (setq shadow-info-file
-           (shadow-expand-file-name "~/.shadows")))
+           (shadow-expand-file-name (convert-standard-filename "~/.shadows"))))
   (if (null shadow-todo-file)
       (setq shadow-todo-file
-           (shadow-expand-file-name "~/.shadow_todo")))
+           (shadow-expand-file-name
+            (convert-standard-filename "~/.shadow_todo"))))
   (if (not (shadow-read-files))
       (progn
        (message "Shadowfile information files not found - aborting")
@@ -835,5 +831,4 @@ look for files that have been changed and need to be copied to other systems."
 
 (provide 'shadowfile)
 
-;;; arch-tag: e2f4cdd7-2bab-4def-9130-9e69b412b79e
 ;;; shadowfile.el ends here