123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- (defun al/make-backup-file-name-1 (file)
- "Return a new backup file path of a given FILE.
- If the new path's directories do not exist, create them.
- This function is intended to be used as a substitution for
- `make-backup-file-name-1'."
- (let ((alist backup-directory-alist)
- (file (expand-file-name file))
- elt backup-directory abs-backup-directory backup-file)
- (while alist
- (setq elt (pop alist))
- (if (string-match (car elt) file)
- (setq backup-directory (cdr elt)
- alist nil)))
- (if (null backup-directory)
- (setq backup-file file)
- (setq backup-file
-
- (concat (directory-file-name (expand-file-name backup-directory))
- file)
- abs-backup-directory (file-name-directory backup-file))
- (if (and abs-backup-directory
- (not (file-exists-p abs-backup-directory)))
- (condition-case nil
- (make-directory abs-backup-directory 'parents)
- (file-error (setq backup-directory nil
- abs-backup-directory nil)))))
- backup-file))
- (defun al/backup-enable-predicate (name)
- "Function for `backup-enable-predicate'.
- Do not backup su/sudo files."
- (and (normal-backup-enable-predicate name)
- (not (let ((method (file-remote-p name 'method)))
- (when (stringp method)
- (member method '("su" "sudo")))))))
- (provide 'al-backup)
|