Article View: gnu.emacs.sources
Article #232Re: Automatic file carbon-copying
From: Boris Goldowsky
Date: Thu, 19 Nov 1992 17:30
Date: Thu, 19 Nov 1992 17:30
152 lines
6764 bytes
6764 bytes
It was pointed out to me that I used one function that I did not define,
and that on some systems (system-name) does not return a full hostname.
Here is a patch for those problems. (Well, it actually does not fix the
second problem, it just provides a way around it -- set shadow-system-name
to the complete hostname, gotten by some other means. Better solutions
would be welcomed...
Bng (patch follows .sig)
--
Boris Goldowsky The only way you'll end up in a corner
Is by walking in too straight of a li
boris@prodigal.psych.rochester.edu --Claudia Schmidt n
57 Glasgow Street, Rochester, NY 14608 e
----------------------------------------------------------------------
*** shadow-files.el.orig Thu Nov 19 12:25:52 1992
--- shadow-files.el Thu Nov 19 12:22:34 1992
***************
*** 1,5 ****
;;;; shadow-files.el: For keeping identical copies of files on multiple hosts
! ;;; By Boris Goldowsky, 11/92. Bugs to <boris@prodigal.psych.rochester.edu>.
;;; USE: put (require 'shadow-files) in your .emacs; add clusters and file
;;; groups with shadow-define-cluster, shadow-define-group, and
--- 1,5 ----
;;;; shadow-files.el: For keeping identical copies of files on multiple hosts
! ;;; By Boris Goldowsky, 11/19/92. Bugs to <boris@psych.rochester.edu>.
;;; USE: put (require 'shadow-files) in your .emacs; add clusters and file
;;; groups with shadow-define-cluster, shadow-define-group, and
***************
*** 57,62 ****
--- 57,69 ----
This is a replacement for kill-emacs-hook, which only allowed one hook
function.")
+ ;;; The following two variables should in most cases initialize themselves
+ ;;; correctly. They are provided as variables in case the defaults are wrong
+ ;;; on your machine.
+
+ (defvar shadow-system-name (system-name)
+ "The complete hostname of this machine.")
+
(defvar shadow-homedir (expand-file-name (getenv "HOME"))
;; Call to expand-file-name is in case we are using symlink-fix
"The directory that shadow file specs are assumed to be relative to
***************
*** 190,199 ****
;;; Internal functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun shadow-of (buffer)
"If BUFFER's file has shadows, return the list of shadow structures."
! (let* ((site (system-name))
! (file-abs (buffer-file-name buffer))
(file-rel (if (string-match (concat "^" (regexp-quote shadow-homedir))
file-abs)
(substring file-abs (1+ (match-end 0)))))
--- 197,217 ----
;;; Internal functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ (defun shadow-member (item list)
+ "Like `member' or `memq', but uses EQUAL for comparison."
+ (let ((ptr list)
+ (done nil)
+ (result '()))
+ (while (not (or done (endp ptr)))
+ (cond ((equal item (car ptr))
+ (setq done t)
+ (setq result ptr)))
+ (setq ptr (cdr ptr)))
+ result))
+
(defun shadow-of (buffer)
"If BUFFER's file has shadows, return the list of shadow structures."
! (let* ((file-abs (buffer-file-name buffer))
(file-rel (if (string-match (concat "^" (regexp-quote shadow-homedir))
file-abs)
(substring file-abs (1+ (match-end 0)))))
***************
*** 204,213 ****
(let ((f (shadow-file s)))
(and (string-equal file-abs
(expand-file-name f shadow-homedir))
! (shadow-site-match (shadow-site s) site)))))
group)
(setq found (append found
! (shadow-what-to-copy site nil buffer group)))))
(dolist (group shadow-regexp-groups)
(if (and (or (string-match (shadow-file (car group)) file-abs)
(if file-rel
--- 222,233 ----
(let ((f (shadow-file s)))
(and (string-equal file-abs
(expand-file-name f shadow-homedir))
! (shadow-site-match (shadow-site s)
! shadow-system-name)))))
group)
(setq found (append found
! (shadow-what-to-copy shadow-system-name
! nil buffer group)))))
(dolist (group shadow-regexp-groups)
(if (and (or (string-match (shadow-file (car group)) file-abs)
(if file-rel
***************
*** 214,223 ****
(string-match (shadow-file (car group)) file-rel)))
(some (function
(lambda (s)
! (shadow-site-match (shadow-site s) site)))
group))
(setq found (append found
! (shadow-what-to-copy site (or file-rel file-abs)
buffer group)))))
found))
--- 234,245 ----
(string-match (shadow-file (car group)) file-rel)))
(some (function
(lambda (s)
! (shadow-site-match (shadow-site s)
! shadow-system-name)))
group))
(setq found (append found
! (shadow-what-to-copy shadow-system-name
! (or file-rel file-abs)
buffer group)))))
found))
***************
*** 241,247 ****
if it is on the shadow-file-list."
(let ((shadows (shadow-of (current-buffer))))
(dolist (s shadows)
! (when (not (member-general s shadow-marked-files (function equal)))
(push s shadow-marked-files)
(message "Use %s to copy this file to %s."
(substitute-command-keys "\\[shadow-write-marked-files]")
--- 263,269 ----
if it is on the shadow-file-list."
(let ((shadows (shadow-of (current-buffer))))
(dolist (s shadows)
! (when (not (shadow-member s shadow-marked-files))
(push s shadow-marked-files)
(message "Use %s to copy this file to %s."
(substitute-command-keys "\\[shadow-write-marked-files]")
--
Boris Goldowsky The only way you'll end up in a corner
Is by walking in too straight of a li
boris@prodigal.psych.rochester.edu --Claudia Schmidt n
57 Glasgow Street, Rochester, NY 14608 e
Technical Details
Message-ID:
<1992Nov19.173056.14441@cs.rochester.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!caen!batcomputer!cornell!rochester!borisReferences:
<KEVIN.92Nov18163701@calamityjane.edscom.demon.co.uk> <1992Nov18.214842.16875@cs.rochester.edu>Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.sources Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!caen!batcomputer!cornell!rochester!boris From: boris@cs.rochester.edu (Boris Goldowsky) Subject: Re: Automatic file carbon-copying Message-ID: <1992Nov19.173056.14441@cs.rochester.edu> Summary: shadow-files.el PATCH Reply-To: boris@slate.cs.rochester.edu Organization: University of Rochester References: <KEVIN.92Nov18163701@calamityjane.edscom.demon.co.uk> <1992Nov18.214842.16875@cs.rochester.edu> Date: Thu, 19 Nov 1992 17:30:56 GMT Lines: 152