: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
))
(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 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"