annotate lisp/shadowfile.el @ 38436:b174db545cfd

Some fixes to follow coding conventions.
author Pavel Janík <Pavel@Janik.cz>
date Mon, 16 Jul 2001 12:23:00 +0000
parents 8606adf5daf6
children 92d4c0ba3ff9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
1 ;;; shadowfile.el --- automatic file copying
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
3 ;; Copyright (C) 1993, 1994, 2001 Free Software Foundation, Inc.
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
4
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 24294
diff changeset
5 ;; Author: Boris Goldowsky <boris@gnu.org>
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
6 ;; Keywords: comm files
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
7
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
8 ;; This file is part of GNU Emacs.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
13 ;; any later version.
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
14
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
18 ;; GNU General Public License for more details.
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
19
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
23 ;; Boston, MA 02111-1307, USA.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
24
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
25 ;;; Commentary:
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
27 ;; This package helps you to keep identical copies of files in more than one
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
28 ;; place - possibly on different machines. When you save a file, it checks
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
29 ;; whether it is on the list of files with "shadows", and if so, it tries to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
30 ;; copy it when you exit emacs (or use the shadow-copy-files command).
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
32 ;; Installation & Use:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
33
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
34 ;; Add clusters (if necessary) and file groups with shadow-define-cluster,
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
35 ;; shadow-define-literal-group, and shadow-define-regexp-group (see the
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
36 ;; documentation for these functions for information on how and when to use
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
37 ;; them). After doing this once, everything should be automatic.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
39 ;; The lists of clusters and shadows are saved in a file called .shadows,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
40 ;; so that they can be remembered from one emacs session to another, even
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
41 ;; (as much as possible) if the emacs session terminates abnormally. The
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
42 ;; files needing to be copied are stored in .shadow_todo; if a file cannot
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
43 ;; be copied for any reason, it will stay on the list to be tried again
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
44 ;; next time. The .shadows file should itself have shadows on all your
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
45 ;; accounts so that the information in it is consistent everywhere, but
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
46 ;; .shadow_todo is local information and should have no shadows.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
47
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
48 ;; If you do not want to copy a particular file, you can answer "no" and
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
49 ;; be asked again next time you hit C-x 4 s or exit emacs. If you do not
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
50 ;; want to be asked again, use shadow-cancel, and you will not be asked
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
51 ;; until you change the file and save it again. If you do not want to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
52 ;; shadow that file ever again, you can edit it out of the .shadows
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
53 ;; buffer. Anytime you edit the .shadows buffer, you must type M-x
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
54 ;; shadow-read-files to load in the new information, or your changes will
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
55 ;; be overwritten!
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
57 ;; Bugs & Warnings:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
58 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
59 ;; - It is bad to have two emacses both running shadowfile at the same
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
60 ;; time. It tries to detect this condition, but is not always successful.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
61 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
62 ;; - You have to be careful not to edit a file in two locations
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
63 ;; before shadowfile has had a chance to copy it; otherwise
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
64 ;; "updating shadows" will overwrite one of the changed versions.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
65 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
66 ;; - It ought to check modification times of both files to make sure
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
67 ;; it is doing the right thing. This will have to wait until
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
68 ;; file-newer-than-file-p works between machines.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
69 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
70 ;; - It will not make directories for you, it just fails to copy files
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
71 ;; that belong in non-existent directories.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
72 ;;
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 24294
diff changeset
73 ;; Please report any bugs to me (boris@gnu.org). Also let me know
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13337
diff changeset
74 ;; if you have suggestions or would like to be informed of updates.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
76
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;;; Code:
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (require 'ange-ftp)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;;; Variables
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
85 (defgroup shadow nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
86 "Automatic file copying when saving a file."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
87 :prefix "shadow-"
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
88 :link '(emacs-commentary-link "shadowfile")
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
89 :group 'files)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
90
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
91 (defcustom shadow-noquery nil
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
92 "*If t, always copy shadow files without asking.
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
93 If nil \(the default), always ask. If not nil and not t, ask only if there
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
94 is no buffer currently visiting the file."
22598
dcb17af08ae0 (shadow-noquery): Use `other' widget type.
Andreas Schwab <schwab@suse.de>
parents: 21408
diff changeset
95 :type '(choice (const t) (const nil) (other :tag "Ask if no buffer" maybe))
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
96 :group 'shadow)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
98 (defcustom shadow-inhibit-message nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
99 "*If nonnil, do not display a message when a file needs copying."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
100 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
101 :group 'shadow)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
103 (defcustom shadow-inhibit-overload nil
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
104 "If nonnil, shadowfile won't redefine \\[save-buffers-kill-emacs].
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 Normally it overloads the function `save-buffers-kill-emacs' to check
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
106 for files have been changed and need to be copied to other systems."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
107 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
108 :group 'shadow)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
110 (defcustom shadow-info-file nil
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
111 "File to keep shadow information in.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
112 The `shadow-info-file' should be shadowed to all your accounts to
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
113 ensure consistency. Default: ~/.shadows"
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
114 :type '(choice (const nil) file)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
115 :group 'shadow)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
117 (defcustom shadow-todo-file nil
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 "File to store the list of uncopied shadows in.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 This means that if a remote system is down, or for any reason you cannot or
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
120 decide not to copy your shadow files at the end of one Emacs session, it will
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
121 remember and ask you again in your next Emacs session.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 This file must NOT be shadowed to any other system, it is host-specific.
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
123 Default: ~/.shadow_todo"
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
124 :type '(choice (const nil) file)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
125 :group 'shadow)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 18402
diff changeset
126
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;;; The following two variables should in most cases initialize themselves
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;;; correctly. They are provided as variables in case the defaults are wrong
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;;; on your machine \(and for efficiency).
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defvar shadow-system-name (system-name)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 "The complete hostname of this machine.")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (defvar shadow-homedir nil
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "Your home directory on this machine.")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;;; Internal variables whose values are stored in the info and todo files:
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (defvar shadow-clusters nil
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
143 "List of host clusters \(see `shadow-define-cluster').")
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (defvar shadow-literal-groups nil
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 "List of files that are shared between hosts.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 This list contains shadow structures with literal filenames, created by
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 shadow-define-group.")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (defvar shadow-regexp-groups nil
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 "List of file types that are shared between hosts.
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
152 This list contains shadow structures with regexps matching filenames,
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
153 created by `shadow-define-regexp-group'.")
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;;; Other internal variables:
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (defvar shadow-files-to-copy nil) ; List of files that need to
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ; be copied to remote hosts.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (defvar shadow-hashtable nil) ; for speed
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (defvar shadow-info-buffer nil) ; buf visiting shadow-info-file
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (defvar shadow-todo-buffer nil) ; buf visiting shadow-todo-file
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;;; Syntactic sugar; General list and string manipulation
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (defun shadow-union (a b)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
172 "Add members of list A to list B if not equal to items already in B."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (if (null a)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 b
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (if (member (car a) b)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (shadow-union (cdr a) b)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (shadow-union (cdr a) (cons (car a) b)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (defun shadow-find (func list)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
180 "If FUNC applied to some element of LIST is nonnil, return first such element."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (while (and list (not (funcall func (car list))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (setq list (cdr list)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (car list))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (defun shadow-remove-if (func list)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 "Remove elements satisfying FUNC from LIST.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 Nondestructive; actually returns a copy of the list with the elements removed."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (if list
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (if (funcall func (car list))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (shadow-remove-if func (cdr list))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (cons (car list) (shadow-remove-if func (cdr list))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 nil))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (defun shadow-join (strings sep)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 "Concatenate elements of the list of STRINGS with SEP between each."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (cond ((null strings) "")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ((null (cdr strings)) (car strings))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ((concat (car strings) " " (shadow-join (cdr strings) sep)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (defun shadow-regexp-superquote (string)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
201 "Like `regexp-quote', but includes the ^ and $.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
202 This makes sure regexp matches nothing but STRING."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (concat "^" (regexp-quote string) "$"))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defun shadow-suffix (prefix string)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 "If PREFIX begins STRING, return the rest.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 Return value is nonnil if PREFIX and STRING are string= up to the length of
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 PREFIX."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (let ((lp (length prefix))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (ls (length string)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (if (and (>= ls lp)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (string= prefix (substring string 0 lp)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (substring string lp))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 ;;; Clusters and sites
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;;; I use the term `site' to refer to a string which may be the name of a
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;;; cluster or a literal hostname. All user-level commands should accept
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 ;;; either.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (defun shadow-make-cluster (name primary regexp)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
224 "Create a shadow cluster.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
225 It is called NAME, uses the PRIMARY hostname and REGEXP matching all
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
226 hosts in the cluster. The variable `shadow-clusters' associates the
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
227 names of clusters to these structures. This function is for program
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
228 use: to create clusters interactively, use `shadow-define-cluster'
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
229 instead."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (list name primary regexp))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (defmacro shadow-cluster-name (cluster)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 "Return the name of the CLUSTER."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (list 'elt cluster 0))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (defmacro shadow-cluster-primary (cluster)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 "Return the primary hostname of a CLUSTER."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (list 'elt cluster 1))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (defmacro shadow-cluster-regexp (cluster)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 "Return the regexp matching hosts in a CLUSTER."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (list 'elt cluster 2))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (defun shadow-set-cluster (name primary regexp)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
245 "Put cluster NAME on the list of clusters.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
246 Replace old definition, if any. PRIMARY and REGEXP are the
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 information defining the cluster. For interactive use, call
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
248 `shadow-define-cluster' instead."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (let ((rest (shadow-remove-if
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (function (lambda (x) (equal name (car x))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 shadow-clusters)))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
252 (setq shadow-clusters
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (cons (shadow-make-cluster name primary regexp)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 rest))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (defmacro shadow-get-cluster (name)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 "Return cluster named NAME, or nil."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (list 'assoc name 'shadow-clusters))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (defun shadow-site-primary (site)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 "If SITE is a cluster, return primary host, otherwise return SITE."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (let ((c (shadow-get-cluster site)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (if c
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (shadow-cluster-primary c)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 site)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 ;;; SITES
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (defun shadow-site-cluster (site)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
270 "Given a SITE \(hostname or cluster name), return cluster it is in, or nil."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (or (assoc site shadow-clusters)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (shadow-find
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (function (lambda (x)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (string-match (shadow-cluster-regexp x)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 site)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 shadow-clusters)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (defun shadow-read-site ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 "Read a cluster name or hostname from the minibuffer."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (let ((ans (completing-read "Host or cluster name [RET when done]: "
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 shadow-clusters)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (if (equal "" ans)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 nil
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 ans)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (defun shadow-site-match (site1 site2)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
287 "Nonnil iff SITE1 is or includes SITE2.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 Each may be a host or cluster name; if they are clusters, regexp of site1 will
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 be matched against the primary of site2."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (or (string-equal site1 site2) ; quick check
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (let* ((cluster1 (shadow-get-cluster site1))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (primary2 (shadow-site-primary site2)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (if cluster1
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (string-match (shadow-cluster-regexp cluster1) primary2)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (string-equal site1 primary2)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (defun shadow-get-user (site)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
298 "Return the default username for a SITE."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (ange-ftp-get-user (shadow-site-primary site)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 ;;; Filename manipulation
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (defun shadow-parse-fullpath (fullpath)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
306 "Parse FULLPATH into \(site user path) list.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
307 Leave it alone if it already is one. Returns nil if the argument is
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
308 not a full ange-ftp pathname."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (if (listp fullpath)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 fullpath
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (ange-ftp-ftp-name fullpath)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (defun shadow-parse-path (path)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 "Parse any PATH into \(site user path) list.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 Argument can be a simple path, full ange-ftp path, or already a hup list."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (or (shadow-parse-fullpath path)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (list shadow-system-name
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (user-login-name)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 path)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (defsubst shadow-make-fullpath (host user path)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 "Make an ange-ftp style fullpath out of HOST, USER (optional), and PATH.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 This is probably not as general as it ought to be."
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
324 (concat "/"
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (if user (concat user "@"))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 host ":"
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 path))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (defun shadow-replace-path-component (fullpath newpath)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 "Return FULLPATH with the pathname component changed to NEWPATH."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (let ((hup (shadow-parse-fullpath fullpath)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (shadow-make-fullpath (nth 0 hup) (nth 1 hup) newpath)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (defun shadow-local-file (file)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
335 "If FILE is at this site, remove /user@host part.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
336 If refers to a different system or a different user on this system,
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
337 return nil."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (let ((hup (shadow-parse-fullpath file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (cond ((null hup) file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 ((and (shadow-site-match (nth 0 hup) shadow-system-name)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (string-equal (nth 1 hup) (user-login-name)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (nth 2 hup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (t nil))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (defun shadow-expand-cluster-in-file-name (file)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
346 "If hostname part of FILE is a cluster, expand it to cluster's primary hostname.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
347 Will return the pathname bare if it is a local file."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (let ((hup (shadow-parse-path file))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 cluster)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (cond ((null hup) file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 ((shadow-local-file hup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 ((shadow-make-fullpath (shadow-site-primary (nth 0 hup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (nth 1 hup)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (nth 2 hup))))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (defun shadow-expand-file-name (file &optional default)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 "Expand file name and get file's true name."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (file-truename (expand-file-name file default)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (defun shadow-contract-file-name (file)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
361 "Simplify FILE.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
362 Do so by replacing (when possible) home directory with ~, and hostname
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
363 with cluster name that includes it. Filename should be absolute and
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
364 true."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (let* ((hup (shadow-parse-path file))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (homedir (if (shadow-local-file hup)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 shadow-homedir
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (file-name-as-directory
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
369 (nth 2 (shadow-parse-fullpath
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (expand-file-name
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (shadow-make-fullpath
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (nth 0 hup) (nth 1 hup) "~")))))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (suffix (shadow-suffix homedir (nth 2 hup)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (cluster (shadow-site-cluster (nth 0 hup))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (shadow-make-fullpath
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (if cluster
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (shadow-cluster-name cluster)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (nth 0 hup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (nth 1 hup)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
380 (if suffix
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (concat "~/" suffix)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (nth 2 hup)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (defun shadow-same-site (pattern file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 "True if the site of PATTERN and of FILE are on the same site.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 If usernames are supplied, they must also match exactly. PATTERN and FILE may
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 be lists of host, user, path, or ange-ftp pathnames. FILE may also be just a
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 local filename."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (let ((pattern-sup (shadow-parse-fullpath pattern))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (file-sup (shadow-parse-path file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (and
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (shadow-site-match (nth 0 pattern-sup) (nth 0 file-sup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (or (null (nth 1 pattern-sup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (string-equal (nth 1 pattern-sup) (nth 1 file-sup))))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (defun shadow-file-match (pattern file &optional regexp)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
397 "Return t if PATTERN matches FILE.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 If REGEXP is supplied and nonnil, the pathname part of the pattern is a regular
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 expression, otherwise it must match exactly. The sites and usernames must
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 match---see shadow-same-site. The pattern must be in full ange-ftp format, but
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 the file can be any valid filename. This function does not do any filename
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 expansion or contraction, you must do that yourself first."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (let* ((pattern-sup (shadow-parse-fullpath pattern))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (file-sup (shadow-parse-path file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (and (shadow-same-site pattern-sup file-sup)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
406 (if regexp
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (string-match (nth 2 pattern-sup) (nth 2 file-sup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (string-equal (nth 2 pattern-sup) (nth 2 file-sup))))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;;; User-level Commands
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
414 ;;;###autoload
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (defun shadow-define-cluster (name)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
416 "Edit \(or create) the definition of a cluster NAME.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 This is a group of hosts that share directories, so that copying to or from
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 one of them is sufficient to update the file on all of them. Clusters are
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 defined by a name, the network address of a primary host \(the one we copy
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 files to), and a regular expression that matches the hostnames of all the sites
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 in the cluster."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (interactive (list (completing-read "Cluster name: " shadow-clusters () ())))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (let* ((old (shadow-get-cluster name))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (primary (read-string "Primary host: "
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
425 (if old (shadow-cluster-primary old)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 name)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (regexp (let (try-regexp)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (while (not
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
429 (string-match
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (setq try-regexp
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
431 (read-string
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 "Regexp matching all host names: "
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (if old (shadow-cluster-regexp old)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (shadow-regexp-superquote primary))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 primary))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (message "Regexp doesn't include the primary host!")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (sit-for 2))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 try-regexp))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
439 ; (username (read-no-blanks-input
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
440 ; (format "Username [default: %s]: "
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 ; (shadow-get-user primary))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ; (if old (or (shadow-cluster-username old) "")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ; (user-login-name))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 )
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 ; (if (string-equal "" username) (setq username nil))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (shadow-set-cluster name primary regexp)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
448 ;;;###autoload
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (defun shadow-define-literal-group ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 "Declare a single file to be shared between sites.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 It may have different filenames on each site. When this file is edited, the
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 new version will be copied to each of the other locations. Sites can be
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
453 specific hostnames, or names of clusters \(see `shadow-define-cluster')."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (interactive)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
455 (let* ((hup (shadow-parse-fullpath
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (shadow-contract-file-name (buffer-file-name))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (path (nth 2 hup))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 user site group)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (while (setq site (shadow-read-site))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (setq user (read-string (format "Username [default %s]: "
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (shadow-get-user site)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 path (read-string "Filename: " path))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
463 (setq group (cons (shadow-make-fullpath site
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (if (string-equal "" user)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (shadow-get-user site)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 user)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 path)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 group)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (setq shadow-literal-groups (cons group shadow-literal-groups)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (shadow-write-info-file))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
472 ;;;###autoload
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (defun shadow-define-regexp-group ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 "Make each of a group of files be shared between hosts.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 Prompts for regular expression; files matching this are shared between a list
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
476 of sites, which are also prompted for. The filenames must be identical on all
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 hosts \(if they aren't, use shadow-define-group instead of this function).
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 Each site can be either a hostname or the name of a cluster \(see
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
479 `shadow-define-cluster')."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (interactive)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
481 (let ((regexp (read-string
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
482 "Filename regexp: "
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (if (buffer-file-name)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (shadow-regexp-superquote
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (nth 2
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (shadow-parse-path
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (shadow-contract-file-name
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (buffer-file-name))))))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 site sites usernames)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (while (setq site (shadow-read-site))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (setq sites (cons site sites))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
492 (setq usernames
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (cons (read-string (format "Username for %s: " site)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (shadow-get-user site))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 usernames)))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
496 (setq shadow-regexp-groups
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (cons (shadow-make-group regexp sites usernames)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 shadow-regexp-groups))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (shadow-write-info-file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (defun shadow-shadows ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 ;; Mostly for debugging.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 "Interactive function to display shadows of a buffer."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (interactive)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (let ((msg (shadow-join (mapcar (function cdr)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (shadow-shadows-of (buffer-file-name)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 " ")))
14349
96692e2ba103 (shadow-shadows, shadow-add-to-todo): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
508 (message "%s"
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
509 (if (zerop (length msg))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 "No shadows."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 msg))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (defun shadow-copy-files (&optional arg)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 "Copy all pending shadow files.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 With prefix argument, copy all pending files without query.
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
516 Pending copies are stored in variable `shadow-files-to-copy', and in
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
517 `shadow-todo-file' if necessary. This function is invoked by
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
518 `shadow-save-buffers-kill-emacs', so it is not usually necessary to
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 call it manually."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (interactive "P")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (if (and (not shadow-files-to-copy) (interactive-p))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (message "No files need to be shadowed.")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (save-excursion
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (map-y-or-n-p (function
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (lambda (pair)
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
526 (or arg shadow-noquery
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (format "Copy shadow file %s? " (cdr pair)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (function shadow-copy-file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 shadow-files-to-copy
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 '("shadow" "shadows" "copy"))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (shadow-write-todo-file t))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (defun shadow-cancel ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 "Cancel the instruction to copy some files.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 Prompts for which copy operations to cancel. You will not be asked to copy
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 them again, unless you make more changes to the files. To cancel a shadow
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
537 permanently, remove the group from `shadow-literal-groups' or
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
538 `shadow-regexp-groups'."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (interactive)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (map-y-or-n-p (function (lambda (pair)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
541 (format "Cancel copying %s to %s? "
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (car pair) (cdr pair))))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
543 (function (lambda (pair)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (shadow-remove-from-todo pair)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 shadow-files-to-copy
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 '("shadow" "shadows" "cancel copy"))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
547 (message "There are %d shadows to be updated."
14349
96692e2ba103 (shadow-shadows, shadow-add-to-todo): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
548 (length shadow-files-to-copy))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (shadow-write-todo-file))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 ;;; Internal functions
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (defun shadow-make-group (regexp sites usernames)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
556 "Make a description of a file group---
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 actually a list of regexp ange-ftp file names---from REGEXP \(name of file to
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 be shadowed), list of SITES, and corresponding list of USERNAMES for each
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 site."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (if sites
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (cons (shadow-make-fullpath (car sites) (car usernames) regexp)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (shadow-make-group regexp (cdr sites) (cdr usernames)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 nil))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (defun shadow-copy-file (s)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 "Copy one shadow file."
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
567 (let* ((buffer
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
568 (cond ((get-file-buffer
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
569 (abbreviate-file-name (shadow-expand-file-name (car s)))))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 ((not (file-readable-p (car s)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (if (y-or-n-p
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
572 (format "Cannot find file %s--cancel copy request? "
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (car s)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (shadow-remove-from-todo s))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 nil)
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
576 ((or (eq t shadow-noquery)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
577 (y-or-n-p
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
578 (format "No buffer for %s -- update shadow anyway? "
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
579 (car s))))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (find-file-noselect (car s)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (to (shadow-expand-cluster-in-file-name (cdr s))))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
582 (when buffer
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (set-buffer buffer)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (save-restriction
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (widen)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
586 (condition-case i
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (progn
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (write-region (point-min) (point-max) to)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (shadow-remove-from-todo s))
14349
96692e2ba103 (shadow-shadows, shadow-add-to-todo): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
590 (error (message "Shadow %s not updated!" (cdr s))))))))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (defun shadow-shadows-of (file)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
593 "Return copy operations needed to update FILE.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
594 Filename should have clusters expanded, but otherwise can have any format.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 Return value is a list of dotted pairs like \(from . to), where from
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 and to are absolute file names."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 (or (symbol-value (intern-soft file shadow-hashtable))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (let* ((absolute-file (shadow-expand-file-name
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (or (shadow-local-file file) file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 shadow-homedir))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (canonical-file (shadow-contract-file-name absolute-file))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
602 (shadows
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (mapcar (function (lambda (shadow)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (cons absolute-file shadow)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (append
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (shadow-shadows-of-1
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 canonical-file shadow-literal-groups nil)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (shadow-shadows-of-1
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 canonical-file shadow-regexp-groups t)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (set (intern file shadow-hashtable) shadows))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (defun shadow-shadows-of-1 (file groups regexp)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
613 "Return list of FILE's shadows in GROUPS.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
614 Consider them as regular expressions if third arg REGEXP is true."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (if groups
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (let ((nonmatching
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
617 (shadow-remove-if
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (function (lambda (x) (shadow-file-match x file regexp)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (car groups))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (append (cond ((equal nonmatching (car groups)) nil)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
621 (regexp
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (let ((realpath (nth 2 (shadow-parse-fullpath file))))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
623 (mapcar
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
624 (function
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
625 (lambda (x)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (shadow-replace-path-component x realpath)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 nonmatching)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (t nonmatching))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (shadow-shadows-of-1 file (cdr groups) regexp)))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (defun shadow-add-to-todo ()
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
632 "If current buffer has shadows, add them to the list needing to be copied."
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
633 (let ((shadows (shadow-shadows-of
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
634 (shadow-expand-file-name
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (buffer-file-name (current-buffer))))))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
636 (when shadows
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (setq shadow-files-to-copy
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (shadow-union shadows shadow-files-to-copy))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
639 (when (not shadow-inhibit-message)
14349
96692e2ba103 (shadow-shadows, shadow-add-to-todo): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
640 (message "%s" (substitute-command-keys
96692e2ba103 (shadow-shadows, shadow-add-to-todo): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
641 "Use \\[shadow-copy-files] to update shadows."))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (sit-for 1))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (shadow-write-todo-file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 nil) ; Return nil for write-file-hooks
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (defun shadow-remove-from-todo (pair)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
647 "Remove PAIR from `shadow-files-to-copy'.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 PAIR must be (eq to) one of the elements of that list."
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
649 (setq shadow-files-to-copy
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (shadow-remove-if (function (lambda (s) (eq s pair)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 shadow-files-to-copy)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (defun shadow-read-files ()
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
654 "Visit and load `shadow-info-file' and `shadow-todo-file'.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
655 Thus restores shadowfile's state from your last Emacs session.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 Returns t unless files were locked; then returns nil."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (interactive)
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
658 (if (and (fboundp 'file-locked-p)
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
659 (or (stringp (file-locked-p shadow-info-file))
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
660 (stringp (file-locked-p shadow-todo-file))))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (progn
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (message "Shadowfile is running in another emacs; can't have two.")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (beep)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (sit-for 3)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 nil)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (save-excursion
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
667 (when shadow-info-file
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (set-buffer (setq shadow-info-buffer
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (find-file-noselect shadow-info-file)))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
670 (when (and (not (buffer-modified-p))
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
671 (file-newer-than-file-p (make-auto-save-file-name)
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
672 shadow-info-file))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (erase-buffer)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
674 (message "Data recovered from %s."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (car (insert-file-contents (make-auto-save-file-name))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (sit-for 1))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (eval-current-buffer))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
678 (when shadow-todo-file
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
679 (set-buffer (setq shadow-todo-buffer
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (find-file-noselect shadow-todo-file)))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
681 (when (and (not (buffer-modified-p))
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
682 (file-newer-than-file-p (make-auto-save-file-name)
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
683 shadow-todo-file))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 (erase-buffer)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
685 (message "Data recovered from %s."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (car (insert-file-contents (make-auto-save-file-name))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (sit-for 1))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (eval-current-buffer nil))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (shadow-invalidate-hashtable))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 t))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (defun shadow-write-info-file ()
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
693 "Write out information to `shadow-info-file'.
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
694 Also clear `shadow-hashtable', since when there are new shadows
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
695 defined, the old hashtable info is invalid."
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (shadow-invalidate-hashtable)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (if shadow-info-file
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (save-excursion
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (if (not shadow-info-buffer)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (setq shadow-info-buffer (find-file-noselect shadow-info-file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (set-buffer shadow-info-buffer)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (delete-region (point-min) (point-max))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (shadow-insert-var 'shadow-clusters)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (shadow-insert-var 'shadow-literal-groups)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (shadow-insert-var 'shadow-regexp-groups))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (defun shadow-write-todo-file (&optional save)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
708 "Write out information to shadow-todo-file.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 With nonnil argument also saves the buffer."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (save-excursion
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (if (not shadow-todo-buffer)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (setq shadow-todo-buffer (find-file-noselect shadow-todo-file)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (set-buffer shadow-todo-buffer)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (delete-region (point-min) (point-max))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 (shadow-insert-var 'shadow-files-to-copy)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (if save (shadow-save-todo-file))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (defun shadow-save-todo-file ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (save-excursion
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (set-buffer shadow-todo-buffer)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
722 (condition-case nil ; have to continue even in case of
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (basic-save-buffer) ; error, otherwise kill-emacs might
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (error ; not work!
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (message "WARNING: Can't save shadow todo file; it is locked!")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (sit-for 1))))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (defun shadow-invalidate-hashtable ()
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (setq shadow-hashtable (make-vector 37 0)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (defun shadow-insert-var (variable)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 "Prettily insert a setq command for VARIABLE.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 which, when later evaluated, will restore it to its current setting.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 SYMBOL must be the name of a variable whose value is a list."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 (let ((standard-output (current-buffer)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 (insert (format "(setq %s" variable))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (cond ((consp (eval variable))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
738 (insert "\n '(")
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (prin1 (car (eval variable)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (let ((rest (cdr (eval variable))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (while rest
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (insert "\n ")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (prin1 (car rest))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (setq rest (cdr rest)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (insert "))\n\n")))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (t (insert " ")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (prin1 (eval variable))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (insert ")\n\n")))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (defun shadow-save-buffers-kill-emacs (&optional arg)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 "Offer to save each buffer and copy shadows, then kill this Emacs process.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 With prefix arg, silently save all file-visiting buffers, then kill.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 Extended by shadowfile to automatically save `shadow-todo-file' and
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 look for files that have been changed and need to be copied to other systems."
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 ;; This function is necessary because we need to get control and save
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 ;; the todo file /after/ saving other files, but /before/ the warning
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 ;; message about unsaved buffers (because it can get modified by the
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 ;; action of saving other buffers). `kill-emacs-hook' is no good
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 ;; because it is not called at the correct time, and also because it is
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 ;; called when the terminal is disconnected and we cannot ask whether
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 ;; to copy files.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (interactive "P")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (shadow-save-todo-file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (save-some-buffers arg t)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (shadow-copy-files)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (shadow-save-todo-file)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (and (or (not (memq t (mapcar (function
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (lambda (buf) (and (buffer-file-name buf)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (buffer-modified-p buf))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (buffer-list))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (yes-or-no-p "Modified buffers exist; exit anyway? "))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 (or (not (fboundp 'process-list))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 ;; process-list is not defined on VMS.
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 (let ((processes (process-list))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 active)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (while processes
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 (and (memq (process-status (car processes)) '(run stop open))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (let ((val (process-kill-without-query (car processes))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (process-kill-without-query (car processes) val)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 val)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (setq active t))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (setq processes (cdr processes)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (or (not active)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (yes-or-no-p "Active processes exist; kill them and exit anyway? "))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 (kill-emacs)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
789 ;;; Lucid Emacs compatibility
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
792 ;; This is on hold until someone tells me about a working version of
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
793 ;; map-ynp for Lucid Emacs.
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
795 ;(when (string-match "Lucid" emacs-version)
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
796 ; (require 'symlink-fix)
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
797 ; (require 'ange-ftp)
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
798 ; (require 'map-ynp)
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
799 ; (if (not (fboundp 'file-truename))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
800 ; (fset 'shadow-expand-file-name
5288
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
801 ; (symbol-function 'symlink-expand-file-name)))
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
802 ; (if (not (fboundp 'ange-ftp-ftp-name))
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
803 ; (fset 'ange-ftp-ftp-name
c32c5d1aa89d (shadow-noquery): Use it.
Richard M. Stallman <rms@gnu.org>
parents: 5119
diff changeset
804 ; (symbol-function 'ange-ftp-ftp-path))))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 ;;; Hook us up
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
810 ;;;###autoload
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (defun shadow-initialize ()
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
812 "Set up file shadowing."
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
813 (interactive)
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (if (null shadow-homedir)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 (setq shadow-homedir
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 (file-name-as-directory (shadow-expand-file-name "~"))))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (if (null shadow-info-file)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
818 (setq shadow-info-file
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (shadow-expand-file-name "~/.shadows")))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (if (null shadow-todo-file)
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
821 (setq shadow-todo-file
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (shadow-expand-file-name "~/.shadow_todo")))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 (if (not (shadow-read-files))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (progn
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (message "Shadowfile information files not found - aborting")
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (beep)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (sit-for 3))
27685
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
828 (when (and (not shadow-inhibit-overload)
15ad3fb709f8 (shadow-when): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
829 (not (fboundp 'shadow-orig-save-buffers-kill-emacs)))
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
830 (defalias 'shadow-orig-save-buffers-kill-emacs
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
831 (symbol-function 'save-buffers-kill-emacs))
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
832 (defalias 'save-buffers-kill-emacs 'shadow-save-buffers-kill-emacs))
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (add-hook 'write-file-hooks 'shadow-add-to-todo)
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (define-key ctl-x-4-map "s" 'shadow-copy-files)))
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835
36041
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
836 (defun shadowfile-unload-hook ()
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
837 (if (fboundp 'shadow-orig-save-buffers-kill-emacs)
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
838 (fset 'save-buffers-kill-emacs
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
839 (symbol-function 'shadow-orig-save-buffers-kill-emacs)))
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
840 (remove-hook 'write-file-hooks 'shadow-add-to-todo))
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
841
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
842 (provide 'shadowfile)
8606adf5daf6 Doc fixes.
Dave Love <fx@gnu.org>
parents: 27685
diff changeset
843
5119
bf9e7676a73e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 ;;; shadowfile.el ends here