[comp.os.vms] Patch to files.el for VMS Dired

rbr4@uhura.cc.rochester.edu (Roland Roberts) (09/01/89)

Several people pointed out that there still existed one additional
problem (at least) with the way VMS dired works.  When trying to save
a file which has a version number, e.g. FOO.BAR;3 one typically gets
an error message about an IO error.  It turned out to be easier to fix
than I expected, so below is the patch to files.el which will prevent
this.

On VMS, this patch causes a buffer named FOO.BAR;3 associated with
file DISK:[DIR]FOO.BAR;3 to have the suffix dropped both in the buffer
name and its associated file name once an attempt to save is made.
The result is that the file will be saved as the next higher version
number according to customary VMS usage.  So if there is are versions
4, 5, and 6, this will now be saved as version 7.

If you don't have the 'patch' program, don't worry.  These diff's are
all inserted into a single spot in the expression basic-save-buffer.
It should be quite easy to find.

*** [lisp]files.el
--- files.el
**************
*** 653,658
    (interactive)
    (if (buffer-modified-p)
        (let (setmodes tempsetmodes)
  	(or buffer-file-name
  	    (progn
  	      (setq buffer-file-name
--- 653,679 -----
    (interactive)
    (if (buffer-modified-p)
        (let (setmodes tempsetmodes)
+ 	(if (and (eq system-type 'vax-vms)
+ 		 (string= buffer-file-name
+ 			  (file-name-sans-versions buffer-file-name)))
+ 	    (let ((buffer-new-name nil)
+ 		  (buffer-name-list nil))
+ 	      ;; Strip VMS version number before save
+ 	      (setq buffer-file-name
+ 		    (file-name-sans-versions buffer-file-name))
+ 	      ;; Select a buffer name to correspond
+ 	      (setq buffer-new-name
+ 		    (downcase (file-name-nondirectory buffer-file-name)))
+ 	      ;; Check to see if the buffer name is in use
+ 	      (setq buffer-name-list
+ 		    (mapcar (function buffer-name) (buffer-list)))
+ 	      (while (and buffer-name-list
+ 			  (not (string= buffer-new-name
+ 					(car buffer-name-list))))
+ 		(setq buffer-name-list (cdr buffer-name-list)))
+ 	      ;; Change the buffer name, if no conflict
+ 	      (if (not buffer-name-list)
+ 		  (rename-buffer buffer-new-name))))
  	(or buffer-file-name
  	    (progn
  	      (setq buffer-file-name
-- 
Roland Roberts                      BITNET: roberts@uornsrl
  Nuclear Structure Research Lab  INTERNET: rbr4@uhura.cc.rochester.edu
  271 East River Road                 UUCP: rochester!ur-cc!uhura!rbr4
  Rochester, NY  14267                AT&T: (716) 275-8962