[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 4f72046 1/6: New defcustoms handling formatting of
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 4f72046 1/6: New defcustoms handling formatting of anniversary dates |
Date: |
Tue, 19 May 2020 15:49:20 -0400 (EDT) |
branch: externals/ebdb
commit 4f72046550c72a134cc4d25f2f525b4c8448bc6e
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
New defcustoms handling formatting of anniversary dates
Partially addresses #88, but we should be handling the different
calendars as well.
* ebdb.el (ebdb-anniversary-md-format, ebdb-anniversary-ymd-format):
New options handling date formatting strings.
* ebdb.el (ebdb-string): Use new options.
---
ebdb.el | 41 +++++++++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index 6090ee9..c3ad803 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -340,9 +340,24 @@ Emacs, always query before reverting."
:group 'ebdb-utilities-anniv
:type 'boolean)
+(defcustom ebdb-anniversary-md-format "%B %d"
+ "Format string used for displaying month-day anniversary dates.
+See the docstring of `format-time-string' for the meaning of
+various formatting escapes, but keep in mind that only month and
+day values are available."
+ :group 'ebdb-utilities-anniv
+ :type 'string)
+
+(defcustom ebdb-anniversary-ymd-format "%B %d, %Y"
+ "Format string used for displaying year-month-day anniversary dates.
+See the docstring of `format-time-string' for the meaning of
+various formatting escapes, but keep in mind that only year,
+month, and day values are available."
+ :group 'ebdb-utilities-anniv
+ :type 'string)
+
(defvar ebdb-diary-entries nil
"A list of all anniversary diary entries.
-
Entries are added and removed in the `ebdb-init-field' and
`ebdb-delete-field' methods of the `ebdb-field-anniversary'
class, and added with the `ebdb-diary-add-entries' function.
@@ -2129,15 +2144,6 @@ Eventually this method will go away."
(list month day year))
obj)))
-(cl-defmethod ebdb-string ((ann ebdb-field-anniversary))
- (let* ((date (slot-value ann 'date))
- (month-name (aref calendar-month-name-array
- (1- (nth 0 date))))
- (str (format "%s %d" month-name (nth 1 date))))
- (when (nth 2 date)
- (setq str (concat str (format ", %d" (nth 2 date)))))
- str))
-
;; `ebdb-field-anniv-diary-entry' is defined below.
(cl-defmethod ebdb-init-field ((anniv ebdb-field-anniversary) record)
(when ebdb-use-diary
@@ -2145,6 +2151,21 @@ Eventually this method will go away."
'ebdb-diary-entries
(ebdb-field-anniv-diary-entry anniv record))))
+(cl-defmethod ebdb-string ((ann ebdb-field-anniversary))
+ (let* ((date (slot-value ann 'date))
+ (encoded (encode-time
+ ;; Why did I reverse the day month order?!
+ `(0 0 0
+ ,(nth 1 date)
+ ,(car date)
+ ,(nth 2 date)
+ nil nil nil))))
+ (format-time-string
+ (if (nth 2 date)
+ ebdb-anniversary-ymd-format
+ ebdb-anniversary-md-format)
+ encoded)))
+
(cl-defmethod ebdb-delete-field ((anniv ebdb-field-anniversary)
record &optional _unload)
(when ebdb-use-diary
- [elpa] externals/ebdb updated (5d8b473 -> 15f5bd8), Eric Abrahamsen, 2020/05/19
- [elpa] externals/ebdb 4f72046 1/6: New defcustoms handling formatting of anniversary dates,
Eric Abrahamsen <=
- [elpa] externals/ebdb d0321ab 2/6: Fix to previous anniversary display defcustoms, Eric Abrahamsen, 2020/05/19
- [elpa] externals/ebdb 4027218 3/6: Have ebdb-record-mail sort mails by priority, Eric Abrahamsen, 2020/05/19
- [elpa] externals/ebdb 3913555 4/6: Update last commit, Eric Abrahamsen, 2020/05/19
- [elpa] externals/ebdb f28b665 5/6: Prevent sort from actually altering record mails, Eric Abrahamsen, 2020/05/19
- [elpa] externals/ebdb 15f5bd8 6/6: Don't do anything clever with phone numbers by default, Eric Abrahamsen, 2020/05/19