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

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

[elpa] externals/org-contacts 1b028de47c 124/154: Fix contacts complete


From: ELPA Syncer
Subject: [elpa] externals/org-contacts 1b028de47c 124/154: Fix contacts complete not working problem
Date: Fri, 9 Sep 2022 15:58:54 -0400 (EDT)

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

    Fix contacts complete not working problem
    
    > I found ~org-contacts-org-complete-function~ returned a special value:
    >
    > #+begin_example
    > #f(compiled-function (string pred action) #<bytecode -0x9e1a398d61d3acb>)
    > #+end_example
    
    I can't see any way M-: (org-contacts-org-complete-function) RET
    can return the above value.  So I suspect a "pilot error".
    This looks like the 3rd value in the returned list (i.e. the value
    returned by `completion-table-dynamic`).
    
    > #+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* ((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
    >             (completion-table-dynamic
    >              (lambda (_)
    >                (mapcar
    >                 (lambda (contact) (plist-get contact :name))
    >                 (org-contacts--all-contacts))))))))
    > #+end_src
    
    This gives a `begin..end` region which presumably includes `@`.
    Does (plist-get contact :name) return names that start with `@`?
    If not, the completion will never match.
    
    > And test with execute following ~add-hook~ in org-mode buffer or
    >  emacs-lisp-mode buffer:
    
    In emacs-lisp-mode, `@` has symbol syntax, so
    (bounds-of-thing-at-point 'symbol)
    will include `@` in the returned region, whereas in Org mode
    `@` seems to have punctuation syntax so the `@` will not be included in
    the returned region.
    
    Maybe instead of `bounds-of-thing-at-point` you want to use something
    less "magic", like (skip-chars-backward "[:alnum:]@").
    
    > #+begin_src emacs-lisp
    > (add-hook 'completion-at-point-functions 
'org-contacts-org-complete-function nil 'local)
    > #+end_src
---
 org-contacts.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/org-contacts.el b/org-contacts.el
index 945435e0e4..ec26017323 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -698,7 +698,7 @@ description."
             (completion-table-dynamic
              (lambda (_)
                (mapcar
-                (lambda (contact) (plist-get contact :name))
+                (lambda (contact) (concat "@" (plist-get contact :name)))
                 (org-contacts--all-contacts))))
 
             ;; :predicate 'stringp



reply via email to

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