company-mode doc-buffer return customized buffer which support customization

This commit is contained in:
stardiviner 2021-11-18 16:53:06 +08:00
parent 18d4945fcc
commit 8a074f2a41

View file

@ -639,10 +639,11 @@ description."
(org-contacts--all-contacts)))
(name (plist-get contact :name))
(file (plist-get contact :file))
(position (plist-get contact :position)))
(company-doc-buffer
(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.
(with-current-buffer (find-file-noselect file)
(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.
@ -652,7 +653,15 @@ description."
((org-at-block-p)
(org-narrow-to-block))
(t (org-narrow-to-subtree)))
(buffer-substring (point-min) (point-max)))))))
(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."