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

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

[elpa] externals/ebdb f44a797 286/350: New function ebdb-mua-in-ebdb-buf


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb f44a797 286/350: New function ebdb-mua-in-ebdb-buffer
Date: Mon, 14 Aug 2017 11:46:55 -0400 (EDT)

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

    New function ebdb-mua-in-ebdb-buffer
    
    * ebdb-mua.el (ebdb-mua-in-ebdb-buffer): New function, a bit
      experimental.  Call it to temporarily move point to the pop-up EBDB
      buffer associated with the current MUA.  Re-wires "q" to return to
      the previous window configuration.  Don't document or bind for now.
---
 ebdb-mua.el | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/ebdb-mua.el b/ebdb-mua.el
index 10872f2..63cc7a1 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -1031,6 +1031,35 @@ bind `ebdb-message-all-addresses' to ALL."
   (interactive)
   (ebdb-mua-display-records 'recipients t))
 
+(defun ebdb-mua-in-ebdb-buffer ()
+  "From an MUA, temporarily move point to the corresponding EBDB buffer.
+
+All further operations will take place within the EBDB buffer as
+per normal, with the exception that \"q\" will return point to
+where it was in the MUA, rather than quitting the EBDB buffer."
+  (interactive)
+  (let* ((buf (get-buffer (ebdb-make-buffer-name)))
+        (w-conf (current-window-configuration))
+        (w-win (selected-window))
+        (w-point (window-point))
+        (e-win (if (window-live-p (get-buffer-window buf))
+                   (get-buffer-window buf)
+                 (ebdb-pop-up-window buf t (ebdb-popup-window))))
+        (key-m (make-sparse-keymap)))
+    (define-key key-m (kbd "q")
+      (lambda ()
+       (interactive)
+       (when (window-live-p w-win)
+         (set-window-configuration w-conf)
+         (goto-char w-point))))
+    (select-window e-win t)
+    (set-transient-map
+     key-m
+     (lambda ()
+       ;; Keep the transient map active until the user hits "q".
+       (null
+       (equal (this-command-keys-vector)
+              [?q]))))))
 
 ;;;###autoload
 (defun ebdb-mua-edit-field (&optional field header-class)



reply via email to

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