-;; see also ../packages/auto-save.el
-(defun make-auto-save-file-name (&optional filename)
- "Return file name to use for auto-saves of current buffer.
-Does not consider `auto-save-visited-file-name' as that variable is checked
-before calling this function. You can redefine this for customization.
-See also `auto-save-file-name-p'."
- (let ((fname (or filename buffer-file-name))
- name)
- (setq name
- (if fname
- (concat (file-name-directory fname)
- "#"
- (file-name-nondirectory fname)
- "#")
-
- ;; Deal with buffers that don't have any associated files. (Mail
- ;; mode tends to create a good number of these.)
-
- (let ((buffer-name (buffer-name))
- (limit 0))
- ;; Use technique from Sebastian Kremer's auto-save
- ;; package to turn slashes into \\!. This ensures that
- ;; the auto-save buffer name is unique.
-
- ;; #### - yuck! yuck! yuck! move this functionality
- ;; somewhere else and make the name translation customizable.
- ;; Using "\!" as part of a filename on a UNIX filesystem is nearly
- ;; IMPOSSIBLE to get past a shell parser. -stig
-
- (while (string-match "[/\\]" buffer-name limit)
- (setq buffer-name
- (concat (substring buffer-name 0 (match-beginning 0))
- (if (string= (substring buffer-name
- (match-beginning 0)
- (match-end 0))
- "/")
- "\\!"
- "\\\\")
- (substring buffer-name (match-end 0))))
- (setq limit (1+ (match-end 0))))
-
- ;; (expand-file-name (format "#%s#%s#" (buffer-name) (make-temp-name "")))
-
- ;; jwz: putting the emacs PID in the auto-save file name
- ;; is bad news, because that defeats auto-save-recovery of
- ;; *mail* buffers -- the (sensible) code in sendmail.el
- ;; calls (make-auto-save-file-name) to determine whether
- ;; there is unsent, auto-saved mail to recover. If that
- ;; mail came from a previous emacs process (far and away
- ;; the most likely case) then this can never succeed as
- ;; the pid differs.
-
- (expand-file-name (format "#%s#" buffer-name)))
- ))
- ;; don't try to write auto-save files in unwritable places. Unless
- ;; there's already an autosave file here, put ours somewhere safe. --Stig
- (if (or (file-writable-p name)
- (file-exists-p name))
- name
- (expand-file-name (concat "~/" (file-name-nondirectory name))))))
-
-(defun auto-save-file-name-p (filename)
- "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'.
-FILENAME should lack slashes.
-You can redefine this for customization."
- (string-match "\\`#.*#\\'" filename))