From ea3b76d3a7ae0d72be1239fa1fcf00f7d55710e7 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Wed, 3 Nov 2021 15:17:32 +0000 Subject: [PATCH] Further improvement of file-has-changed-p * lisp/files.el (file-has-changed-p): Expand the file name when necessary. Use cons instead of concat. Clarify and fix typo in the docstring. --- lisp/files.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 173198a424..ad814ed3d3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6187,16 +6187,18 @@ file-has-changed-p--hash-table (defun file-has-changed-p (file &optional tag) "Return non-nil if FILE has changed. The size and modification time of FILE are compared to the size -and modification time of tghe same FILE during a previous +and modification time of the same FILE during a previous invocation of `file-has-changed-p'. Thus, the first invocation -of `file-has-changed-p' always returns non-nil. +of `file-has-changed-p' on a given FILE always returns non-nil. The optional argument TAG, which must be a symbol, can be used to limit the comparison to invocations with identical tags; it can be the symbol of the calling function, for example." (let* ((fileattr (file-attributes file 'integer)) (attr (cons (file-attribute-size fileattr) (file-attribute-modification-time fileattr))) - (sym (concat (symbol-name tag) "@" file)) + (sym (cons tag (if (file-name-absolute-p file) + file + (expand-file-name file)))) (cachedattr (gethash sym file-has-changed-p--hash-table))) (when (not (equal attr cachedattr)) (puthash sym attr file-has-changed-p--hash-table)))) -- 2.33.0