summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2014-07-04 14:37:13 +0100
committerAlex Bennée <alex.bennee@linaro.org>2014-07-04 14:37:13 +0100
commit09a16a3e382b19c5f72fc0ee4dd3b0ed5cb7f011 (patch)
tree34e8c6dceba7bdfb510bba1d70e4d70c5d978c43
parentcdcd895b6fe45fb26995de574e5fa090496c8d79 (diff)
lava-mode: new helpers + fixes
Make the timeout helper a bit neater. Add a find-latest-file helper.
-rw-r--r--lava-mode.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/lava-mode.el b/lava-mode.el
index a552a18..eecab88 100644
--- a/lava-mode.el
+++ b/lava-mode.el
@@ -202,9 +202,18 @@ This is intended to ensure hacking sessions don't hang around for too
(let* ((today (format-time-string "%e %b %Y"))
(tz (format-time-string "%Z"))
(then (format "%s %s %s" today end-of-day tz)))
- (let ((now (time-to-seconds (current-time)))
- (timeout (time-to-seconds (date-to-time then))))
- (round (- timeout now)))))
+ (round (time-to-seconds
+ (time-subtract
+ (date-to-time then)
+ (current-time))))))
+
+(defun lava-mode-find-latest-file (path pattern)
+ "Find the latest file matching `PATTERN' at `PATH'."
+ (let* ((all-files (directory-files path t pattern)))
+ (file-name-nondirectory
+ (-max-by #'(lambda (fileA fileB)
+ (not (time-less-p (nth 5 (file-attributes fileA))
+ (nth 5 (file-attributes fileB))))) all-files))))
(provide 'lava-mode)
;;; lava-mode.el ends here