comparison lisp/vms-patch.el @ 92529:7b55b0a875cc

(make-legal-file-name): New obsolete alias. (make-valid-file-name): Rename from `make-legal-file-name'. (make-auto-save-file-name): Use it.
author Juanma Barranquero <lekktu@gmail.com>
date Thu, 06 Mar 2008 15:00:14 +0000
parents 107ccd98fa12
children 1e3a407766b9
comparison
equal deleted inserted replaced
92528:ee48946b8267 92529:7b55b0a875cc
41 "Create a suitably named buffer for visiting FILENAME, and return it. 41 "Create a suitably named buffer for visiting FILENAME, and return it.
42 FILENAME (sans directory) is used unchanged if that name is free; 42 FILENAME (sans directory) is used unchanged if that name is free;
43 otherwise a string <2> or <3> or ... is appended to get an unused name." 43 otherwise a string <2> or <3> or ... is appended to get an unused name."
44 (generate-new-buffer (downcase (file-name-nondirectory filename)))) 44 (generate-new-buffer (downcase (file-name-nondirectory filename))))
45 45
46 ;;; Given a string FN, return a similar name which is a legal VMS filename. 46 ;;; Given a string FN, return a similar name which is a valid VMS filename.
47 ;;; This is used to avoid invalid auto save file names. 47 ;;; This is used to avoid invalid auto save file names.
48 (defun make-legal-file-name (fn) 48 (defun make-valid-file-name (fn)
49 (setq fn (copy-sequence fn)) 49 (setq fn (copy-sequence fn))
50 (let ((dot nil) (indx 0) (len (length fn)) chr) 50 (let ((dot nil) (indx 0) (len (length fn)) chr)
51 (while (< indx len) 51 (while (< indx len)
52 (setq chr (aref fn indx)) 52 (setq chr (aref fn indx))
53 (cond 53 (cond
57 (eq chr ?$) (eq chr ?_) (and (eq chr ?-) (> indx 0)))) 57 (eq chr ?$) (eq chr ?_) (and (eq chr ?-) (> indx 0))))
58 (aset fn indx ?_))) 58 (aset fn indx ?_)))
59 (setq indx (1+ indx)))) 59 (setq indx (1+ indx))))
60 fn) 60 fn)
61 61
62 (define-obsolete-function-alias 'make-legal-file-name 'make-valid-file-name "23.1")
63
62 ;;; Auto save filesnames start with _$ and end with $. 64 ;;; Auto save filesnames start with _$ and end with $.
63 65
64 (defun make-auto-save-file-name () 66 (defun make-auto-save-file-name ()
65 "Return file name to use for auto-saves of current buffer. 67 "Return file name to use for auto-saves of current buffer.
66 This function does not consider `auto-save-visited-file-name'; 68 This function does not consider `auto-save-visited-file-name';
71 (if buffer-file-name 73 (if buffer-file-name
72 (concat (file-name-directory buffer-file-name) 74 (concat (file-name-directory buffer-file-name)
73 "_$" 75 "_$"
74 (file-name-nondirectory buffer-file-name) 76 (file-name-nondirectory buffer-file-name)
75 "$") 77 "$")
76 (expand-file-name (concat "_$_" (make-legal-file-name (buffer-name)) "$")))) 78 (expand-file-name (concat "_$_" (make-valid-file-name (buffer-name)) "$"))))
77 79
78 (defun auto-save-file-name-p (filename) 80 (defun auto-save-file-name-p (filename)
79 "Return t if FILENAME can be yielded by `make-auto-save-file-name'. 81 "Return t if FILENAME can be yielded by `make-auto-save-file-name'.
80 FILENAME should lack slashes. 82 FILENAME should lack slashes.
81 This is a separate function so that your `.emacs' file or the site's 83 This is a separate function so that your `.emacs' file or the site's