emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ebdb 79ed878 201/350: Handle formatting to a fake *EBDB


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 79ed878 201/350: Handle formatting to a fake *EBDB* buffer
Date: Mon, 14 Aug 2017 11:46:36 -0400 (EDT)

branch: externals/ebdb
commit 79ed8786c1b3d714ed14a3c669b6dc2b708d988b
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Handle formatting to a fake *EBDB* buffer
    
    Fixes #26
    
    * ebdb-format.el (ebdb-format-to-tmp-buffer): It's possible for the
      user to choose a *EBDB* formatter when formatting to tmp buffer.  In
      that case, output a buffer containing what the *EBDB* buffer would
      have contained, but then remove all properties and put it in text
      mode.
---
 ebdb-format.el | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/ebdb-format.el b/ebdb-format.el
index 3b064c6..9f7e950 100644
--- a/ebdb-format.el
+++ b/ebdb-format.el
@@ -404,15 +404,33 @@ grouped by field class."
    (list (ebdb-prompt-for-formatter)
         (ebdb-do-records)))
   (let ((buf (get-buffer-create ebdb-format-buffer-name))
-       (fmt-coding (slot-value formatter 'coding-system)))
-    (with-current-buffer buf
-      (erase-buffer)
-      (insert (ebdb-fmt-header formatter records))
-      (dolist (r records)
-       (insert (ebdb-fmt-record formatter r)))
-      (insert (ebdb-fmt-footer formatter records))
-      (set-buffer-file-coding-system fmt-coding))
-    (pop-to-buffer buf)))
+       (fmt-coding (slot-value formatter 'coding-system))
+       (ebdb-p (object-of-class-p formatter 'ebdb-formatter-ebdb)))
+    ;; If the user has chosen an ebdb formatter, we need to
+    ;; special-case it.  First because the ebdb formatters handle
+    ;; insertion themselves and the other formatters don't, which was
+    ;; arguably a bad choice.  Second because ebdb formatting should
+    ;; behave differently here -- we assume that what the user
+    ;; actually wants is a text-mode buffer containing the text that
+    ;; *would have been* displayed in an *EBDB* buffer, but with all
+    ;; properties removed.
+    (if ebdb-p
+       (save-window-excursion
+         (ebdb-display-records records formatter nil nil nil " *EBDB Fake 
Output*")
+         (let ((str (buffer-substring-no-properties
+                     (point-min) (point-max))))
+           (with-current-buffer buf
+             (erase-buffer)
+             (insert str))))
+      (with-current-buffer buf
+       (erase-buffer)
+       (insert (ebdb-fmt-header formatter records))
+       (dolist (r records)
+         (insert (ebdb-fmt-record formatter r)))
+       (insert (ebdb-fmt-footer formatter records))
+       (set-buffer-file-coding-system fmt-coding)))
+    (pop-to-buffer buf)
+    (text-mode)))
 
 ;;;###autoload
 (defun ebdb-format-all-records (&optional formatter)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]