diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-28 10:45:55 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-28 10:51:37 +0200 |
| commit | fe536f569d2e1974c6976415f89af100a9bf80af (patch) | |
| tree | 4abb0ea689a389d12d243230aedb3af3c1d6bf74 | |
| parent | e0eda06495826cbb9ada9ced4f304ee9caf1916f (diff) | |
Handle deleted files in sort-by-modification/access-time
file-attributes returns nil for deleted files, causing
file-attribute-modification-time to error. Use 0 as the fallback
timestamp so deleted files sort to the end instead of crashing.
| -rw-r--r-- | projectile.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/projectile.el b/projectile.el index e7f84bf..ff68cb7 100644 --- a/projectile.el +++ b/projectile.el @@ -2729,7 +2729,8 @@ Parameters MODE VARIABLE VALUE are passed directly to (let ((default-directory (projectile-project-root)) (mtimes (make-hash-table :test 'equal :size (length files)))) (dolist (file files) - (puthash file (file-attribute-modification-time (file-attributes file)) mtimes)) + (let ((attrs (file-attributes file))) + (puthash file (if attrs (file-attribute-modification-time attrs) 0) mtimes))) (seq-sort (lambda (file1 file2) (not (time-less-p (gethash file1 mtimes) (gethash file2 mtimes)))) @@ -2740,7 +2741,8 @@ Parameters MODE VARIABLE VALUE are passed directly to (let ((default-directory (projectile-project-root)) (atimes (make-hash-table :test 'equal :size (length files)))) (dolist (file files) - (puthash file (file-attribute-access-time (file-attributes file)) atimes)) + (let ((attrs (file-attributes file))) + (puthash file (if attrs (file-attribute-access-time attrs) 0) atimes))) (seq-sort (lambda (file1 file2) (not (time-less-p (gethash file1 atimes) (gethash file2 atimes)))) |
