X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=elisp.git;a=blobdiff_plain;f=enotes.el;h=48c4ed3f0299db3644175b1fbc16851a9de55ffe;hp=8f806b3ef183936e47e80839e3186a49276d10bf;hb=HEAD;hpb=3771096a125c7cff7216ca61ce51b2cda5a7aca1 diff --git a/enotes.el b/enotes.el index 8f806b3..48c4ed3 100644 --- a/enotes.el +++ b/enotes.el @@ -1,4 +1,3 @@ - ;; -*-Emacs-Lisp-*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -100,6 +99,11 @@ :type 'list :group 'enotes) +(defcustom enotes/default-time-fields "6:00" + "The default values for non-specified time fields when setting a date." + :type 'string + :group 'enotes) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defconst enotes/help-string " n,TAB: go to next note p,S-TAB: go to prev note @@ -417,23 +421,48 @@ heuristic. Improvements are welcome" )) (defun enotes/default-list (l default-l) - (when l (cons (or (car l) (car default-l)) (enotes/default-list (cdr l) (cdr default-l))))) + (when l (cons (or (car l) (car default-l)) + (enotes/default-list (cdr l) (cdr default-l))))) + +(defun enotes/default-time-fields () + (let ((time (decode-time (current-time)))) + (enotes/default-list + (parse-time-string enotes/default-time-fields) + `(0 0 6 1 ,(elt time 4) ,(elt time 5))) + )) (defun enotes/string-to-float-time (date) (let ((time (decode-time (current-time)))) (float-time (apply 'encode-time - (enotes/default-list (parse-time-string date) `(0 0 6 1 ,(elt time 4) ,(elt time 5))))))) + (enotes/default-list + (parse-time-string date) + (enotes/default-time-fields)))))) (defun enotes/second-to-delay (second) "Returns a string describing a delay in english" - (cond ((< second (- enotes/day-duration)) (format "%d day%s ago" (/ second -86400) (if (> (ftruncate (/ second -86400)) 1) "s" ""))) - ((< second -3600) (format "%dh ago" (/ second -3600))) - ((< second -300) (format "%dmin ago" (/ second -60))) - ((< second 0) (format "now!!!" (/ second -60))) - ((< second 3600) (format "in %dmin" (/ second 60))) - ((< second enotes/day-duration) (format "in %dh" (/ second 3600))) - ((< second enotes/month-duration) (format "in %d day%s" (/ second 86400) (if (> (ftruncate (/ second 86400)) 1) "s" ""))) - (t (format "in ~ %d month%s" (/ second 2592000) (if (> (ftruncate (/ second 2592000)) 1) "s" ""))))) + (cond ((< second (- enotes/day-duration)) + (format "%d day%s ago" + (/ second -86400) + (if (> (ftruncate (/ second -86400)) 1) + "s" ""))) + ((< second -3600) + (format "%dh ago" (/ second -3600))) + ((< second -300) + (format "%dmin ago" (/ second -60))) + ((< second 0) + (format "now!!!" (/ second -60))) + ((< second 3600) + (format "in %dmin" (/ second 60))) + ((< second enotes/day-duration) + (format "in %dh" (/ second 3600))) + ((< second (* 3 enotes/month-duration)) + (format "in %d day%s" (/ second 86400) + (if (> (ftruncate (/ second 86400)) 1) + "s" ""))) + (t + (format "in ~ %d month%s" (/ second 2592000) + (if (> (ftruncate (/ second 2592000)) 1) + "s" ""))))) (defun enotes/cond-propertize (cnd str prop) "Propertize STR if both CND and PROP are non-nil" @@ -451,10 +480,12 @@ heuristic. Improvements are welcome" ;; The small color tag (if (enotes/get-color note) - (propertize " " 'face (cons 'background-color - (enotes/get-color note))) + (propertize " " + 'face (cons 'background-color (enotes/get-color note))) " ") + (if (equal (enotes/get-event-time note) (enotes/get-warning-time note)) "+" " ") + " ") 'field 'title)