branch: externals/ebdb commit 8700b4a33f578328a4e8210a4befaa23590791ff Author: Eric Abrahamsen <e...@ericabrahamsen.net> Commit: Eric Abrahamsen <e...@ericabrahamsen.net>
Don't show redundant labels for fields that don't have their own This might indicate we need to re-think the label formatting procedure. * ebdb-com.el (ebdb-fmt-field-label): If phones and addresses are going to get a generic label on the left anyway, don't repeat that label in parentheses. Only output that label if the field instance has its own label. * ebdb-format.el (ebdb-fmt-field): Do the same for any field being output in the 'compact style. --- ebdb-com.el | 15 +++++++++++++-- ebdb-format.el | 10 +++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ebdb-com.el b/ebdb-com.el index 2588e16..ca48212 100644 --- a/ebdb-com.el +++ b/ebdb-com.el @@ -548,13 +548,24 @@ choice: that formatter should be selected explicitly." (field ebdb-field-phone) (_style (eql oneline)) &optional _record) - (format "phone (%s)" (ebdb-field-label field))) + (let ((label (slot-value field 'label))) + ;; Don't use `ebdb-field-label' because if the field has no label, + ;; we end up outputting something stupid like "phone (phone)". + (concat + "phone" + (when label + (format " (%s)" label))))) (cl-defmethod ebdb-fmt-field-label ((_fmt ebdb-formatter-ebdb) (field ebdb-field-address) (_style (eql oneline)) &optional _record) - (format "address (%s)" (ebdb-field-label field))) + (let ((label (slot-value field 'label))) + ;; As above. + (concat + "address" + (when label + (format " (%s)" label))))) (cl-defmethod ebdb-fmt-field-label ((_fmt ebdb-formatter-ebdb) (field ebdb-field-relation) diff --git a/ebdb-format.el b/ebdb-format.el index ceb02bf..cb2c987 100644 --- a/ebdb-format.el +++ b/ebdb-format.el @@ -248,9 +248,13 @@ a symbol indicating a style of some sort, such as 'compact or (field ebdb-field-labeled) (_style (eql compact)) (record ebdb-record)) - (format "(%s) %s" - (ebdb-field-label field) - (ebdb-fmt-field fmt field 'oneline record))) + (let ((label (slot-value field 'label))) + ;; The compact style shouldn't output a default label, only use it + ;; if the field in question really has one. + (concat + (when label + (format "(%s) " label)) + (ebdb-fmt-field fmt field 'oneline record)))) (cl-defmethod ebdb-fmt-field ((_fmt ebdb-formatter) (field ebdb-field)