summaryrefslogtreecommitdiff
path: root/lisp/filecache.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-11-17 14:16:46 +0800
committerChong Yidong <cyd@gnu.org>2012-11-17 14:16:46 +0800
commitec15e0ff0be9c3ab23d6df93953fc351fb4eb40e (patch)
tree735c5f4212c37d9d16884276f656c03a6a33d763 /lisp/filecache.el
parenta33da68be0fd3dd306155955210ddca6b521f28d (diff)
downloademacs-ec15e0ff0be9c3ab23d6df93953fc351fb4eb40e.tar.gz
* filecache.el (file-cache-add-file): Handle relative file name in the argument.
Fixes: debbugs:12694
Diffstat (limited to 'lisp/filecache.el')
-rw-r--r--lisp/filecache.el33
1 files changed, 16 insertions, 17 deletions
diff --git a/lisp/filecache.el b/lisp/filecache.el
index 2dd7c2673bf..23246c24c45 100644
--- a/lisp/filecache.el
+++ b/lisp/filecache.el
@@ -310,23 +310,22 @@ files in each directory, not to the directory list itself."
(defun file-cache-add-file (file)
"Add FILE to the file cache."
(interactive "fAdd File: ")
- (if (not (file-exists-p file))
- (message "Filecache: file %s does not exist" file)
- (let* ((file-name (file-name-nondirectory file))
- (dir-name (file-name-directory file))
- (the-entry (assoc-string
- file-name file-cache-alist
- file-cache-ignore-case)))
- ;; Does the entry exist already?
- (if the-entry
- (if (or (and (stringp (cdr the-entry))
- (string= dir-name (cdr the-entry)))
- (and (listp (cdr the-entry))
- (member dir-name (cdr the-entry))))
- nil
- (setcdr the-entry (cons dir-name (cdr the-entry))))
- ;; If not, add it to the cache
- (push (list file-name dir-name) file-cache-alist)))))
+ (setq file (file-truename file))
+ (unless (file-exists-p file)
+ (error "Filecache: file %s does not exist" file))
+ (let* ((file-name (file-name-nondirectory file))
+ (dir-name (file-name-directory file))
+ (the-entry (assoc-string file-name file-cache-alist
+ file-cache-ignore-case)))
+ ;; Does the entry exist already?
+ (if the-entry
+ (unless (or (and (stringp (cdr the-entry))
+ (string= dir-name (cdr the-entry)))
+ (and (listp (cdr the-entry))
+ (member dir-name (cdr the-entry))))
+ (setcdr the-entry (cons dir-name (cdr the-entry))))
+ ;; If not, add it to the cache
+ (push (list file-name dir-name) file-cache-alist))))
;;;###autoload
(defun file-cache-add-directory-using-find (directory)