comparison lisp/files.el @ 4965:dad86ab54e36

(find-backup-file-name): Don't fatal-error on directories that are hard to read; fall back on ~/%backup%. (file-truename): Treat ~USER like just ~.
author Richard M. Stallman <rms@gnu.org>
date Wed, 10 Nov 1993 20:41:17 +0000
parents e7d8cfd205d4
children 4b1f2e4dcf34
comparison
equal deleted inserted replaced
4964:78c13f3054e5 4965:dad86ab54e36
328 (defun file-truename (filename) 328 (defun file-truename (filename)
329 "Return the truename of FILENAME, which should be absolute. 329 "Return the truename of FILENAME, which should be absolute.
330 The truename of a file name is found by chasing symbolic links 330 The truename of a file name is found by chasing symbolic links
331 both at the level of the file and at the level of the directories 331 both at the level of the file and at the level of the directories
332 containing it, until no links are left at any level." 332 containing it, until no links are left at any level."
333 (if (string= filename "~") 333 (if (or (string= filename "~")
334 (and (string= (substring filename 0 1) "~")
335 (string-match "~[^/]*" filename)))
334 (progn 336 (progn
335 (setq filename (expand-file-name filename)) 337 (setq filename (expand-file-name filename))
336 (if (string= filename "") 338 (if (string= filename "")
337 (setq filename "/")))) 339 (setq filename "/"))))
338 (let ((handler (find-file-name-handler filename))) 340 (let ((handler (find-file-name-handler filename)))
1296 and whose cdr is a list of old versions to consider deleting now." 1298 and whose cdr is a list of old versions to consider deleting now."
1297 (if (eq version-control 'never) 1299 (if (eq version-control 'never)
1298 (list (make-backup-file-name fn)) 1300 (list (make-backup-file-name fn))
1299 (let* ((base-versions (concat (file-name-nondirectory fn) ".~")) 1301 (let* ((base-versions (concat (file-name-nondirectory fn) ".~"))
1300 (bv-length (length base-versions)) 1302 (bv-length (length base-versions))
1301 (possibilities (file-name-all-completions 1303 possibilities
1302 base-versions 1304 (versions nil)
1303 (file-name-directory fn))) 1305 (high-water-mark 0)
1304 (versions (sort (mapcar 1306 (deserve-versions-p nil)
1305 (function backup-extract-version) 1307 (number-to-delete 0))
1306 possibilities) 1308 (condition-case ()
1307 '<)) 1309 (setq possibilities (file-name-all-completions
1308 (high-water-mark (apply 'max 0 versions)) 1310 base-versions
1309 (deserve-versions-p 1311 (file-name-directory fn))
1310 (or version-control 1312 versions (sort (mapcar
1311 (> high-water-mark 0))) 1313 (function backup-extract-version)
1312 (number-to-delete (- (length versions) 1314 possibilities)
1313 kept-old-versions kept-new-versions -1))) 1315 '<)
1316 high-water-mark (apply 'max 0 versions)
1317 deserve-versions-p (or version-control
1318 (> high-water-mark 0))
1319 number-to-delete (- (length versions)
1320 kept-old-versions kept-new-versions -1))
1321 (file-error
1322 (setq possibilities nil)))
1314 (if (not deserve-versions-p) 1323 (if (not deserve-versions-p)
1315 (list (make-backup-file-name fn)) 1324 (list (make-backup-file-name fn))
1316 (cons (concat fn ".~" (int-to-string (1+ high-water-mark)) "~") 1325 (cons (concat fn ".~" (int-to-string (1+ high-water-mark)) "~")
1317 (if (and (> number-to-delete 0) 1326 (if (and (> number-to-delete 0)
1318 ;; Delete nothing if there is overflow 1327 ;; Delete nothing if there is overflow