Skip to content

Instantly share code, notes, and snippets.

@joostkremers
Created January 7, 2015 08:26
Show Gist options
  • Select an option

  • Save joostkremers/de6bf299a3941b0f1129 to your computer and use it in GitHub Desktop.

Select an option

Save joostkremers/de6bf299a3941b0f1129 to your computer and use it in GitHub Desktop.
Ebib: filter recently added entries (updated for Ebib 2.1)
(defun ebib-filter-n-days (n)
"Filter entries added in the last n days"
(let* ((field "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)
(ebib-db-set-filter `(contains ,field ,regexp-days-between) ebib--cur-db)
(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))
@joostkremers
Copy link
Author

This gist is the code from Ebib issue #24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment