Last active
December 23, 2015 03:49
-
-
Save mardukbp/6575838 to your computer and use it in GitHub Desktop.
Filter recently added entries in ebib UPDATED (Sep. 16 2013)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ebib-filter-n-days (n) | |
"Filter entries added in the last n days" | |
(let* ((field (intern-soft "timestamp")) | |
(day-of-year (string-to-number (format-time-string "%j"))) | |
(n-days-ago (- day-of-year (- n 1))) | |
(days-between (number-sequence n-days-ago day-of-year)) | |
(regexp-days-between (mapconcat #'(lambda (x) | |
(concat "\\(" (number-to-string x) "d\\)")) | |
days-between "\\|"))) | |
(ebib-execute-when | |
((real-db) | |
(setf (edb-filter ebib-cur-db) `(contains ,field ,regexp-days-between)) | |
(ebib-redisplay))) | |
)) | |
(defun ebib-filter-added-nth (key) | |
(interactive (list (if (featurep 'xemacs) | |
(event-key last-command-event) | |
last-command-event))) | |
(ebib-filter-n-days (- (if (featurep 'xemacs) | |
(char-to-int key) | |
key) 48))) | |
(mapc #'(lambda (key) | |
(define-key ebib-filters-map (format "%d" key) | |
'ebib-filter-added-nth)) | |
'(1 2 3 4 5 6 7 8 9)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment