home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / emacs / sources / 810 < prev    next >
Encoding:
Text File  |  1992-11-19  |  6.4 KB  |  165 lines

  1. Newsgroups: gnu.emacs.sources
  2. Path: sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!caen!batcomputer!cornell!rochester!boris
  3. From: boris@cs.rochester.edu (Boris Goldowsky)
  4. Subject: Re: Automatic file carbon-copying
  5. Message-ID: <1992Nov19.173056.14441@cs.rochester.edu>
  6. Summary: shadow-files.el PATCH
  7. Reply-To: boris@slate.cs.rochester.edu
  8. Organization: University of Rochester
  9. References: <KEVIN.92Nov18163701@calamityjane.edscom.demon.co.uk> <1992Nov18.214842.16875@cs.rochester.edu>
  10. Date: Thu, 19 Nov 1992 17:30:56 GMT
  11. Lines: 152
  12.  
  13. It was pointed out to me that I used one function that I did not define,
  14. and that on some systems (system-name) does not return a full hostname.
  15. Here is a patch for those problems.  (Well, it actually does not fix the
  16. second problem, it just provides a way around it -- set shadow-system-name
  17. to the complete hostname, gotten by some other means.  Better solutions
  18. would be welcomed...
  19.  
  20. Bng                                (patch follows .sig)
  21. --
  22. Boris Goldowsky                        The only way you'll end up in a corner
  23.                                         Is by walking in too straight of a li
  24. boris@prodigal.psych.rochester.edu        --Claudia Schmidt                 n
  25. 57 Glasgow Street, Rochester, NY 14608                                      e
  26.  
  27. ----------------------------------------------------------------------
  28. *** shadow-files.el.orig    Thu Nov 19 12:25:52 1992
  29. --- shadow-files.el    Thu Nov 19 12:22:34 1992
  30. ***************
  31. *** 1,5 ****
  32.   ;;;; shadow-files.el: For keeping identical copies of files on multiple hosts
  33. ! ;;;  By Boris Goldowsky, 11/92.  Bugs to <boris@prodigal.psych.rochester.edu>.
  34.   
  35.   ;;; USE: put (require 'shadow-files) in your .emacs; add clusters and file
  36.   ;;; groups with shadow-define-cluster, shadow-define-group, and
  37. --- 1,5 ----
  38.   ;;;; shadow-files.el: For keeping identical copies of files on multiple hosts
  39. ! ;;;  By Boris Goldowsky, 11/19/92.  Bugs to <boris@psych.rochester.edu>.
  40.   
  41.   ;;; USE: put (require 'shadow-files) in your .emacs; add clusters and file
  42.   ;;; groups with shadow-define-cluster, shadow-define-group, and
  43. ***************
  44. *** 57,62 ****
  45. --- 57,69 ----
  46.   This is a replacement for kill-emacs-hook, which only allowed one hook
  47.   function.")
  48.   
  49. + ;;; The following two variables should in most cases initialize themselves
  50. + ;;; correctly.  They are provided as variables in case the defaults are wrong
  51. + ;;; on your machine.
  52. + (defvar shadow-system-name (system-name)
  53. +   "The complete hostname of this machine.")
  54.   (defvar shadow-homedir (expand-file-name (getenv "HOME"))
  55.     ;; Call to expand-file-name is in case we are using symlink-fix
  56.     "The directory that shadow file specs are assumed to be relative to 
  57. ***************
  58. *** 190,199 ****
  59.   ;;; Internal functions
  60.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61.   
  62.   (defun shadow-of (buffer)
  63.     "If BUFFER's file has shadows, return the list of shadow structures."
  64. !   (let* ((site (system-name))
  65. !      (file-abs (buffer-file-name buffer))
  66.        (file-rel (if (string-match (concat "^" (regexp-quote shadow-homedir))
  67.                        file-abs)
  68.                  (substring file-abs (1+ (match-end 0)))))
  69. --- 197,217 ----
  70.   ;;; Internal functions
  71.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  72.   
  73. + (defun shadow-member (item list)
  74. +   "Like `member' or `memq', but uses EQUAL for comparison."
  75. +   (let ((ptr list)
  76. +         (done nil)
  77. +         (result '()))
  78. +     (while (not (or done (endp ptr)))
  79. +       (cond ((equal item (car ptr))
  80. +              (setq done t)
  81. +              (setq result ptr)))
  82. +       (setq ptr (cdr ptr)))
  83. +     result))
  84.   (defun shadow-of (buffer)
  85.     "If BUFFER's file has shadows, return the list of shadow structures."
  86. !   (let* ((file-abs (buffer-file-name buffer))
  87.        (file-rel (if (string-match (concat "^" (regexp-quote shadow-homedir))
  88.                        file-abs)
  89.                  (substring file-abs (1+ (match-end 0)))))
  90. ***************
  91. *** 204,213 ****
  92.              (let ((f (shadow-file s)))
  93.                (and (string-equal file-abs 
  94.                       (expand-file-name f shadow-homedir))
  95. !               (shadow-site-match (shadow-site s) site)))))
  96.           group)
  97.         (setq found (append found 
  98. !                   (shadow-what-to-copy site nil buffer group)))))
  99.       (dolist (group shadow-regexp-groups)
  100.         (if (and (or (string-match (shadow-file (car group)) file-abs)
  101.              (if file-rel
  102. --- 222,233 ----
  103.              (let ((f (shadow-file s)))
  104.                (and (string-equal file-abs 
  105.                       (expand-file-name f shadow-homedir))
  106. !               (shadow-site-match (shadow-site s) 
  107. !                          shadow-system-name)))))
  108.           group)
  109.         (setq found (append found 
  110. !                   (shadow-what-to-copy shadow-system-name
  111. !                            nil buffer group)))))
  112.       (dolist (group shadow-regexp-groups)
  113.         (if (and (or (string-match (shadow-file (car group)) file-abs)
  114.              (if file-rel
  115. ***************
  116. *** 214,223 ****
  117.                  (string-match (shadow-file (car group)) file-rel)))
  118.              (some (function
  119.                 (lambda (s)
  120. !             (shadow-site-match (shadow-site s) site)))
  121.                group))
  122.         (setq found (append found
  123. !                   (shadow-what-to-copy site (or file-rel file-abs)
  124.                              buffer group)))))
  125.       found))
  126.   
  127. --- 234,245 ----
  128.                  (string-match (shadow-file (car group)) file-rel)))
  129.              (some (function
  130.                 (lambda (s)
  131. !             (shadow-site-match (shadow-site s) 
  132. !                        shadow-system-name)))
  133.                group))
  134.         (setq found (append found
  135. !                   (shadow-what-to-copy shadow-system-name
  136. !                            (or file-rel file-abs)
  137.                              buffer group)))))
  138.       found))
  139.   
  140. ***************
  141. *** 241,247 ****
  142.   if it is on the shadow-file-list."
  143.     (let ((shadows (shadow-of (current-buffer))))
  144.       (dolist (s shadows)
  145. !       (when (not (member-general s shadow-marked-files (function equal)))
  146.       (push s shadow-marked-files)
  147.       (message "Use %s to copy this file to %s."
  148.            (substitute-command-keys "\\[shadow-write-marked-files]")
  149. --- 263,269 ----
  150.   if it is on the shadow-file-list."
  151.     (let ((shadows (shadow-of (current-buffer))))
  152.       (dolist (s shadows)
  153. !       (when (not (shadow-member s shadow-marked-files))
  154.       (push s shadow-marked-files)
  155.       (message "Use %s to copy this file to %s."
  156.            (substitute-command-keys "\\[shadow-write-marked-files]")
  157. -- 
  158. Boris Goldowsky                        The only way you'll end up in a corner
  159.                                         Is by walking in too straight of a li
  160. boris@prodigal.psych.rochester.edu        --Claudia Schmidt                 n
  161. 57 Glasgow Street, Rochester, NY 14608                                      e
  162.