[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb e169e58 4/8: Add guards against fields failing to
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb e169e58 4/8: Add guards against fields failing to produce strings |
Date: |
Mon, 6 Jan 2020 14:39:42 -0500 (EST) |
branch: externals/ebdb
commit e169e58e1d28c782b63b4bae5be810b036ebea18
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Add guards against fields failing to produce strings
* ebdb-com.el (ebdb-fmt-field-label): There always needs to be
a string to get propertized, otherwise the user can't edit/delete the
field.
(ebdb-current-field): Raise an error if no field is found.
---
ebdb-com.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index dfdc216..09f5011 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -385,7 +385,8 @@ position-marker mark)."
(next-single-property-change (point)
'ebdb-field nil
(line-end-position)))
- 'ebdb-field)))
+ 'ebdb-field)
+ (error "No field at point")))
;;; *EBDB* formatting
@@ -555,7 +556,16 @@ choice: that formatter should be selected explicitly."
(_record ebdb-record))
"Put the 'ebdb-field text property on FIELD. The value of the
property is the field instance itself."
- (propertize (cl-call-next-method) 'ebdb-field field))
+ (let ((str (cl-call-next-method)))
+ ;; If the field fails to produce a string, or produces an empty
+ ;; string, `propertize' will fail to add the 'ebdb-field property.
+ ;; Put in a dummy string to be propertized, otherwise the user
+ ;; will have no way of interacting with the field.
+ (propertize (if (or (null str)
+ (string-empty-p str))
+ "<empty>"
+ str)
+ 'ebdb-field field)))
(cl-defmethod ebdb-fmt-field ((_fmt ebdb-formatter-ebdb)
(field ebdb-field)
- [elpa] externals/ebdb updated (4fb5fc9 -> 50c8ee4), Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb 8b952a4 2/8: First draft of EBDB support for Notmuch, Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb 0f062bc 1/8: Simplify use of structs in migration, Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb 04c207d 7/8: Shift location of auto update hook for wl, Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb e169e58 4/8: Add guards against fields failing to produce strings,
Eric Abrahamsen <=
- [elpa] externals/ebdb c0e7c2d 5/8: Neglected to add a ebdb-read method for ebdb-field-tags, Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb 311775a 3/8: Bump copyright years to 2020, Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb 50c8ee4 8/8: Bump to version 0.6.12, Eric Abrahamsen, 2020/01/06
- [elpa] externals/ebdb 606d49a 6/8: Fix logic of singleton fields, Eric Abrahamsen, 2020/01/06