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,20 +639,29 @@ description."
(org-contacts--all-contacts))) (org-contacts--all-contacts)))
(name (plist-get contact :name)) (name (plist-get contact :name))
(file (plist-get contact :file)) (file (plist-get contact :file))
(position (plist-get contact :position))) (position (plist-get contact :position))
(company-doc-buffer (doc-buffer (get-buffer-create " *org-contact*"))
;; get org-contact headline and property drawer. (org-contact-buffer (get-buffer (find-file-noselect file)))
(with-current-buffer (find-file-noselect file) ;; get org-contact headline and property drawer.
(goto-char position) (contents (with-current-buffer org-contact-buffer
(when (derived-mode-p 'org-mode) (goto-char position)
;; `org-edit-src-code' is not a real narrowing command. (when (derived-mode-p 'org-mode)
;; Remove this first conditional if you don't want it. ;; `org-edit-src-code' is not a real narrowing command.
(cond ((ignore-errors (org-edit-src-code)) ;; Remove this first conditional if you don't want it.
(delete-other-windows)) (cond ((ignore-errors (org-edit-src-code))
((org-at-block-p) (delete-other-windows))
(org-narrow-to-block)) ((org-at-block-p)
(t (org-narrow-to-subtree))) (org-narrow-to-block))
(buffer-substring (point-min) (point-max))))))) (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) (defun org-contacts-org-complete--location-function (candidate)
"Return org-contacts location of contact candidate." "Return org-contacts location of contact candidate."