I try to write a capf function for org-contacts to auto complete contact names after "@". Here is my code, but it still does not work. Can someone help me to review my code and figure out the problem. If you provide problem solution is welcome. Thanks a lot. #+begin_src emacs-lisp (defun org-contacts-org-complete-function () "Function used in `completion-at-point-functions' in `org-mode' to complete @name." (when-let* ((@-prefix-p (string-prefix-p "@" (thing-at-point 'symbol))) (symbol (thing-at-point 'symbol)) (prefix (substring-no-properties symbol 1 nil)) (bounds (bounds-of-thing-at-point 'symbol)) (begin (car bounds)) (end (cdr bounds))) (list begin end (all-completions prefix (mapcar (lambda (contact) (plist-get contact :name)) (org-contacts--all-contacts)) 'stringp) ;; (completion-table-dynamic ;; (lambda (input) ;; (mapcar ;; (lambda (contact) (plist-get contact :name)) ;; (org-contacts--all-contacts)))) :exclusive 'no :annotation-function ; tags ;; TODO (lambda (candidate) "Tags: ") :company-docsig #'identity ; metadata :company-doc-buffer ; doc popup (lambda (candidate) (let ((name (plist-get candidate :name)) (file (plist-get candidate :file)) (position (plist-get candidate :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))))))) :company-location (lambda (candidate) (let ((name (plist-get candidate :name)) (file (plist-get candidate :file)) (position (plist-get candidate :position))) (with-current-buffer (find-file-noselect file) (goto-char position) (cons (current-buffer) position))))))) ;;; @Chr (add-hook 'completion-at-point-functions 'org-contacts-completion-at-point nil 'local) ;; (add-to-list 'completion-at-point-functions 'org-contacts-completion-at-point) #+end_src -- [ stardiviner ] I try to make every word tell the meaning that I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3