Skip to content

Instantly share code, notes, and snippets.

@mardukbp
Last active December 23, 2015 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mardukbp/6575838 to your computer and use it in GitHub Desktop.
Save mardukbp/6575838 to your computer and use it in GitHub Desktop.
Filter recently added entries in ebib UPDATED (Sep. 16 2013)
(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