[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 073b071 115/167: Allow to sort files by last modification
From: |
Oleh Krehel |
Subject: |
[elpa] master 073b071 115/167: Allow to sort files by last modification time. |
Date: |
Tue, 08 Dec 2015 10:50:24 +0000 |
branch: master
commit 073b071a12e7c5e6004b5bb68e7e48ce980401bf
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to sort files by last modification time.
* ivy.el (ivy--sort-files-by-date): New defun.
Example of use:
(add-to-list
'ivy-sort-matches-functions-alist
'(read-file-name-internal . ivy--sort-files-by-date))
This will result in e.g. `find-file' or `counsel-find-file' sorting
files by last modification time.
Fixes #213
---
ivy.el | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ivy.el b/ivy.el
index 0f62ab9..3dbfd82 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1726,6 +1726,15 @@ not matched collection functions.
The alist VAL is a sorting function with the signature of
`ivy--prefix-sort'.")
+(defun ivy--sort-files-by-date (_name candidates)
+ "Re-soft CANDIDATES according to file modification date."
+ (let ((default-directory ivy--directory))
+ (cl-sort candidates
+ (lambda (f1 f2)
+ (time-less-p
+ (nth 5 (file-attributes f2))
+ (nth 5 (file-attributes f1)))))))
+
(defun ivy--sort (name candidates)
"Re-sort CANDIDATES according to NAME.
All CANDIDATES are assumed to match NAME."
- [elpa] master 74bb138 144/167: Update ivy format functions., (continued)
- [elpa] master 74bb138 144/167: Update ivy format functions., Oleh Krehel, 2015/12/08
- [elpa] master 39e6733 129/167: Improve ivy TRAMP support, Oleh Krehel, 2015/12/08
- [elpa] master 63e714c 130/167: Allow access to TRAMP from "// C-j", Oleh Krehel, 2015/12/08
- [elpa] master 85bd44b 125/167: swiper.el: Modify the behavior with org-mode and visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action, Oleh Krehel, 2015/12/08
- [elpa] master ce6ab7a 135/167: Perform string-match in the original buffer, Oleh Krehel, 2015/12/08
- [elpa] master bc00eaf 137/167: Fix `counsel-ag` on Windows, Oleh Krehel, 2015/12/08
- [elpa] master ed2367b 134/167: swiper.el (swiper--candidates): Require outline, Oleh Krehel, 2015/12/08
- [elpa] master 80d4dde 141/167: Fix broken candidate index in ivy-resume, Oleh Krehel, 2015/12/08
- [elpa] master d9ecd2e 133/167: Fix the preselect for (swiper "one"), Oleh Krehel, 2015/12/08
- [elpa] master 073b071 115/167: Allow to sort files by last modification time.,
Oleh Krehel <=
- [elpa] master 0c62f7e 132/167: ivy.el (ivy-alt-done): Split into smaller defuns, Oleh Krehel, 2015/12/08
- [elpa] master 59df2e9 131/167: ivy.el (ivy-alt-done): Refactor, Oleh Krehel, 2015/12/08
- [elpa] master 2bec99d 146/167: Ease production of functions like ivy-format-function-default, Oleh Krehel, 2015/12/08
- [elpa] master c546ae4 150/167: Enable recursive swiper calls, Oleh Krehel, 2015/12/08
- [elpa] master 1bf4ae2 140/167: Warn the user about the behavior of ivy--regex-ignore-order, Oleh Krehel, 2015/12/08
- [elpa] master 99d214d 142/167: Ivy-resume should restore the buffer for swiper, Oleh Krehel, 2015/12/08
- [elpa] master 8abed59 143/167: Add counsel-grep, Oleh Krehel, 2015/12/08
- [elpa] master 3b67044 145/167: Convert ivy formatting functions to dotted pairs., Oleh Krehel, 2015/12/08
- [elpa] master ac09f6b 152/167: Fix the issue caused by recursive swiper calls, Oleh Krehel, 2015/12/08
- [elpa] master a34e532 155/167: swiper.el: Use show-all if outline-show-all isn't there, Oleh Krehel, 2015/12/08