[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-contacts c1d2b6dfbc 122/154: prototype of org-conta
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-contacts c1d2b6dfbc 122/154: prototype of org-contacts contact complete |
Date: |
Fri, 9 Sep 2022 15:58:53 -0400 (EDT) |
branch: externals/org-contacts
commit c1d2b6dfbc9c8e7e0cc08f84f1635b776a738e07
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
prototype of org-contacts contact complete
---
org-contacts.el | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/org-contacts.el b/org-contacts.el
index 8aed3533f9..945435e0e4 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -642,6 +642,102 @@ description."
(run-hook-with-args-until-success
'org-contacts-complete-functions string))))))))
+(defun org-contacts-org-complete--annotation-function (candidate)
+ "Return org-contacts tags of contact candidate."
+ ;; TODO
+ "Tags: ")
+
+(defun org-contacts-org-complete--doc-function (candidate)
+ "Return org-contacts content of contact 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)))))))
+
+(defun org-contacts-org-complete--location-function (candidate)
+ "Return org-contacts location of contact 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))))
+
+(defun org-contacts-org-complete-function ()
+ "Function used in `completion-at-point-functions' in `org-mode' to complete
@name."
+ (when-let* ((bounds (bounds-of-thing-at-point 'symbol))
+ (begin (1- (car bounds)))
+ (end (cdr bounds))
+ (symbol (buffer-substring-no-properties begin end))
+ (org-contacts-prefix-p (string-prefix-p "@" symbol))
+ ;; (prefix (substring-no-properties symbol 1 nil))
+ )
+ (when org-contacts-prefix-p
+ (list begin
+ end
+
+ ;; (all-completions
+ ;; prefix
+ ;; (mapcar
+ ;; (lambda (contact) (plist-get contact :name))
+ ;; (org-contacts--all-contacts))
+ ;; 'stringp)
+
+ (completion-table-dynamic
+ (lambda (_)
+ (mapcar
+ (lambda (contact) (plist-get contact :name))
+ (org-contacts--all-contacts))))
+
+ ;; :predicate 'stringp
+ ;; :exclusive 'no
+ ;; properties check out `completion-extra-properties'
+ ;; :annotation-function
#'org-contacts-org-complete--annotation-function
+ ;; :exit-function ; TODO change completion candidate inserted
contact name into org-contact link??
+
+ ;; :company-docsig #'identity ;
metadata
+ ;; :company-doc-buffer #'org-contacts-org-complete--doc-function ;
doc popup
+ ;; :company-location #'org-contacts-org-complete--location-function
+ ))))
+
+(add-hook 'completion-at-point-functions 'org-contacts-org-complete-function
nil 'local)
+
+(try-completion
+ "tri"
+ (mapcar
+ (lambda (contact) (plist-get contact :name))
+ (org-contacts--all-contacts)))
+
+(all-completions "Chr" (nth 2 (org-contacts-org-complete-function)))
+
+;; @Chris
+
+;; (type-of
+;; (all-completions
+;; "tri"
+;; (mapcar
+;; (lambda (contact) (plist-get contact :name))
+;; (org-contacts--all-contacts))
+;; 'stringp))
+
+;;; TEST
+;;; @chris
+;; (add-hook 'completion-at-point-functions
'org-contacts-org-complete-function nil 'local)
+;; (remove-hook 'completion-at-point-functions
'org-contacts-completion-at-point 'local)
+;; (add-to-list 'completion-at-point-functions
'org-contacts-org-complete-function)
+
(defun org-contacts-gnus-get-name-email ()
"Get name and email address from Gnus message."
(if (gnus-alive-p)
- [elpa] externals/org-contacts 4d41ad256d 074/154: Merge branch 'maint', (continued)
- [elpa] externals/org-contacts 4d41ad256d 074/154: Merge branch 'maint', ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 36c6b30ec2 077/154: contrib/lisp/org-contacts.el: Add a hook to allow users to plug completion functions, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 2ec03e18b8 086/154: org-contacts: Fix org-contacts-matcher for BIRTHDAYs, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 33c5e0582c 085/154: contrib: move a few libraries to cl-lib in place of compile-time cl., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 27bec00a60 089/154: org-agenda: Remove unnecessary visibility modification, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts f07048b75d 092/154: Use `string-match-p' instead of `org-string-match-p', ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 4e3f139857 095/154: Fix function declarations, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts eedaff3498 103/154: org-contacts.el: Only use org-id-store-link if org-id is loaded, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 4540f987ec 111/154: Clean up some more headers, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts c98281fcfe 113/154: Remove compatibility code, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts c1d2b6dfbc 122/154: prototype of org-contacts contact complete,
ELPA Syncer <=
- [elpa] externals/org-contacts 1991ef0ecd 106/154: Fix typo in 304fd01fe, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 038a608e79 119/154: Fix AVATAR property value not exist problem, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts abe24d6f34 137/154: Display company-mode doc buffer bellow current window, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 18d4945fcc 132/154: Fix company-mode `company-show-location' support, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts e52d4eed74 148/154: Drop the "v" prefix in "gnus" version., ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts a9b2eef66f 038/154: org-contacts.el: Check if the database need a refresh in a dedicated function, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 938ca34558 019/154: Add missing word to org-contacts y-or-n-p question, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 010b2ec38a 029/154: org-contacts.el (org-contacts-format-name): New function, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts 50d8ec9752 031/154: Improve `completion-at-point' for `org-contacts.el' in mail, ELPA Syncer, 2022/09/09
- [elpa] externals/org-contacts b34f505d38 042/154: contrib/lisp/org-contacts.el (org-contacts-complete-name): Prevent an error when there is no completion available, ELPA Syncer, 2022/09/09