Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix obscure bug with sorting zk-index buffer by size #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions zk-index.el
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ all files in `zk-directory' will be returned as formatted candidates."
(zk--directory-files)))
(output))
(dolist (file list)
(when (string-match (zk-file-name-regexp) file)
(when (and file (string-match (zk-file-name-regexp) file))
(let ((id (if zk-index-invisible-ids
(propertize (match-string 1 file) 'invisible t)
(match-string 1 file)))
Expand Down Expand Up @@ -526,8 +526,7 @@ with query term STRING."
"Return list files in current index."
(let* ((ids (zk-index--current-id-list (buffer-name)))
(files (zk--parse-id 'file-path ids)))
(when files
files)))
files))

(defun zk-index--sort-created (list)
"Sort LIST for latest created."
Expand Down Expand Up @@ -559,8 +558,10 @@ with query term STRING."
"Sort LIST for latest modification."
(sort list
(lambda (a b)
(> (file-attribute-size (file-attributes a))
(file-attribute-size (file-attributes b))))))
;; `>' signals an error if it's passed a nil, but `file-attributes'
;; can return nil the file does not exist (or when passed a nil).
(> (or (file-attribute-size (file-attributes a)) -1)
(or (file-attribute-size (file-attributes b)) -1)))))

;;; ZK-Index Keymap Commands

Expand Down