branch: externals/ebdb commit 864c1f3c82f1f20f6301784956547a0116efcbce Author: Eric Abrahamsen <e...@ericabrahamsen.net> Commit: Eric Abrahamsen <e...@ericabrahamsen.net>
Give formatters a post-format-function slot * ebdb-format.el (ebdb-formatter): Essentially a post-format hook, intended to be used to set a major mode. (ebdb-format-to-tmp-buffer): Call it. * ebdb-com.el (ebdb-formatter-ebdb): Set it to #'text-mode for the ebdb formatter -- it isn't used during normal *EBDB* buffer formatting. --- ebdb-com.el | 5 ++++- ebdb-format.el | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ebdb-com.el b/ebdb-com.el index d114014..4e31108 100644 --- a/ebdb-com.el +++ b/ebdb-com.el @@ -389,7 +389,10 @@ If FULL is non-nil record includes the display information." ;;; *EBDB* formatting (defclass ebdb-formatter-ebdb (ebdb-formatter) - nil + ;; This post-format-function only comes into play when the user + ;; chooses the EBDB format in `ebdb-format-to-tmp-buffer'. + ((post-format-function + :initform #'text-mode)) :documentation "Abstract formatter base class for *EBDB* buffer(s)." :abstract t) diff --git a/ebdb-format.el b/ebdb-format.el index 181a58f..0ef16cf 100644 --- a/ebdb-format.el +++ b/ebdb-format.el @@ -89,7 +89,13 @@ \"collapsed\". What this means is up to the formatter, but it generally indicates that most of the field contents will hidden unless the user takes some action, such as clicking or - hitting <TAB>. (Currently unimplemented.)")) + hitting <TAB>. (Currently unimplemented.)") + (post-format-function + :type (or null function) + :initarg :post-format-function + :initform nil + :documentation "A function to be called after formatting is + complete. Probably a major mode.")) :abstract t :documentation "Abstract base class for EBDB formatters. Subclass this to produce real formatters.") @@ -376,7 +382,9 @@ grouped by field class." (insert (ebdb-fmt-footer formatter records)) (set-buffer-file-coding-system fmt-coding))) (pop-to-buffer buf) - (text-mode))) + (let ((f (slot-value formatter 'post-format-function))) + (when (fboundp f) + (funcall f))))) ;;;###autoload (defun ebdb-format-all-records (&optional formatter)