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

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

[elpa] externals/org-contacts 8a074f2a41 133/154: company-mode doc-buffe


From: ELPA Syncer
Subject: [elpa] externals/org-contacts 8a074f2a41 133/154: company-mode doc-buffer return customized buffer which support customization
Date: Fri, 9 Sep 2022 15:58:54 -0400 (EDT)

branch: externals/org-contacts
commit 8a074f2a41ea7bec4f8396955ccec172d7f8a08b
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    company-mode doc-buffer return customized buffer which support customization
---
 org-contacts.el | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/org-contacts.el b/org-contacts.el
index 44eb0163ae..d9d9e2b6fe 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -639,20 +639,29 @@ description."
                    (org-contacts--all-contacts)))
          (name (plist-get contact :name))
          (file (plist-get contact :file))
-         (position (plist-get contact :position)))
-    (company-doc-buffer
-     ;; get org-contact headline and property drawer.
-     (with-current-buffer (find-file-noselect file)
-       (goto-char position)
-       (when (derived-mode-p 'org-mode)
-         ;; `org-edit-src-code' is not a real narrowing command.
-         ;; Remove this first conditional if you don't want it.
-         (cond ((ignore-errors (org-edit-src-code))
-                (delete-other-windows))
-               ((org-at-block-p)
-                (org-narrow-to-block))
-               (t (org-narrow-to-subtree)))
-         (buffer-substring (point-min) (point-max)))))))
+         (position (plist-get contact :position))
+         (doc-buffer (get-buffer-create " *org-contact*"))
+         (org-contact-buffer (get-buffer (find-file-noselect file)))
+         ;; get org-contact headline and property drawer.
+         (contents (with-current-buffer org-contact-buffer
+                     (goto-char position)
+                     (when (derived-mode-p 'org-mode)
+                       ;; `org-edit-src-code' is not a real narrowing command.
+                       ;; Remove this first conditional if you don't want it.
+                       (cond ((ignore-errors (org-edit-src-code))
+                              (delete-other-windows))
+                             ((org-at-block-p)
+                              (org-narrow-to-block))
+                             (t (org-narrow-to-subtree)))
+                       (buffer-substring (point-min) (point-max))))))
+    (with-current-buffer doc-buffer
+      (read-only-mode 1)
+      (let ((inhibit-read-only t))
+        (erase-buffer)
+        (insert contents)
+        (org-mode)
+        (org-show-all)))
+    doc-buffer))
 
 (defun org-contacts-org-complete--location-function (candidate)
   "Return org-contacts location of contact candidate."



reply via email to

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